You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test_TimeRE_recreation_timezone failure on systems with non-default posixrules #79352
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2018-11-06.04:29:11.944>created_at=<Date2018-11-05.22:53:29.646>labels= ['3.7', '3.8', 'type-bug', 'tests']
title='test_TimeRE_recreation_timezone failure on systems with non-default posixrules'updated_at=<Date2018-11-06.04:59:10.218>user='https://github.com/izbyshev'
Traceback (most recent call last):
File "/scratch2/izbyshev/cpython/Lib/test/support/__init__.py", line 1683, in innerreturn func(*args, **kwds)
File "/scratch2/izbyshev/cpython/Lib/test/test_strptime.py", line 702, in test_TimeRE_recreation_timezoneself.assertEqual(tm.tm_isdst, 1)
AssertionError: 0 != 1
This test sets TZ environment variable to 'STD-1DST' and calls time.tzset() (inside support.run_with_tz decorator). This TZ value lacks rules that specify when DST transitions happen. POSIX seems to be silent what should be done if the rule is missing, thought it does specify that the rule is optional[1].
What actually happens at least on Linux/glibc[2] and FreeBSD[3] is that those rules are taken from 'posixrules' file. On OpenSUSE, it's linked to '/etc/localtime', which is linked to 'Europe/Moscow' in my case. DST transitions were cancelled in Russia in 2011, so when Python tries to get timezone names for two points of the year (
), it gets unexpected values instead. The actual values depend on the bugginess of the libc used:
Glibc seems to be confused by having 'posixrules' file with DST cancelled but a specification which includes the DST timezone part, so localtime() returns 'MSK' in tm_zone (both for January and July).
musl doesn't implement 'posixrules' fallback, so it uses "all-zero" rules instead which cause it return 'DST' in both cases.
FreeBSD 11.1 (with 'posixrules' linked to 'Europe/Moscow') returns 'STD' in both cases.
With any of the above, the test fails because strptime is called with the same timezone name two times.
Note that even if PyInit_timezone() didn't probe January/July and used 'tzname' global instead, it wouldn't work as expected at least on FreeBSD: it sets tzname[1] to the empty string in the test above.
ISTM the best way to fix this is to remove dependence on 'posixrules' file by specifying the rules in TZ.
New changeset f1b9ad3 by Benjamin Peterson (Alexey Izbyshev) in branch 'master':
closes bpo-35171: Fix test_TimeRE_recreation_timezone failure on some systems. (GH-10347) f1b9ad3
New changeset ca592bc by Miss Islington (bot) in branch '3.7':
closes bpo-35171: Fix test_TimeRE_recreation_timezone failure on some systems. (GH-10347) ca592bc
New changeset d0e3105 by Miss Islington (bot) in branch '3.6':
closes bpo-35171: Fix test_TimeRE_recreation_timezone failure on some systems. (GH-10347) d0e3105
New changeset ffbce43 by Miss Islington (bot) in branch '2.7':
closes bpo-35171: Fix test_TimeRE_recreation_timezone failure on some systems. (GH-10347) ffbce43
Activity
izbyshev commentedon Nov 5, 2018
I've got the following on OpenSUSE Tumbleweed (glibc 2.27):
======================================================================
FAIL: test_TimeRE_recreation_timezone (test.test_strptime.CacheTests)
----------------------------------------------------------------------
This test sets TZ environment variable to 'STD-1DST' and calls time.tzset() (inside support.run_with_tz decorator). This TZ value lacks rules that specify when DST transitions happen. POSIX seems to be silent what should be done if the rule is missing, thought it does specify that the rule is optional[1].
What actually happens at least on Linux/glibc[2] and FreeBSD[3] is that those rules are taken from 'posixrules' file. On OpenSUSE, it's linked to '/etc/localtime', which is linked to 'Europe/Moscow' in my case. DST transitions were cancelled in Russia in 2011, so when Python tries to get timezone names for two points of the year (
cpython/Modules/timemodule.c
Line 1603 in 570e371
Glibc seems to be confused by having 'posixrules' file with DST cancelled but a specification which includes the DST timezone part, so localtime() returns 'MSK' in tm_zone (both for January and July).
musl doesn't implement 'posixrules' fallback, so it uses "all-zero" rules instead which cause it return 'DST' in both cases.
FreeBSD 11.1 (with 'posixrules' linked to 'Europe/Moscow') returns 'STD' in both cases.
With any of the above, the test fails because strptime is called with the same timezone name two times.
Note that even if PyInit_timezone() didn't probe January/July and used 'tzname' global instead, it wouldn't work as expected at least on FreeBSD: it sets tzname[1] to the empty string in the test above.
ISTM the best way to fix this is to remove dependence on 'posixrules' file by specifying the rules in TZ.
[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08
[2] http://man7.org/linux/man-pages/man3/tzset.3.html
[3] https://www.freebsd.org/cgi/man.cgi?query=tzset&sektion=3
benjaminp commentedon Nov 6, 2018
New changeset f1b9ad3 by Benjamin Peterson (Alexey Izbyshev) in branch 'master':
closes bpo-35171: Fix test_TimeRE_recreation_timezone failure on some systems. (GH-10347)
f1b9ad3
miss-islington commentedon Nov 6, 2018
New changeset ca592bc by Miss Islington (bot) in branch '3.7':
closes bpo-35171: Fix test_TimeRE_recreation_timezone failure on some systems. (GH-10347)
ca592bc
miss-islington commentedon Nov 6, 2018
New changeset d0e3105 by Miss Islington (bot) in branch '3.6':
closes bpo-35171: Fix test_TimeRE_recreation_timezone failure on some systems. (GH-10347)
d0e3105
miss-islington commentedon Nov 6, 2018
New changeset ffbce43 by Miss Islington (bot) in branch '2.7':
closes bpo-35171: Fix test_TimeRE_recreation_timezone failure on some systems. (GH-10347)
ffbce43