diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-12-08 23:38:53 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-12-08 23:38:53 (GMT) |
commit | dbe28d26b46adb7ed3d6731bc148fc095ff43bba (patch) | |
tree | 5266105803fd79823af0215631426eebeb284723 /Modules/timemodule.c | |
parent | 2b635971e7fedc06b8a12d467a8b717c9752f4a4 (diff) | |
download | cpython-dbe28d26b46adb7ed3d6731bc148fc095ff43bba.zip cpython-dbe28d26b46adb7ed3d6731bc148fc095ff43bba.tar.gz cpython-dbe28d26b46adb7ed3d6731bc148fc095ff43bba.tar.bz2 |
time_strptime() uses PyObject_Call()
Issue #28915: Use PyObject_Call() to pass a tuple of positional arguments,
instead of relying on _PyObject_CallMethodId() weird behaviour to unpack the
tuple.
Diffstat (limited to 'Modules/timemodule.c')
-rw-r--r-- | Modules/timemodule.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c index db0ab58..e9edbf3 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -717,16 +717,22 @@ is not present, current time as returned by localtime() is used.\n\ static PyObject * time_strptime(PyObject *self, PyObject *args) { - PyObject *strptime_module = PyImport_ImportModuleNoBlock("_strptime"); - PyObject *strptime_result; + PyObject *module, *func, *result; _Py_IDENTIFIER(_strptime_time); - if (!strptime_module) + module = PyImport_ImportModuleNoBlock("_strptime"); + if (!module) return NULL; - strptime_result = _PyObject_CallMethodId(strptime_module, - &PyId__strptime_time, "O", args); - Py_DECREF(strptime_module); - return strptime_result; + + func = _PyObject_GetAttrId(module, &PyId__strptime_time); + Py_DECREF(module); + if (!func) { + return NULL; + } + + result = PyObject_Call(func, args, NULL); + Py_DECREF(func); + return result; } |