email.message_from_string.get() fails parses the special text "Subject:=?us-ascii?X?value?=", See the following example.
import email
import email.policy
mytext = "Subject:=?us-ascii?X?value?="
em = email.message_from_string(mytext, policy=email.policy.default)
em.get('Subject')
Traceback (most recent call last):
File "/home/xxm/Desktop/RustPython/test.py", line 569, in <module>
em.get('Subject')
File "/home/xxm/.cargo/git/checkouts/rustpython-f8ef4d934ac33cd8/0284059/pylib/Lib/email/message.py", line 471, in get
return self.policy.header_fetch_parse(k, v)
File "/home/xxm/.cargo/git/checkouts/rustpython-f8ef4d934ac33cd8/0284059/pylib/Lib/email/policy.py", line 162, in header_fetch_parse
return self.header_factory(name, value)
File "/home/xxm/.cargo/git/checkouts/rustpython-f8ef4d934ac33cd8/0284059/pylib/Lib/email/headerregistry.py", line 586, in __call__
return self[name](name, value)
File "/home/xxm/.cargo/git/checkouts/rustpython-f8ef4d934ac33cd8/0284059/pylib/Lib/email/headerregistry.py", line 197, in __new__
cls.parse(value, kwds)
File "/home/xxm/.cargo/git/checkouts/rustpython-f8ef4d934ac33cd8/0284059/pylib/Lib/email/headerregistry.py", line 269, in parse
kwds['parse_tree'] = cls.value_parser(value)
File "/home/xxm/.cargo/git/checkouts/rustpython-f8ef4d934ac33cd8/0284059/pylib/Lib/email/_header_value_parser.py", line 1498, in get_unstructured
pass
File "/home/xxm/.cargo/git/checkouts/rustpython-f8ef4d934ac33cd8/0284059/pylib/Lib/email/_header_value_parser.py", line 1494, in get_unstructured
token, value = get_encoded_word(value)
File "/home/xxm/.cargo/git/checkouts/rustpython-f8ef4d934ac33cd8/0284059/pylib/Lib/email/_header_value_parser.py", line 1447, in get_encoded_word
"encoded word format invalid: '{}'".format(ew.cte))
File "/home/xxm/.cargo/git/checkouts/rustpython-f8ef4d934ac33cd8/0284059/pylib/Lib/email/_header_value_parser.py", line 1444, in get_encoded_word
text, charset, lang, defects = _ew.decode('=?' + tok + '?=')
File "/home/xxm/.cargo/git/checkouts/rustpython-f8ef4d934ac33cd8/0284059/pylib/Lib/email/_encoded_words.py", line 166, in decode
bstring, defects = _cte_decoders[cte](bstring)
KeyError: x
email.message_from_string.get() fails parses the special text "Subject:=?us-ascii?X?value?=", See the following example.
test.py
Behaviors on CPython 3.8.0,3.9.0,3.11.3: work normally
Behaviors on RustPython 0.2.0:
Environment:
Ubuntu 18.04
RustPython 0.2.0 0284059
CPython 3.8.0, 3.9.0, 3.11.3