mirror of https://github.com/python/cpython.git
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.
This commit is contained in:
parent
2b635971e7
commit
dbe28d26b4
|
@ -717,16 +717,22 @@ is not present, current time as returned by localtime() is used.\n\
|
||||||
static PyObject *
|
static PyObject *
|
||||||
time_strptime(PyObject *self, PyObject *args)
|
time_strptime(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *strptime_module = PyImport_ImportModuleNoBlock("_strptime");
|
PyObject *module, *func, *result;
|
||||||
PyObject *strptime_result;
|
|
||||||
_Py_IDENTIFIER(_strptime_time);
|
_Py_IDENTIFIER(_strptime_time);
|
||||||
|
|
||||||
if (!strptime_module)
|
module = PyImport_ImportModuleNoBlock("_strptime");
|
||||||
|
if (!module)
|
||||||
return NULL;
|
return NULL;
|
||||||
strptime_result = _PyObject_CallMethodId(strptime_module,
|
|
||||||
&PyId__strptime_time, "O", args);
|
func = _PyObject_GetAttrId(module, &PyId__strptime_time);
|
||||||
Py_DECREF(strptime_module);
|
Py_DECREF(module);
|
||||||
return strptime_result;
|
if (!func) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = PyObject_Call(func, args, NULL);
|
||||||
|
Py_DECREF(func);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue