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:53:36 +03:00
parent bae5d81f5d
commit 9305d83425
6 changed files with 62 additions and 1 deletions

View file

@ -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;