Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
Closed
Description
Bug report
email._header_value_parser tries to raiseerrors.InvalidHeaderError, but that does not exist (and as far as I can tell, never did):
>>>fromemail.headerregistryimportHeaderRegistry>>>reg=HeaderRegistry()>>>reg('Content-Disposition','attachment; 0*00="foo"')Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>File"/usr/lib/python3.10/email/headerregistry.py",line604,in__call__returnself[name](name,value)File"/usr/lib/python3.10/email/headerregistry.py",line192,in__new__cls.parse(value,kwds)File"/usr/lib/python3.10/email/headerregistry.py",line448,inparsekwds['parse_tree']=parse_tree=cls.value_parser(value)File"/usr/lib/python3.10/email/_header_value_parser.py",line2705,inparse_content_disposition_headerdisp_header.append(parse_mime_parameters(value[1:]))File"/usr/lib/python3.10/email/_header_value_parser.py",line2569,inparse_mime_parameterstoken,value=get_parameter(value)File"/usr/lib/python3.10/email/_header_value_parser.py",line2431,inget_parametertoken,value=get_section(value)File"/usr/lib/python3.10/email/_header_value_parser.py",line2382,inget_sectionsection.defects.append(errors.InvalidHeaderError(AttributeError:module'email.errors'hasnoattribute'InvalidHeaderError'.Didyoumean:'InvalidHeaderDefect'?
Code:
cpython/Lib/email/_header_value_parser.py
Lines 2381 to 2383 ind853758
| ifdigits[0]=='0'anddigits!='0': | |
| section.defects.append(errors.InvalidHeaderError( | |
| "section number has an invalid leading 0")) |
This was added in97f43c0 by@bitdancer pretty much some 10 years ago, and I don't think it ever worked (but nor could I find anyone running into this so far): The git history doesn't know anything about anemail.errors.InvalidHeaderError.
Found viaHypothesis while testing my own parsing code - cc@Zac-HD if you want to see another instance of "the curse of hypothesis" 😉
Your environment
- CPython versions tested on: 3.7.13, 3.8.13, 3.9.13, 3.10.4, 3.11.0b1
- Operating system and architecture: Archlinux, x86_64