Repository navigation
strptime(.., '%c') fails to parse output of strftime('%c', ..) in some locales #53203
Copy link
Copy link
Closed
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
| BPO | 8957 |
|---|---|
| Nosy | @abalkin, @vstinner, @ezio-melotti |
| Dependencies | |
| Files |
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 = None
created_at = <Date 2010-06-09.20:24:38.889>
labels = ['extension-modules', 'type-bug', '3.7']
title = "strptime(.., '%c') fails to parse output of strftime('%c', ..) in some locales"
updated_at = <Date 2016-09-26.21:29:29.654>
user = 'https://github.com/abalkin'bugs.python.org fields:
activity = <Date 2016-09-26.21:29:29.654>
actor = 'belopolsky'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Extension Modules']
creation = <Date 2010-06-09.20:24:38.889>
creator = 'belopolsky'
dependencies = ['8915']
files = ['17601', '17602', '20358', '20412']
hgrepos = []
issue_num = 8957
keywords = ['patch']
message_count = 18.0
messages = ['107413', '125966', '125968', '126043', '126045', '126055', '126057', '126059', '126084', '126235', '126313', '126316', '126339', '126340', '126345', '126347', '126358', '221924']
nosy_count = 4.0
nosy_names = ['belopolsky', 'vstinner', 'ezio.melotti', 'rpetrov']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'needs patch'
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue8957'
versions = ['Python 3.7']Linked PRs
- gh-53203: Fix strptime() for %c and %x formats on many locales #124946
- gh-53203: Improve tests for strptime() #125090
- [3.13] gh-53203: Improve tests for strptime() (GH-125090) #125091
- [3.12] gh-53203: Improve tests for strptime() (GH-125090) #125093
- [3.13] gh-53203: Fix strptime() for %c and %x formats on many locales (GH-124946) #125369
- [3.12] gh-53203: Fix strptime() for %c and %x formats on many locales (GH-124946) #125370
- gh-53203: Fix strptime() for %c, %x and %X formats on many locales #125406
- [3.13] gh-53203: Fix strptime() for %c, %x and %X formats on many locales (GH-125406) #125454
- gh-53203: Fix strptime() tests for %X on glibc < 2.29 #125469
- [3.12] gh-53203: Fix strptime() for %c, %x and %X formats on many locales (GH-125406) (GH-125454) #125483
- gh-53203: Fix test_strptime on Solaris #125785
- [3.13] gh-53203: Fix test_strptime on Solaris (GH-125785) #125806
- [3.12] gh-53203: Fix test_strptime on Solaris (GH-125785) #125807
- gh-53203: Fix strptime() for %c, %x and %X formats on some locales #135971
- [3.14] gh-53203: Fix strptime() for %c, %x and %X formats on some locales (GH-135971) #136019
- [3.13] gh-53203: Fix strptime() for %c, %x and %X formats on some locales (GH-135971) #136020
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
- StatusShow more project fieldsDone
- StatusShow more project fieldsDone
Activity
abalkin commentedon Jun 9, 2010
The following code:
Raises
ValueError: time data '%c' does not match format 'Mer 9 jui 16:14:46 2010'
in any locale where month follows day in '%c' format. Note that attached C code works as expected on my OSX laptop.
I wonder it it would make sense to call platform strptime where available? I wonder if platform support for strptime has improved since 2002 when _strptime.py was introduced.
abalkin commentedon Jan 11, 2011
Adding bpo-8915 as a dependency because deducing D_T_FMT locale setting from strftime output seems impossible:
>>> locale.nl_langinfo(locale.D_T_FMT) '%a %b %e %H:%M:%S %Y'abalkin commentedon Jan 11, 2011
Victor,
You may be interested because your native language is implicated. :-)
rpetrov commentedon Jan 11, 2011
time.strptime(s, '%c' ) ?
abalkin commentedon Jan 11, 2011
Oh my. It certainly took a long time to recognize a silly mistake!
Thanks.
abalkin commentedon Jan 12, 2011
My tests were wrong but the problem does exist. I am attaching a script that tests strptime(.., '%c') for all locales installed on my system (an unmodified US Mac OS X 10.6.6).
The only failing locale that I recognize is Hebrew (he_IL). Eli, what do you think about this?
[-]strptime('%c', ..) fails to parse output of strftime('%c', ..) in non-English locale[/-][+]strptime(.., '%c') fails to parse output of strftime('%c', ..) in some locales[/+]rpetrov commentedon Jan 12, 2011
68 remaining items
pythongh-53203: Fix strptime() for %c, %x and %X formats on some locales
serhiy-storchaka commentedon Jun 26, 2025
#135971 is perhaps the last PR for this issue. It adds support of non-decimal alt digits on locale lzh_TW, fixes bug in detecting the position of week day name on locales byn_ER and wal_ET, fixes support of single-digit hour on locales ar_SA and bg_BG.
The code is prepared for using nl_langinfo(). The rest of changes belongs to #53161.
gh-53203: Fix strptime() for %c, %x and %X formats on some locales (#…
pythongh-53203: Fix strptime() for %c, %x and %X formats on some loca…
pythongh-53203: Fix strptime() for %c, %x and %X formats on some loca…
[3.13] gh-53203: Fix strptime() for %c, %x and %X formats on some loc…
[3.14] gh-53203: Fix strptime() for %c, %x and %X formats on some loc…
pythongh-53203: Fix strptime() for %c, %x and %X formats on some loca…
pythongh-53203: Fix strptime() for %c, %x and %X formats on some loca…
pythongh-53203: Fix strptime() for %c, %x and %X formats on some loca…
pythongh-53203: Fix strptime() for %c, %x and %X formats on some loca…