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

Unicode display name causes UnicodeEncodeError in sparkpost.transmissions.send() in Python 2.7 #155

Open
wodow opened this issue Aug 10, 2017 · 1 comment

Comments

@wodow
Copy link
Contributor

wodow commented Aug 10, 2017

Using v1.3.5, calling sparkpost_client.transmissions.send(**message)

with message containing ... 'recipients': [ u'REDACTED Hernández <[email protected]>' ], ...

results in this stacktrace:

UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 9: ordinal not in range(128)
... 
File "sparkpost/transmissions.py", line 253, in send
    payload = self._translate_keys(**kwargs)
  File "sparkpost/transmissions.py", line 76, in _translate_keys
    bcc_copies = self._format_copies(recipients, bcc)
  File "sparkpost/transmissions.py", line 100, in _format_copies
    'header_to': self._format_header_to(recipients[0])
  File "sparkpost/transmissions.py", line 109, in _format_header_to
    email=recipient['address']['email']

Should it accept a unicode string as a param? It did in an earlier version - tested on v1.2.0 so far.

@wodow
Copy link
Contributor Author

wodow commented Aug 10, 2017

The exception is raised at https://github.com/SparkPost/python-sparkpost/blame/master/sparkpost/transmissions.py#L105

The inline string there will be a str in Python 2, so can't interpolate a unicode string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant