Skip to content

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

Open

Description

@wodow

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

with message containing ... 'recipients': [ u'REDACTED Hernández <REDACTED@hotmail.com>' ], ...

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.

Activity

  1. wodow commented on Aug 10, 2017

    @wodow
    ContributorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions