gh-136702: Deprecate passing non-ascii *encoding* (str) to encodings.normalize_encoding (#140030)

Closes #136702
This commit is contained in:
Stan Ulbrych 2025-11-09 12:37:34 +00:00 committed by GitHub
parent 7ae440f262
commit 5ba0a1aa1f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 42 additions and 6 deletions

View file

@ -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.