Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Ensure ``time.tzname`` is correct on Windows when the active code page is
set to CP_UTF7 or CP_UTF8.
14 changes: 14 additions & 0 deletions Modules/timemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1571,6 +1571,19 @@ init_timezone(PyObject *m)
PyModule_AddIntConstant(m, "altzone", _Py_timezone-3600);
#endif
PyModule_AddIntConstant(m, "daylight", _Py_daylight);
#ifdef MS_WINDOWS
TIME_ZONE_INFORMATION tzinfo = {0};
GetTimeZoneInformation(&tzinfo);
otz0 = PyUnicode_FromWideChar(tzinfo.StandardName, -1);
if (otz0 == NULL) {
return -1;
}
otz1 = PyUnicode_FromWideChar(tzinfo.DaylightName, -1);
if (otz1 == NULL) {
Py_DECREF(otz0);
return -1;
}
#else
otz0 = PyUnicode_DecodeLocale(_Py_tzname[0], "surrogateescape");
if (otz0 == NULL) {
return -1;
Expand All @@ -1580,6 +1593,7 @@ init_timezone(PyObject *m)
Py_DECREF(otz0);
return -1;
}
#endif // MS_WINDOWS
PyObject *tzname_obj = Py_BuildValue("(NN)", otz0, otz1);
if (tzname_obj == NULL) {
return -1;
Expand Down