Skip to content

Commit

Permalink
Python 2 / 3 compatible imports.
Browse files Browse the repository at this point in the history
  • Loading branch information
rudaporto committed Oct 22, 2017
1 parent 6788be5 commit 6224970
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Expand Up @@ -22,6 +22,8 @@ Bug fixes:
- Change api.group.get_groups to work with CMF master.
[jaroel]

- Added six to deal with Python 2 / 3 compatibility.
[rudaporto]

1.8.1 (2017-10-17)
------------------
Expand Down
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -38,6 +38,7 @@ def read(*rnames):
'plone.app.linkintegrity',
'plone.uuid',
'setuptools',
'six',
'zope.globalrequest',
],
extras_require={
Expand Down
5 changes: 3 additions & 2 deletions src/plone/api/portal.py
Expand Up @@ -21,6 +21,7 @@
from zope.interface.interfaces import IInterface

import pkg_resources
import six


logger = getLogger('plone.api.portal')
Expand Down Expand Up @@ -191,7 +192,7 @@ def send_email(

# If the mail headers are not properly encoded we need to extract
# them and let MailHost manage the encoding.
if isinstance(body, unicode):
if isinstance(body, six.text_type):
body = body.encode(encoding)

host = get_tool('MailHost')
Expand Down Expand Up @@ -441,7 +442,7 @@ def translate(msgid, domain='plone', lang=None):
:param lang: target language
:type lang: string
:returns: translated message
:rtype: unicode
:rtype: six.text_type
:Example: :ref:`portal_translate_example`
"""
translation_service = get_tool('translation_service')
Expand Down

0 comments on commit 6224970

Please sign in to comment.