summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2013-11-22 12:39:36 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2013-11-22 12:39:36 (GMT)
commitc72e4e6dccce99bcdcb45959767436d7e5cfda8c (patch)
tree029832d80cc82a039dc1014302c9eb9dd2214543 /Objects
parent322f5ba0d8d5e8a9cd2a134fa215884b4cbc373d (diff)
downloadcpython-c72e4e6dccce99bcdcb45959767436d7e5cfda8c.zip
cpython-c72e4e6dccce99bcdcb45959767436d7e5cfda8c.tar.gz
cpython-c72e4e6dccce99bcdcb45959767436d7e5cfda8c.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.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 3644db3..7de5f1f 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -3044,7 +3044,7 @@ PyUnicode_Decode(const char *s,
buffer = PyMemoryView_FromBuffer(&info);
if (buffer == NULL)
goto onError;
- unicode = PyCodec_Decode(buffer, encoding, errors);
+ unicode = _PyCodec_DecodeText(buffer, encoding, errors);
if (unicode == NULL)
goto onError;
if (!PyUnicode_Check(unicode)) {
@@ -3410,7 +3410,7 @@ PyUnicode_AsEncodedString(PyObject *unicode,
}
/* Encode via the codec registry */
- v = PyCodec_Encode(unicode, encoding, errors);
+ v = _PyCodec_EncodeText(unicode, encoding, errors);
if (v == NULL)
return NULL;