You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TypeError: '<' not supported between instances of 'NoneType' and 'int' raised during call to email.message_from_file #134151
During fuzzing of Python standard libraries, the following code snippet causes a TypeError with the following message: TypeError: '<' not supported between instances of 'NoneType' and 'int'. This occurs in the decode_params function at line 419 in email/utils.py.
Traceback (most recent call last):
File "rep.py", line 5, in <module>
email.message_from_file(d)
File "/usr/lib/python3.12/email/__init__.py", line 53, in message_from_file
return Parser(*args, **kws).parse(fp)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/email/parser.py", line 54, in parse
return feedparser.close()
^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/email/feedparser.py", line 185, in close
self._call_parse()
File "/usr/lib/python3.12/email/feedparser.py", line 178, in _call_parse
self._parse()
File "/usr/lib/python3.12/email/feedparser.py", line 304, in _parsegen
boundary = self._cur.get_boundary()
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/email/message.py", line 861, in get_boundary
boundary = self.get_param('boundary', missing)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/email/message.py", line 725, in get_param
for k, v in self._get_params_preserve(failobj, header):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/email/message.py", line 674, in _get_params_preserve
params = utils.decode_params(params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/email/utils.py", line 419, in decode_params
continuations.sort()
TypeError: '<' not supported between instances of 'NoneType' and 'int'
This issue is in the old code, not the new API. If someone feels like fixing it I'll review, but I'm not going to fix this one myself. I'll look at the other issues presently, which are in the new API.
I am surprised to discover that this is a legend code craft from 17 years ago. I am uncertain of the extent to which it could be beneficial to fix it, as we have already received a new API. However, I would appreciate it if you could take a look at it, @bitdancer.
Please let me know if you believe it is appropriate to merge this into the main branch :), thanks!
Activity
picnixz commentedon May 18, 2025
@bitdancer If possilbe, could you also have a look at:
UnboundLocalErrorinemail._header_value_parser.parse_message_id#134152AttributeErrorinemail._header_value_parser.get_address#134155TiA.
bitdancer commentedon May 18, 2025
This issue is in the old code, not the new API. If someone feels like fixing it I'll review, but I'm not going to fix this one myself. I'll look at the other issues presently, which are in the new API.
zangjiucheng commentedon May 26, 2025
Hello everyone,
I am surprised to discover that this is a legend code craft from 17 years ago. I am uncertain of the extent to which it could be beneficial to fix it, as we have already received a new API. However, I would appreciate it if you could take a look at it, @bitdancer.
Please let me know if you believe it is appropriate to merge this into the main branch :), thanks!
gh-134151 Fix `TypeError` in `email.utils.decode_params` when sorting…
pythongh-134151 Fix `TypeError` in `email.utils.decode_params` when s…
pythongh-134151 Fix `TypeError` in `email.utils.decode_params` when s…
[3.13] gh-134151 Fix `TypeError` in `email.utils.decode_params` when …
[3.14] gh-134151 Fix `TypeError` in `email.utils.decode_params` when …
bitdancer commentedon Jun 8, 2025
Thanks @zangjiucheng for the fix, and @picnixz for the additional review and merge.
pythongh-134151 Fix `TypeError` in `email.utils.decode_params` when s…
pythongh-134151 Fix `TypeError` in `email.utils.decode_params` when s…
pythongh-134151 Fix `TypeError` in `email.utils.decode_params` when s…
pythongh-134151 Fix `TypeError` in `email.utils.decode_params` when s…
Take a response http.client cannot parse for one that cannot be read