[issue2551092] TypeError: can only concatenate str (not "bytes") to str

Cédric Krier <[email protected]>
Newsgroups gmane.comp.bug-tracking.roundup.devel
Message-ID <[email protected]>
New submission from Cédric Krier:

I got this traceback on email with subject encoding Q:

Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/roundup/mailgw.py", line 1511, in handle_Message
    return self.handle_message(message)
  File "/usr/lib/python3.7/site-packages/roundup/mailgw.py", line 1583, in handle_message
    return self._handle_message(message)
  File "/usr/lib/python3.7/site-packages/roundup/mailgw.py", line 1594, in _handle_message
    self.parsed_message = self.parsed_message_class(self, message)
  File "/usr/lib/python3.7/site-packages/roundup/mailgw.py", line 509, in __init__
    self.subject = message.get_header('subject', '')
  File "/usr/lib/python3.7/site-packages/roundup/mailgw.py", line 252, in get_header
    return self._decode_header(value.replace('\n', ''))
  File "/usr/lib/python3.7/site-packages/roundup/mailgw.py", line 219, in _decode_header
    for part, encoding in decode_header(hdr):
  File "/usr/lib/python3.7/site-packages/roundup/anypy/email_.py", line 124, in decode_header
    last_word += word
TypeError: can only concatenate str (not "bytes") to str


I found that the roundup.anypy.email_.decode_header which is a copy of the stdlib email.header.decode_header is missing a line which convert word into bytes if it is a str (on Python3).
Here is attached a patch which applies the change only for Python3.
Also I think the fix of issue2551008 may be removed as now decode_header will always returns bytes.
It will even better to remove roundup.anypy.email_ completly once Python2 is no more supported (issue2550879).

----------
components: Mail interface
files: anypy_email.patch
keywords: patch
messages: 6967
nosy: ced
severity: major
status: new
title: TypeError: can only concatenate str (not "bytes") to str
type: crash
versions: 2.0.0

_________________________________________________
Roundup tracker <[email protected]>
<https://issues.roundup-tracker.org/issue2551092>
_________________________________________________


_______________________________________________
Roundup-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/roundup-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.