Skip to content

SendGrid 1.4.3 broken in Python 3, introduce via iteritems #126

@urda

Description

@urda

Problem

sendgrid 1.4.3 is broken when used in a python3 context. A call is being made to iteritems during the set_headers call.

This iteritems call was introduced in commit afe99dc

Workaround

Python 3 users should not upgrade to 1.4.3 and remain at 1.4.2

Testing Environment

Bash Commands

# Environment setup
$ mkvirtualenv --python=/usr/bin/python3 sendgrid-issue

$ python --version
Python 3.4.3

# Upgrade pip, install sendgrid
$ pip install -U pip
$ pip install sendgrid
Collecting sendgrid
  Using cached sendgrid-1.4.3.tar.gz
Collecting smtpapi==0.2.0 (from sendgrid)
  Downloading smtpapi-0.2.0.tar.gz
Installing collected packages: smtpapi, sendgrid
  Running setup.py install for smtpapi
  Running setup.py install for sendgrid
Successfully installed sendgrid-1.4.3 smtpapi-0.2.0

# Confirm pip status
$ pip freeze
sendgrid==1.4.3
smtpapi==0.2.0

# Begin in next code section
$ python

Python sample

>>> import sendgrid
>>> message = sendgrid.Mail()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/purda/.virtualenvs/sendgrid-issue/lib/python3.4/site-packages/sendgrid/message.py", line 50, in __init__
    self.set_headers(opts.get('headers', {}))
  File "/home/purda/.virtualenvs/sendgrid-issue/lib/python3.4/site-packages/sendgrid/message.py", line 168, in set_headers
    for key, value in headers.iteritems():
AttributeError: 'dict' object has no attribute 'iteritems'

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