#27771: Problem with unicode literals and EMAIL_PORT
-----------------------------------------+------------------------
Reporter: Michal Čihař | Owner: nobody
Type: Uncategorized | Status: new
Component: Core (Other) | Version: 1.10
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
When your settings.py looks like:
{{{
from __future__ import unicode_literals
EMAIL_HOST= 'localhost'
EMAIL_PORT = '587'
}}}
You end up with error when sending mail:
{{{
File "/opt/weblate/.local/lib/python2.7/site-
packages/django/core/mail/backends/smtp.py" in open
58. self.connection = connection_class(self.host, self.port,
**connection_params)
File "/usr/lib/python2.7/smtplib.py" in __init__
256. (code, msg) = self.connect(host, port)
File "/usr/lib/python2.7/smtplib.py" in connect
316. self.sock = self._get_socket(host, port, self.timeout)
File "/usr/lib/python2.7/smtplib.py" in _get_socket
291. return socket.create_connection((host, port), timeout)
File "/usr/lib/python2.7/socket.py" in create_connection
553. for res in getaddrinfo(host, port, 0, SOCK_STREAM):
Exception Type: error at /accounts/register/
Exception Value: getaddrinfo() argument 2 must be integer or string
}}}
This is caused by fact that that getaddrinfo happily accepts int or
string, but not unicode literals as port (it doesn't have problem with
unicode literals as hostname though):
{{{
>>> from __future__ import unicode_literals
>>> import socket
>>> socket.getaddrinfo('localhost', '567', 0, socket.SOCK_STREAM)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
socket.error: getaddrinfo() argument 2 must be integer or string
}}}
I think Django should prevent this configuration error, or at least
properly tell where the problem is.
Originally reported at https://github.com/WeblateOrg/weblate/issues/1330
--
Ticket URL: <https://code.djangoproject.com/ticket/27771>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/048.53c867e7969363fd16055801ef358b6c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.