Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permit unicode string values with Substitution helper #335

Merged
merged 2 commits into from
Aug 31, 2017
Merged

Permit unicode string values with Substitution helper #335

merged 2 commits into from
Aug 31, 2017

Conversation

openly-retro
Copy link
Contributor

This PR addresses issue #334

The issue was with using unicode values in substitutions. In this PR, I removed forced casting to ascii for values used with Substitutions. It seems that other helpers don't cast values to ascii.

Example code that would cause an error:

personalization.add_substitution(Substitution("%city%", u"Αθήνα"))

I created a simple test to see that the Substitutions helper can now handle a unicode string. All tests pass.

I also tested this in an end-to-end workflow, where we submitted data into our form and received a live email with unicode values where expected.

This is my first public pull request on Github, please let me know if I am missing anything required here.

Mehron Kugler added 2 commits August 21, 2017 14:29
This test checks that the Substitutions helper accepts unicode string values.
Previously, it was not able to handle unicode strings.
@thinkingserious thinkingserious added the status: code review request requesting a community code review or review from Twilio label Aug 21, 2017
@SendGridDX
Copy link

SendGridDX commented Aug 21, 2017

CLA assistant check
All committers have signed the CLA.

@thinkingserious thinkingserious merged commit fae1edb into sendgrid:master Aug 31, 2017
@thinkingserious
Copy link
Contributor

Hello @mehronkugler,

Thanks again for the PR!

We want to show our appreciation by sending you some swag. Could you please fill out this form so we can send it to you? Thanks!

Team SendGrid DX

@wdhorton
Copy link

@mehronkugler @thinkingserious I'm not sure if this was considered, but the removal of the str breaks the case where value is not a string. Maybe that was never explicitly supported, but I'm working on something right now where not having to explicitly cast the substitution values myself would be a nice feature. (I actually stumbled on this PR because I was going to suggest adding str in the Substitution constructor). Is there any way we could preserve casting non-string values without breaking unicode?

@thinkingserious
Copy link
Contributor

Hi @wdhorton,

Do you mind starting a new issue with your request?

Thanks!

With Best Regards,

Elmer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: code review request requesting a community code review or review from Twilio
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants