Author eryksun
Recipients AndiDog_old, belopolsky, eric.smith, eryksun, ezio.melotti, paul.moore, shimizukawa, steve.dower, terry.reedy, tim.golden, vstinner, zach.ware
Date 2021-03-07.16:09:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Update since msg255133:

Python 3.8+ now calls setlocale(LC_CTYPE, "") at startup in Windows, as 3.x has always done in POSIX. So decoding the output of C strftime("%Z") with PyUnicode_DecodeLocaleAndSize() 'works' again, since both default to the process code page. The latter is usually the system code page, unless overridden to UTF-8 in the application manifest.

But calling C strftime() as a workaround is still a fragile solution, since it requires that the process code page is able to encode the process or thread UI language. In general, the system code page, the current user locale, and current user preferred language are independent settings in Windows. 

Calling C strftime() also unnecessarily limits the format string to characters in the current LC_CTYPE locale encoding, which requires hacky workarounds.

Starting with Windows 10 v2004 (build 19041), ucrt uses an internal wide-character version of the time-zone name that gets returned by an internal __wide_tzname() call and used for "%Z" in wcsftime(). The wide-character value gets updated by _tzset() and kept in sync with _tzname.

If Python switched to using wcsftime() in Windows 10 2004+, then the current locale encoding would no longer be a problem for any UI language. 

Also, bpo-36779 switched to setting time.tzname by directly calling WinAPI GetTimeZineInformation(). time.tzset() should be implemented in order to keep the value of time.tzname in sync with time.strftime("%Z").
Date User Action Args
2021-03-07 16:09:30eryksunsetrecipients: + eryksun, terry.reedy, paul.moore, belopolsky, vstinner, eric.smith, tim.golden, ezio.melotti, AndiDog_old, shimizukawa, zach.ware, steve.dower
2021-03-07 16:09:30eryksunsetmessageid: <>
2021-03-07 16:09:30eryksunlinkissue8304 messages
2021-03-07 16:09:30eryksuncreate