mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-136702: Deprecate passing non-ascii *encoding* (str) to encodings.normalize_encoding (#140030)
Closes #136702
This commit is contained in:
parent
7ae440f262
commit
5ba0a1aa1f
8 changed files with 42 additions and 6 deletions
|
|
@ -460,6 +460,10 @@ def collapse_rfc2231_value(value, errors='replace',
|
|||
charset = fallback_charset
|
||||
rawbytes = bytes(text, 'raw-unicode-escape')
|
||||
try:
|
||||
# Explicitly look up the codec for warning generation, see gh-140030
|
||||
# Can be removed in 3.17
|
||||
import codecs
|
||||
codecs.lookup(charset)
|
||||
return str(rawbytes, charset, errors)
|
||||
except LookupError:
|
||||
# charset is not a known codec.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue