mirror of
https://github.com/python/cpython.git
synced 2025-07-30 06:34:15 +00:00
bpo-35373: Fix PyInit_timezone() if HAVE_DECL_TZNAME is defined (GH-10861)
If HAVE_DECL_TZNAME, PyInit_timezone() now returns -1 on error.
This commit is contained in:
parent
4013c17911
commit
ab66149693
1 changed files with 5 additions and 4 deletions
|
@ -1581,16 +1581,17 @@ PyInit_timezone(PyObject *m)
|
||||||
PyModule_AddIntConstant(m, "daylight", daylight);
|
PyModule_AddIntConstant(m, "daylight", daylight);
|
||||||
otz0 = PyUnicode_DecodeLocale(tzname[0], "surrogateescape");
|
otz0 = PyUnicode_DecodeLocale(tzname[0], "surrogateescape");
|
||||||
if (otz0 == NULL) {
|
if (otz0 == NULL) {
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
otz1 = PyUnicode_DecodeLocale(tzname[1], "surrogateescape");
|
otz1 = PyUnicode_DecodeLocale(tzname[1], "surrogateescape");
|
||||||
if (otz1 == NULL) {
|
if (otz1 == NULL) {
|
||||||
Py_DECREF(otz0);
|
Py_DECREF(otz0);
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
PyObject *tzname_obj = Py_BuildValue("(NN)", otz0, otz1);
|
PyObject *tzname_obj = Py_BuildValue("(NN)", otz0, otz1);
|
||||||
if (tzname_obj == NULL)
|
if (tzname_obj == NULL) {
|
||||||
return;
|
return -1;
|
||||||
|
}
|
||||||
PyModule_AddObject(m, "tzname", tzname_obj);
|
PyModule_AddObject(m, "tzname", tzname_obj);
|
||||||
#else // !HAVE_DECL_TZNAME
|
#else // !HAVE_DECL_TZNAME
|
||||||
static const time_t YEAR = (365 * 24 + 6) * 3600;
|
static const time_t YEAR = (365 * 24 + 6) * 3600;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue