diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-06-18 10:56:16 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-06-18 10:56:16 (GMT) |
commit | f95de0e8cc259b1ccb6b604a0ed74bb7894f4b2b (patch) | |
tree | 24ae043565544e6b02d39b127439b987b144d0d8 /Objects | |
parent | 2fec611a70ba862a4127b7656a6d98d48850c3af (diff) | |
parent | 9305d83425e2ec63b2769336907dd07b3151cd5f (diff) | |
download | cpython-f95de0e8cc259b1ccb6b604a0ed74bb7894f4b2b.zip cpython-f95de0e8cc259b1ccb6b604a0ed74bb7894f4b2b.tar.gz cpython-f95de0e8cc259b1ccb6b604a0ed74bb7894f4b2b.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.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 7de44ce..db6a51c 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -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; |