[GH-ISSUE #242] manage smtpd has uncaught python exception: 'str' object has no attribute 'decode' #175

Closed
opened 2026-02-25 23:41:28 +03:00 by kerem · 2 comments
Owner

Originally created by @nogweii on GitHub (Apr 16, 2019).
Original GitHub issue: https://github.com/healthchecks/healthchecks/issues/242

Sample log message:

Apr 15 17:47:40 healthchecks venv-exec[21021]: error: uncaptured python exception, closing channel <smtpd.SMTPChannel connected ('::ffff:209.222.82.145', 43696, 0, 0) at 0x7fecadee2eb8> (<class 'AttributeError'>:'str' object has no attribute 'decode' [/usr/lib/python3.5/asyncore.py|read|83] [/usr/lib/python3.5/asyncore.py|handle_read_event|423] [/usr/lib/python3.5/asynchat.py|handle_read|171] [/usr/lib/python3.5/smtpd.py|found_terminator|390] [/opt/healthchecks/healthchecks/hc/api/management/commands/smtpd.py|process_message|26])

Seems like it happens every time an email arrives. Fails on attempting to decode a string which is already a unicode string 'cause Python 3 defaults to that:

github.com/healthchecks/healthchecks@143c90674b/hc/api/management/commands/smtpd.py (L18-L29)

Running healthchecks 1.6.0 on an Ubuntu 16.04 system, running python 3.5.3.

Originally created by @nogweii on GitHub (Apr 16, 2019). Original GitHub issue: https://github.com/healthchecks/healthchecks/issues/242 Sample log message: > `Apr 15 17:47:40 healthchecks venv-exec[21021]: error: uncaptured python exception, closing channel <smtpd.SMTPChannel connected ('::ffff:209.222.82.145', 43696, 0, 0) at 0x7fecadee2eb8> (<class 'AttributeError'>:'str' object has no attribute 'decode' [/usr/lib/python3.5/asyncore.py|read|83] [/usr/lib/python3.5/asyncore.py|handle_read_event|423] [/usr/lib/python3.5/asynchat.py|handle_read|171] [/usr/lib/python3.5/smtpd.py|found_terminator|390] [/opt/healthchecks/healthchecks/hc/api/management/commands/smtpd.py|process_message|26])` Seems like it happens every time an email arrives. Fails on attempting to decode a string which is already a unicode string 'cause Python 3 defaults to that: https://github.com/healthchecks/healthchecks/blob/143c90674bb0e7b2253cd425db75512008c7fe9c/hc/api/management/commands/smtpd.py#L18-L29 Running healthchecks 1.6.0 on an Ubuntu 16.04 system, running python 3.5.3.
kerem closed this issue 2026-02-25 23:41:28 +03:00
Author
Owner

@nogweii commented on GitHub (Apr 16, 2019):

Commenting out lines 25 through 28 seem to make it work with no heartache, though we haven't set up any subject line tests yet.

<!-- gh-comment-id:483472201 --> @nogweii commented on GitHub (Apr 16, 2019): Commenting out lines 25 through 28 seem to make it work with no heartache, though we haven't set up any subject line tests yet.
Author
Owner

@cuu508 commented on GitHub (Apr 16, 2019):

Looks like the default value of the decode_data argument in SMTPServer constructor changed between Python 3.5 and Python 3.6.

There was even a warning about that, which I had missed: https://github.com/python/cpython/blob/3.5/Lib/smtpd.py#L650

Just pushed a change that sets an explicit decode_data=False value. I'll be honest, I only tested it with Python 3.6.7 which I have installed locally. Would you be able to test it with 3.5 and confirm it works?

<!-- gh-comment-id:483546918 --> @cuu508 commented on GitHub (Apr 16, 2019): Looks like the default value of the `decode_data` argument in SMTPServer constructor changed between Python 3.5 and Python 3.6. There was even a warning about that, which I had missed: https://github.com/python/cpython/blob/3.5/Lib/smtpd.py#L650 Just pushed a change that sets an explicit decode_data=False value. I'll be honest, I only tested it with Python 3.6.7 which I have installed locally. Would you be able to test it with 3.5 and confirm it works?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/healthchecks#175
No description provided.