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

TypeError "name must be of type string" regression when name is Unicode string #790

Closed
johnpkennedy opened this issue Apr 25, 2019 · 2 comments · Fixed by #792
Closed

TypeError "name must be of type string" regression when name is Unicode string #790

johnpkennedy opened this issue Apr 25, 2019 · 2 comments · Fixed by #792
Labels
difficulty: medium fix is medium in difficulty status: work in progress Twilio or the community is in the process of implementing type: bug bug in the library

Comments

@johnpkennedy
Copy link

johnpkennedy commented Apr 25, 2019

Issue Summary

We encountered the following regression error after upgrading from sendgrid v5.6 to v6.0.3.

TypeError: name must be of type string.
...
  File "sendgrid/helpers/mail/email.py", line 52, in __init__
    self.parse_email(email)
  File "sendgrid/helpers/mail/email.py", line 207, in parse_email
    self.name = name
  File "sendgrid/helpers/mail/email.py", line 86, in name
    raise TypeError('name must be of type string.')

Steps to Reproduce

The following code should reproduce the problem:

        from_address = u"John Doe <[email protected]>"
        mail = Mail()
        mail.from_email = Email(from_address)

This code works in v5.6.

Technical details:

  • sendgrid-python Version: 6.0.3
  • Python Version: 2.7

In v5.6, the name setter method in the Email class (helpers/mail/email.py) was simply this:

    @name.setter
    def name(self, value):
        self._name = value

In v6, the name setter method was changed to the following:

    @name.setter
    def name(self, value):
        if not (value is None or isinstance(value, str)):
            raise TypeError('name must be of type string.')

Note that isinstance() is using str not basestring.

@patelnav
Copy link

@thinkingserious this is quite a serious regression. Can't pass unicode values for Email name.

johnpkennedy pushed a commit to johnpkennedy/sendgrid-python that referenced this issue Apr 28, 2019
Allow Unicode strings for the name associated with the email.
@johnpkennedy johnpkennedy mentioned this issue Apr 28, 2019
7 tasks
@thinkingserious thinkingserious added difficulty: medium fix is medium in difficulty status: work in progress Twilio or the community is in the process of implementing type: bug bug in the library labels Apr 30, 2019
@thinkingserious
Copy link
Contributor

Thanks for being awesome and creating the PR for this @johnpkennedy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: medium fix is medium in difficulty status: work in progress Twilio or the community is in the process of implementing type: bug bug in the library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants