Skip to content
This repository has been archived by the owner on Jan 11, 2019. It is now read-only.

Encoding issue on Py3.5 #6

Open
Chive opened this issue Jun 12, 2016 · 0 comments
Open

Encoding issue on Py3.5 #6

Chive opened this issue Jun 12, 2016 · 0 comments

Comments

@Chive
Copy link

Chive commented Jun 12, 2016

When using this addon on a Python 3.5 project I get the following error:

Internal Server Error: snipped
Traceback (most recent call last):
  File "/virtualenv/lib/python3.5/site-packages/django/core/handlers/base.py", line 149, in get_response
    response = self.process_exception_by_middleware(e, request)
  File "/virtualenv/lib/python3.5/site-packages/django/core/handlers/base.py", line 147, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/virtualenv/lib/python3.5/site-packages/django/utils/decorators.py", line 149, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/virtualenv/lib/python3.5/site-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/virtualenv/lib/python3.5/site-packages/django/contrib/admin/sites.py", line 244, in inner
    return view(request, *args, **kwargs)
  File "/virtualenv/lib/python3.5/site-packages/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/virtualenv/lib/python3.5/site-packages/django/views/generic/base.py", line 88, in dispatch
    return handler(request, *args, **kwargs)
  File "/virtualenv/lib/python3.5/site-packages/django_object_actions/utils.py", line 240, in get
    ret = view(request, *self.view_args)

  ... snipped business logic ...

  File "/app/mail/mail.py", line 60, in send_email
    return message.send()
  File "/virtualenv/lib/python3.5/site-packages/django/core/mail/message.py", line 292, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "/virtualenv/lib/python3.5/site-packages/django/core/mail/backends/smtp.py", line 100, in send_messages
    new_conn_created = self.open()
  File "/virtualenv/lib/python3.5/site-packages/django/core/mail/backends/smtp.py", line 67, in open
    self.connection.login(self.username, self.password)
  File "/usr/local/lib/python3.5/smtplib.py", line 720, in login
    initial_response_ok=initial_response_ok)
  File "/usr/local/lib/python3.5/smtplib.py", line 637, in auth
    authobject(challenge).encode('ascii'), eol='')
AttributeError: 'bytes' object has no attribute 'encode'

This is most likely caused to a double encoding happening in

It can be easily be reproduced like this:

>>> s = 'test'
>>> e = s.encode('ascii')
>>> e
b'test'
>>> e.encode('ascii')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'bytes' object has no attribute 'encode'

After removing the encode calls in aldryn_config.py it worked fine.

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

No branches or pull requests

1 participant