summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-08-06 20:29:29 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-08-06 20:29:29 (GMT)
commitfebc3320563bf597e186ebce75abdac2926ceeb6 (patch)
tree1360725b7e65af72348ed78687257249ccf1d36e /Objects
parentd73c31899e88aa5a1cc28f288cc70a35f2a196c2 (diff)
downloadcpython-febc3320563bf597e186ebce75abdac2926ceeb6.zip
cpython-febc3320563bf597e186ebce75abdac2926ceeb6.tar.gz
cpython-febc3320563bf597e186ebce75abdac2926ceeb6.tar.bz2
Issue #26754: Undocumented support of general bytes-like objects
as path in compile() and similar functions is now deprecated.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 0932f35..2d31c70 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -3837,7 +3837,13 @@ PyUnicode_FSDecoder(PyObject* arg, void* addr)
output = arg;
Py_INCREF(output);
}
- else if (PyObject_CheckBuffer(arg)) {
+ else if (PyBytes_Check(arg) || PyObject_CheckBuffer(arg)) {
+ if (!PyBytes_Check(arg) &&
+ PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
+ "path should be string or bytes, not %.200s",
+ Py_TYPE(arg)->tp_name)) {
+ return 0;
+ }
arg = PyBytes_FromObject(arg);
if (!arg)
return 0;
@@ -3846,11 +3852,6 @@ PyUnicode_FSDecoder(PyObject* arg, void* addr)
Py_DECREF(arg);
if (!output)
return 0;
- if (!PyUnicode_Check(output)) {
- Py_DECREF(output);
- PyErr_SetString(PyExc_TypeError, "decoder failed to return unicode");
- return 0;
- }
}
else {
PyErr_Format(PyExc_TypeError,