summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-05-31 17:21:00 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-05-31 17:21:00 (GMT)
commitc7797dc7482035ee166ca2e941b623382b92e1fc (patch)
tree526e26fa4dac506f02859fdbe946d33ed4165f5e /Objects
parentcfb7028df4bdf12325786e48ebef3b4982efa119 (diff)
downloadcpython-c7797dc7482035ee166ca2e941b623382b92e1fc.zip
cpython-c7797dc7482035ee166ca2e941b623382b92e1fc.tar.gz
cpython-c7797dc7482035ee166ca2e941b623382b92e1fc.tar.bz2
Issue #19543: Emit deprecation warning for known non-text encodings.
Backported issues #19619: encode() and decode() methods and constructors of str, unicode and bytearray classes now emit deprecation warning for known non-text encodings when Python is ran with the -3 option. Backported issues #20404: io.TextIOWrapper (and hence io.open()) now uses the internal codec marking system added to emit deprecation warning for known non-text encodings at stream construction time when Python is ran with the -3 option.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/bytearrayobject.c6
-rw-r--r--Objects/stringobject.c4
-rw-r--r--Objects/unicodeobject.c8
3 files changed, 9 insertions, 9 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index fd201ca..5f57580 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -783,7 +783,7 @@ bytearray_init(PyByteArrayObject *self, PyObject *args, PyObject *kwds)
if (PyBytes_Check(arg)) {
PyObject *new, *encoded;
if (encoding != NULL) {
- encoded = PyCodec_Encode(arg, encoding, errors);
+ encoded = _PyCodec_EncodeText(arg, encoding, errors);
if (encoded == NULL)
return -1;
assert(PyBytes_Check(encoded));
@@ -809,7 +809,7 @@ bytearray_init(PyByteArrayObject *self, PyObject *args, PyObject *kwds)
"unicode argument without an encoding");
return -1;
}
- encoded = PyCodec_Encode(arg, encoding, errors);
+ encoded = _PyCodec_EncodeText(arg, encoding, errors);
if (encoded == NULL)
return -1;
assert(PyBytes_Check(encoded));
@@ -2567,7 +2567,7 @@ bytearray_decode(PyObject *self, PyObject *args, PyObject *kwargs)
return NULL;
#endif
}
- return PyCodec_Decode(self, encoding, errors);
+ return _PyCodec_DecodeText(self, encoding, errors);
}
PyDoc_STRVAR(alloc_doc,
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index 46f46db..c1e12a7 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -449,7 +449,7 @@ PyObject *PyString_AsDecodedObject(PyObject *str,
}
/* Decode via the codec registry */
- v = PyCodec_Decode(str, encoding, errors);
+ v = _PyCodec_DecodeText(str, encoding, errors);
if (v == NULL)
goto onError;
@@ -529,7 +529,7 @@ PyObject *PyString_AsEncodedObject(PyObject *str,
}
/* Encode via the codec registry */
- v = PyCodec_Encode(str, encoding, errors);
+ v = _PyCodec_EncodeText(str, encoding, errors);
if (v == NULL)
goto onError;
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 91e7524..08723ac 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -1259,7 +1259,7 @@ PyObject *PyUnicode_Decode(const char *s,
buffer = PyBuffer_FromMemory((void *)s, size);
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)) {
@@ -1292,7 +1292,7 @@ PyObject *PyUnicode_AsDecodedObject(PyObject *unicode,
encoding = PyUnicode_GetDefaultEncoding();
/* Decode via the codec registry */
- v = PyCodec_Decode(unicode, encoding, errors);
+ v = _PyCodec_DecodeText(unicode, encoding, errors);
if (v == NULL)
goto onError;
return v;
@@ -1331,7 +1331,7 @@ PyObject *PyUnicode_AsEncodedObject(PyObject *unicode,
encoding = PyUnicode_GetDefaultEncoding();
/* Encode via the codec registry */
- v = PyCodec_Encode(unicode, encoding, errors);
+ v = _PyCodec_EncodeText(unicode, encoding, errors);
if (v == NULL)
goto onError;
return v;
@@ -1369,7 +1369,7 @@ PyObject *PyUnicode_AsEncodedString(PyObject *unicode,
}
/* Encode via the codec registry */
- v = PyCodec_Encode(unicode, encoding, errors);
+ v = _PyCodec_EncodeText(unicode, encoding, errors);
if (v == NULL)
goto onError;
if (!PyString_Check(v)) {