slimta / python-slimta

Python libraries to send, receive, and queue email.
https://slimta.org/
MIT License
171 stars 43 forks source link

some exception when recv unicode strings in smtp responses #88

Closed thestick613 closed 8 years ago

thestick613 commented 8 years ago

UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 134: ordinal not in range(128) Traceback (most recent call last): File "/root/venv_smtpout/local/lib/python2.7/site-packages/gevent/greenlet.py", line 522, in run result = self._run(_self.args, _self.kwargs) File "/root/venv_smtpout/local/lib/python2.7/site-packages/slimta/relay/smtp/client.py", line 260, in _run self._handshake() File "/root/venv_smtpout/local/lib/python2.7/site-packages/slimta/relay/smtp/client.py", line 135, in _handshake self._banner() File "/root/venv_smtpout/local/lib/python2.7/site-packages/slimta/relay/smtp/client.py", line 49, in new_f ret = old_f(self, _args, _kwargs) File "/root/venv_smtpout/local/lib/python2.7/site-packages/slimta/relay/smtp/client.py", line 101, in _banner raise SmtpRelayError.factory(banner) File "/root/venv_smtpout/local/lib/python2.7/site-packages/slimta/relay/smtp/init.py", line 47, in factory return SmtpPermanentRelayError(reply) File "/root/venv_smtpout/local/lib/python2.7/site-packages/slimta/relay/smtp/init.py", line 61, in init super(SmtpPermanentRelayError, self).init('Permanent', reply) File "/root/venv_smtpout/local/lib/python2.7/site-packages/slimta/relay/smtp/init.py", line 41, in init msg = '{0} failure on {1}: {2}'.format(type, command, str(reply)) File "/root/venv_smtpout/local/lib/python2.7/site-packages/slimta/smtp/reply.py", line 104, in str return '{0} {1}'.format(self.code, self.message) UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 134: ordinal not in range(128)

icgood commented 8 years ago

Just FYI the unicode behavior will be far better if you upgrade to Python 3. This is a fixable case, though, and should be fixed by my PR.