[issue22833] The decode_header() function decodes raw part to bytes or str, depending on encoded part

2022-01-20 Thread Jelle Zijlstra
Jelle Zijlstra added the comment: This behavior is definitely unfortunate, but by now it's also been baked into more than a decade of Python 3 releases, so backward compatibility constraints make it difficult to fix. How can we be sure this change won't break users' code? For reference,

[issue22833] The decode_header() function decodes raw part to bytes or str, depending on encoded part

2022-01-11 Thread Daniel Lenski
Change by Daniel Lenski : -- keywords: +patch pull_requests: +28748 stage: -> patch review pull_request: https://github.com/python/cpython/pull/30548 ___ Python tracker ___

[issue22833] The decode_header() function decodes raw part to bytes or str, depending on encoded part

2021-12-30 Thread Daniel Lenski
Daniel Lenski added the comment: Due to this bug, any user of this function in Python 3.0+ *already* has to be able to handle all of the following outputs in order to use it reliably: decode_header(...) -> [(str, None)] or decode_header(...) -> [(bytes, str)] or decode_header(...) ->

[issue22833] The decode_header() function decodes raw part to bytes or str, depending on encoded part

2021-12-30 Thread Daniel Lenski
Daniel Lenski added the comment: I recently ran into this bug as well. For those looking for a reliable workaround, here's an implementation of a 'decode_header_to_string' function which should Just Work™ in all possible cases: #!/usr/bin/python3 import email.header #

[issue22833] The decode_header() function decodes raw part to bytes or str, depending on encoded part

2021-12-12 Thread Irit Katriel
Irit Katriel added the comment: Reproduced on 3.11. -- nosy: +iritkatriel versions: +Python 3.10, Python 3.11, Python 3.9 -Python 3.4, Python 3.5 ___ Python tracker ___

[issue22833] The decode_header() function decodes raw part to bytes or str, depending on encoded part

2014-11-10 Thread R. David Murray
R. David Murray added the comment: This is a duplicate of issue 6302. Re-reading that issue (again), I'm not quite sure why we didn't fix it, but it may be too late to fix it now for backward compatibility reasons. Since that issue strayed off into other topics, I'm going to leave this one

[issue22833] The decode_header() function decodes raw part to bytes or str, depending on encoded part

2014-11-10 Thread py.user
py.user added the comment: R. David Murray wrote: Is there a reason you are choosing not to use the new API? My program is for Python 3.x. I need to decode wild headers to pretty unicode strings. Now, I do it by decode_header() and try...except for AttributeError, since a unicode string has

[issue22833] The decode_header() function decodes raw part to bytes or str, depending on encoded part

2014-11-10 Thread R. David Murray
R. David Murray added the comment: Certainly not with 3.0, but nobody in their right mind should be using that version any more :). The new API for decoding headers is available as of Python 3.3, with additional new API features in 3.4. See

[issue22833] The decode_header() function decodes raw part to bytes or str, depending on encoded part

2014-11-09 Thread py.user
New submission from py.user: It depends on encoded part in the header, what email.header.decode_header() returns. If the header has both raw part and encoded part, the function returns (bytes, None) for the raw part. But if the header has only raw part, the function returns (str, None) for

[issue22833] The decode_header() function decodes raw part to bytes or str, depending on encoded part

2014-11-09 Thread py.user
Changes by py.user bugzilla-mail-...@yandex.ru: -- type: - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22833 ___ ___ Python-bugs-list