diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-07-11 03:36:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-11 03:36:46 (GMT) |
commit | 1180e5a51871fa53ca6892e83fd2e69dc2600447 (patch) | |
tree | b05732085cdc4aa1995c163f32bc7a04927cef7b /Modules | |
parent | 4f9a446f3fb42f800e73cd9414dd1eccb3ca4fa7 (diff) | |
download | cpython-1180e5a51871fa53ca6892e83fd2e69dc2600447.zip cpython-1180e5a51871fa53ca6892e83fd2e69dc2600447.tar.gz cpython-1180e5a51871fa53ca6892e83fd2e69dc2600447.tar.bz2 |
bpo-30879: os.listdir() and os.scandir() now emit bytes names when (#2634)
called with bytes-like argument.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/posixmodule.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 194a2b5..0c6723f 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -1037,6 +1037,8 @@ path_converter(PyObject *o, void *p) Py_INCREF(bytes); } else if (is_buffer) { + /* XXX Replace PyObject_CheckBuffer with PyBytes_Check in other code + after removing suport of non-bytes buffer objects. */ if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, "%s%s%s should be %s, not %.200s", path->function_name ? path->function_name : "", @@ -3588,8 +3590,8 @@ _posix_listdir(path_t *path, PyObject *list) const char *name; if (path->narrow) { name = path->narrow; - /* only return bytes if they specified a bytes object */ - return_str = !(PyBytes_Check(path->object)); + /* only return bytes if they specified a bytes-like object */ + return_str = !PyObject_CheckBuffer(path->object); } else { name = "."; @@ -11842,7 +11844,7 @@ DirEntry_from_posix_info(path_t *path, const char *name, Py_ssize_t name_len, goto error; } - if (!path->narrow || !PyBytes_Check(path->object)) { + if (!path->narrow || !PyObject_CheckBuffer(path->object)) { entry->name = PyUnicode_DecodeFSDefaultAndSize(name, name_len); if (joined_path) entry->path = PyUnicode_DecodeFSDefault(joined_path); |