diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-02-24 12:43:03 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-02-24 12:43:03 (GMT) |
commit | 94ee389308ec9e0e07b3f7a944d5179aba540c5e (patch) | |
tree | 80bc231aff27723119beacbcfa2654b90f793060 /Lib/encodings | |
parent | 20f8728bf0cce877c1908b15ddc59e2d1011ad0f (diff) | |
download | cpython-94ee389308ec9e0e07b3f7a944d5179aba540c5e.zip cpython-94ee389308ec9e0e07b3f7a944d5179aba540c5e.tar.gz cpython-94ee389308ec9e0e07b3f7a944d5179aba540c5e.tar.bz2 |
Issue #19619: Blacklist non-text codecs in method API
str.encode, bytes.decode and bytearray.decode now use an
internal API to throw LookupError for known non-text encodings,
rather than attempting the encoding or decoding operation and
then throwing a TypeError for an unexpected output type.
The latter mechanism remains in place for third party non-text
encodings.
Backported changeset d68df99d7a57.
Diffstat (limited to 'Lib/encodings')
-rw-r--r-- | Lib/encodings/base64_codec.py | 1 | ||||
-rw-r--r-- | Lib/encodings/bz2_codec.py | 1 | ||||
-rw-r--r-- | Lib/encodings/hex_codec.py | 1 | ||||
-rw-r--r-- | Lib/encodings/quopri_codec.py | 1 | ||||
-rwxr-xr-x | Lib/encodings/rot_13.py | 1 | ||||
-rw-r--r-- | Lib/encodings/uu_codec.py | 1 | ||||
-rw-r--r-- | Lib/encodings/zlib_codec.py | 1 |
7 files changed, 7 insertions, 0 deletions
diff --git a/Lib/encodings/base64_codec.py b/Lib/encodings/base64_codec.py index 321a961..881d1ba 100644 --- a/Lib/encodings/base64_codec.py +++ b/Lib/encodings/base64_codec.py @@ -52,4 +52,5 @@ def getregentry(): incrementaldecoder=IncrementalDecoder, streamwriter=StreamWriter, streamreader=StreamReader, + _is_text_encoding=False, ) diff --git a/Lib/encodings/bz2_codec.py b/Lib/encodings/bz2_codec.py index e65d226..fd9495e 100644 --- a/Lib/encodings/bz2_codec.py +++ b/Lib/encodings/bz2_codec.py @@ -74,4 +74,5 @@ def getregentry(): incrementaldecoder=IncrementalDecoder, streamwriter=StreamWriter, streamreader=StreamReader, + _is_text_encoding=False, ) diff --git a/Lib/encodings/hex_codec.py b/Lib/encodings/hex_codec.py index e003fc3..f2ed0a7 100644 --- a/Lib/encodings/hex_codec.py +++ b/Lib/encodings/hex_codec.py @@ -52,4 +52,5 @@ def getregentry(): incrementaldecoder=IncrementalDecoder, streamwriter=StreamWriter, streamreader=StreamReader, + _is_text_encoding=False, ) diff --git a/Lib/encodings/quopri_codec.py b/Lib/encodings/quopri_codec.py index 9243fc4..70f7083 100644 --- a/Lib/encodings/quopri_codec.py +++ b/Lib/encodings/quopri_codec.py @@ -53,4 +53,5 @@ def getregentry(): incrementaldecoder=IncrementalDecoder, streamwriter=StreamWriter, streamreader=StreamReader, + _is_text_encoding=False, ) diff --git a/Lib/encodings/rot_13.py b/Lib/encodings/rot_13.py index 3140c14..fff9153 100755 --- a/Lib/encodings/rot_13.py +++ b/Lib/encodings/rot_13.py @@ -43,6 +43,7 @@ def getregentry(): incrementaldecoder=IncrementalDecoder, streamwriter=StreamWriter, streamreader=StreamReader, + _is_text_encoding=False, ) ### Map diff --git a/Lib/encodings/uu_codec.py b/Lib/encodings/uu_codec.py index 69c6f17..e3269e4 100644 --- a/Lib/encodings/uu_codec.py +++ b/Lib/encodings/uu_codec.py @@ -96,4 +96,5 @@ def getregentry(): incrementaldecoder=IncrementalDecoder, streamreader=StreamReader, streamwriter=StreamWriter, + _is_text_encoding=False, ) diff --git a/Lib/encodings/zlib_codec.py b/Lib/encodings/zlib_codec.py index e0b9cda..4c81ca1 100644 --- a/Lib/encodings/zlib_codec.py +++ b/Lib/encodings/zlib_codec.py @@ -74,4 +74,5 @@ def getregentry(): incrementaldecoder=IncrementalDecoder, streamreader=StreamReader, streamwriter=StreamWriter, + _is_text_encoding=False, ) |