-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Open
Labels
3.12only security fixesonly security fixes3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirstdlibPython modules in the Lib dirPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
date.strftime
and datetime.strftime
format dates wrong in some locales. For example, when the locale is Bulgaria the '%A' format string returns an incorrect value.
>>> locale.setlocale(locale.LC_TIME, 'bg') # 'bg' is Bulgaria
>>> date_str = datetime.date(2025, 2, 25).strftime('%A') # %A is locale's day of the week
>>> date_str
'âòîðíèê'
>>> date_str.encode('cp1252').decode('cp1251') # I think we're interpreting a cp1251 string as cp1252
'вторник' # Google tells me this is Tuesday in Bulgarian
This also fails with the '%x' format string
I've only tested this on Windows.
My guess is that CPython is making a narrow character API call and using the wrong code page. It should be using the wide character call instead.
CPython versions tested on:
3.13
Operating systems tested on:
Windows
Metadata
Metadata
Assignees
Labels
3.12only security fixesonly security fixes3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirstdlibPython modules in the Lib dirPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
Status
No status
Status
Todo