Skip to content

Commit 0dabdbf

Browse files
gh-53203: Fix strptime() tests for %X on glibc < 2.29
1 parent 5f4e5b5 commit 0dabdbf

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Lib/test/test_strptime.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -569,12 +569,20 @@ def test_date_locale2(self):
569569
'ti_ET', 'tig_ER', 'wal_ET')
570570
def test_time_locale(self):
571571
# Test %X directive
572+
loc = locale.getlocale(locale.LC_TIME)[0]
573+
pos = slice(3, 6)
574+
if glibc_ver and glibc_ver < (2, 29) and loc in {
575+
'aa_ET', 'am_ET', 'byn_ER', 'gez_ET', 'om_ET',
576+
'sid_ET', 'so_SO', 'ti_ET', 'tig_ER', 'wal_ET'}:
577+
# Hours are in 12-hour notation without AM/PM indication.
578+
# Ignore hours.
579+
pos = slice(4, 6)
572580
now = time.time()
573-
self.roundtrip('%X', slice(3, 6), time.localtime(now))
581+
self.roundtrip('%X', pos, time.localtime(now))
574582
# 1 hour 20 minutes 30 seconds ago
575-
self.roundtrip('%X', slice(3, 6), time.localtime(now - 4830))
583+
self.roundtrip('%X', pos, time.localtime(now - 4830))
576584
# 12 hours ago
577-
self.roundtrip('%X', slice(3, 6), time.localtime(now - 12*3600))
585+
self.roundtrip('%X', pos, time.localtime(now - 12*3600))
578586

579587
def test_percent(self):
580588
# Make sure % signs are handled properly

0 commit comments

Comments
 (0)