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

test_strptime fails when time.strftime does not support %Z format string #121782

Open
CharlieZhao95 opened this issue Jul 15, 2024 · 0 comments
Open
Labels
type-bug An unexpected behavior, bug, or error

Comments

@CharlieZhao95
Copy link
Contributor

CharlieZhao95 commented Jul 15, 2024

Bug report

Bug description:

As time.strftime doc says:

%Z: Time zone name (no characters if no time zone exists). Deprecated.

Some C libraries may replace %Z with a null character, which may cause test_strptime.CalculationTests to fail. For example:

ERROR: test_day_of_week_calculation (test.test_strptime.CalculationTests.test_day_of_week_calculation)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/ci/python3.12/lib/python3.12/test/test_strptime.py", line 563, in test_day_of_week_calculation
    result = _strptime._strptime_time(time.strftime(format_string, self.time_tuple),
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/ci/python3.12/lib/python3.12/_strptime.py", line 548, in _strptime_time
    tt = _strptime(data_string, format)[0]
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/ci/python3.12/lib/python3.12/_strptime.py", line 333, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data '2024 07 11 02 08 193 ' does not match format '%Y %m %d %H %S %j %Z'

In my opinion, removing the deprecated %Z from format_string variable will not affect those tests.

Similar tests that may fail:
test_strptime.CalculationTests.test_day_of_week_calculation
test_strptime.CalculationTests.test_gregorian_calculation
test_strptime.CalculationTests.test_julian_calculation
test_time.TimeTestCase.test_strptime

CPython versions tested on:

3.12

Operating systems tested on:

Linux

@CharlieZhao95 CharlieZhao95 added the type-bug An unexpected behavior, bug, or error label Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant