Issue #26754: PyUnicode_FSDecoder() accepted a filename argument encoded as

an iterable of integers. Now only strings and byte-like objects are accepted.
This commit is contained in:
Serhiy Storchaka 2016-06-18 13:56:16 +03:00
commit f95de0e8cc
6 changed files with 61 additions and 1 deletions

View file

@ -3837,7 +3837,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;
@ -3852,6 +3852,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;