Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time_test fails after strptime() #66265

Closed
serhiy-storchaka opened this issue Jul 25, 2014 · 4 comments
Closed

time_test fails after strptime() #66265

serhiy-storchaka opened this issue Jul 25, 2014 · 4 comments
Labels
extension-modules C modules in the Modules dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 22067
Nosy @abalkin, @pitrou, @serhiy-storchaka, @iritkatriel

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 = None
closed_at = <Date 2021-11-23.08:28:45.407>
created_at = <Date 2014-07-25.15:05:06.946>
labels = ['extension-modules', 'type-bug', 'tests']
title = 'time_test fails after strptime()'
updated_at = <Date 2021-11-23.08:28:45.407>
user = 'https://github.com/serhiy-storchaka'

bugs.python.org fields:

activity = <Date 2021-11-23.08:28:45.407>
actor = 'serhiy.storchaka'
assignee = 'none'
closed = True
closed_date = <Date 2021-11-23.08:28:45.407>
closer = 'serhiy.storchaka'
components = ['Extension Modules', 'Tests']
creation = <Date 2014-07-25.15:05:06.946>
creator = 'serhiy.storchaka'
dependencies = []
files = []
hgrepos = []
issue_num = 22067
keywords = []
message_count = 4.0
messages = ['223955', '255842', '406806', '406825']
nosy_count = 4.0
nosy_names = ['belopolsky', 'pitrou', 'serhiy.storchaka', 'iritkatriel']
pr_nums = []
priority = 'normal'
resolution = 'out of date'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue22067'
versions = ['Python 2.7']

@serhiy-storchaka
Copy link
Member Author

time_test fails when running after any test which uses strptime().

The bug can be easily reproduced by running test_time twice:

$ TZ=Europe/Kiev ./python -m test.regrtest -ugui -v test_time test_time
...

======================================================================
FAIL: test_strptime (test.test_time.TimeTestCase)
----------------------------------------------------------------------

Traceback (most recent call last):
  File "/home/serhiy/py/cpython-2.7/Lib/test/test_time.py", line 120, in test_strptime
    (format, strf_output))
AssertionError: conversion specifier '%Z' failed with 'MSK' input.

All works on 3.x and with TZ=UTC.

May be this is related to bpo-13309.

@serhiy-storchaka serhiy-storchaka added extension-modules C modules in the Modules dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error labels Jul 25, 2014
@serhiy-storchaka
Copy link
Member Author

If call time.localtime() with time before 1990-03-25T03:00, EET is turned to MSK. I guess this is a time when the Europe/Kiev timezone was introduced.

>>> import os, time
>>> os.environ['TZ'] = 'Europe/Kiev'
>>> time.tzset()
>>> time.localtime(638319599)
time.struct_time(tm_year=1990, tm_mon=3, tm_mday=25, tm_hour=1, tm_min=59, tm_sec=59, tm_wday=6, tm_yday=84, tm_isdst=0)
>>> time.strftime('%Z', time.gmtime())
'MSK'
>>> time.localtime(638319600)
time.struct_time(tm_year=1990, tm_mon=3, tm_mday=25, tm_hour=3, tm_min=0, tm_sec=0, tm_wday=6, tm_yday=84, tm_isdst=1)
>>> time.strftime('%Z', time.gmtime())
'EET'

C function localtime() implicitly calls tzset() and sets global C variables tzname, timezone, and daylight, but these changes are not exposed as variables in the time module. C and Python ideas about timezone becomes different. This looks as a bug in time.localtime() and other functions that implicitly change timezone variables.

@iritkatriel
Copy link
Member

I am unable to reproduce this on 3.11.

@serhiy-storchaka
Copy link
Member Author

Yes, it was 2.7-only issue.

Thank you Irit for checking and closing outdated issues.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension-modules C modules in the Modules dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants