8000 `test_strptime` fails when `time.strftime` does not support `%Z` format string · Issue #121782 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
test_strptime fails when time.strftime does not support %Z format string #121782
Closed as not pl 8000 anned
@CharlieZhao95

Description

@CharlieZhao95

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

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Done

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0