summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-06-18 10:53:36 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-06-18 10:53:36 (GMT)
commit9305d83425e2ec63b2769336907dd07b3151cd5f (patch)
treeaf956a2eff3d5241bfa64dd3dc2890fb44896ada /Objects
parentbae5d81f5d1f388aad48c2ce1aee8682b157e1bd (diff)
downloadcpython-9305d83425e2ec63b2769336907dd07b3151cd5f.zip
cpython-9305d83425e2ec63b2769336907dd07b3151cd5f.tar.gz
cpython-9305d83425e2ec63b2769336907dd07b3151cd5f.tar.bz2
Issue #26754: PyUnicode_FSDecoder() accepted a filename argument encoded as
an iterable of integers. Now only strings and byte-like objects are accepted.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index f11a082..1fcc83e 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -3666,7 +3666,7 @@ PyUnicode_FSDecoder(PyObject* arg, void* addr)
output = arg;
Py_INCREF(output);
}
- else {
+ else if (PyObject_CheckBuffer(arg)) {
arg = PyBytes_FromObject(arg);
if (!arg)
return 0;
@@ -3681,6 +3681,12 @@ PyUnicode_FSDecoder(PyObject* arg, void* addr)
return 0;
}
}
+ else {
+ PyErr_Format(PyExc_TypeError,
+ "path should be string or bytes, not %.200s",
+ Py_TYPE(arg)->tp_name);
+ return 0;
+ }
if (PyUnicode_READY(output) == -1) {
Py_DECREF(output);
return 0;