Skip to content
Closed
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
22 changes: 17 additions & 5 deletions Lib/test/test_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
from unittest import mock
from copy import copy

if sys.platform == 'win32':
import locale

# These tests are not particularly useful if Python was invoked with -S.
# If you add tests that are useful under -S, this skip should be moved
# to the class level.
Expand Down Expand Up @@ -534,11 +537,20 @@ def test_startup_imports(self):
if sys.platform != 'darwin':
# http://bugs.python.org/issue19209
self.assertNotIn('copyreg', modules, stderr)
# http://bugs.python.org/issue19218>
collection_mods = {'_collections', 'collections', 'functools',
'heapq', 'itertools', 'keyword', 'operator',
'reprlib', 'types', 'weakref'
}.difference(sys.builtin_module_names)
if sys.platform == 'win32' and locale.getpreferredencoding() == 'cp65001':
# if the default ansi codepage on Windows is 65001 (UTF-8)
# cp65001.py is loaded but not in the set of frozen modules
collection_mods = {'_collections', 'itertools', 'types',
'weakref'
}.difference(sys.builtin_module_names)
else:
# http://bugs.python.org/issue19218>
# if the default ansi codepage on Windows is 1252 (Western European)
# cp1252.py is loaded from frozen.c
collection_mods = {'_collections', 'collections', 'functools',
'heapq', 'itertools', 'keyword', 'operator',
'reprlib', 'types', 'weakref'
}.difference(sys.builtin_module_names)
self.assertFalse(modules.intersection(collection_mods), stderr)

def test_startup_interactivehook(self):
Expand Down
19 changes: 19 additions & 0 deletions Modules/timemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1619,9 +1619,28 @@ init_timezone(PyObject *m)
And I'm lazy and hate C so nyer.
*/
#ifdef HAVE_DECL_TZNAME
#ifdef MS_WINDOWS
# include <locale.h>
// https://bugs.python.org/issue36778
// workaround bug in UCRT
// strptime fails if the current locale is a Unicode locale
int cp = GetACP();
char* save_locale = NULL;
if (cp == CP_UTF8 || cp == CP_UTF7)
{
save_locale = setlocale(LC_CTYPE, NULL);
setlocale(LC_CTYPE, "C");
}
#endif
PyObject *otz0, *otz1;
tzset();
PyModule_AddIntConstant(m, "timezone", _Py_timezone);
#ifdef MS_WINDOWS
if (cp == CP_UTF8 || cp == CP_UTF7)
{
setlocale(LC_CTYPE, save_locale);
}
#endif
#ifdef HAVE_ALTZONE
PyModule_AddIntConstant(m, "altzone", altzone);
#else
Expand Down