`date.strftime` and `datetime.strftime` format dates wrong in some locales.
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Riproduci il problema su Windows usando date.strftime e datetime.strftime con la locale bulgara, verificando sia le stringhe di formato %A sia %x. Traccia il modo in cui questi punti di ingresso ottengono il testo formattato secondo la locale e verifica che il risultato sia il valore bulgaro decodificato correttamente, non mojibake.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- localization
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 42/100