Skip to content

gh-53203: Fix strptime() tests for %X on glibc < 2.29 #125469

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

Merged
merged 3 commits into from
Oct 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions Lib/test/test_strptime.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,12 +569,20 @@ def test_date_locale2(self):
'ti_ET', 'tig_ER', 'wal_ET')
def test_time_locale(self):
# Test %X directive
loc = locale.getlocale(locale.LC_TIME)[0]
pos = slice(3, 6)
if glibc_ver and glibc_ver < (2, 29) and loc in {
'aa_ET', 'am_ET', 'byn_ER', 'gez_ET', 'om_ET',
'sid_ET', 'so_SO', 'ti_ET', 'tig_ER', 'wal_ET'}:
# Hours are in 12-hour notation without AM/PM indication.
# Ignore hours.
pos = slice(4, 6)
now = time.time()
self.roundtrip('%X', slice(3, 6), time.localtime(now))
self.roundtrip('%X', pos, time.localtime(now))
# 1 hour 20 minutes 30 seconds ago
self.roundtrip('%X', slice(3, 6), time.localtime(now - 4830))
self.roundtrip('%X', pos, time.localtime(now - 4830))
# 12 hours ago
self.roundtrip('%X', slice(3, 6), time.localtime(now - 12*3600))
self.roundtrip('%X', pos, time.localtime(now - 12*3600))

def test_percent(self):
# Make sure % signs are handled properly
Expand Down
Loading