diff options
author | Henry-Joseph Audéoud <h.audeoud@gmail.com> | 2021-09-10 14:26:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-10 15:26:16 +0300 |
commit | 707137b8637feef37b2e06a851fdca9d1b945861 (patch) | |
tree | eedd9bec5c0b98b244438e120ee12d8143906c19 /Modules/_gdbmmodule.c | |
parent | 62fa613f6a6e872723505ee9d56242c31a654a9d (diff) | |
download | cpython-git-707137b8637feef37b2e06a851fdca9d1b945861.tar.gz |
bpo-40563: Support pathlike objects on dbm/shelve (GH-21849)
Co-authored-by: Hakan Çelik <hakancelik96@outlook.com>
Diffstat (limited to 'Modules/_gdbmmodule.c')
-rw-r--r-- | Modules/_gdbmmodule.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Modules/_gdbmmodule.c b/Modules/_gdbmmodule.c index 3c9a0e98e4..efbf331ca3 100644 --- a/Modules/_gdbmmodule.c +++ b/Modules/_gdbmmodule.c @@ -590,7 +590,7 @@ static PyType_Spec gdbmtype_spec = { /*[clinic input] _gdbm.open as dbmopen - filename: unicode + filename: object flags: str="r" mode: int(py_default="0o666") = 0o666 / @@ -622,7 +622,7 @@ when the database has to be created. It defaults to octal 0o666. static PyObject * dbmopen_impl(PyObject *module, PyObject *filename, const char *flags, int mode) -/*[clinic end generated code: output=9527750f5df90764 input=812b7d74399ceb0e]*/ +/*[clinic end generated code: output=9527750f5df90764 input=bca6ec81dc49292c]*/ { int iflags; _gdbm_state *state = get_gdbm_state(module); @@ -672,10 +672,11 @@ dbmopen_impl(PyObject *module, PyObject *filename, const char *flags, } } - PyObject *filenamebytes = PyUnicode_EncodeFSDefault(filename); - if (filenamebytes == NULL) { + PyObject *filenamebytes; + if (!PyUnicode_FSConverter(filename, &filenamebytes)) { return NULL; } + const char *name = PyBytes_AS_STRING(filenamebytes); if (strlen(name) != (size_t)PyBytes_GET_SIZE(filenamebytes)) { Py_DECREF(filenamebytes); |