`iso2022_jp_3` encodes U+9B1D but decodes the result as U+9B1C
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 84/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- python
- Bereich
- internationalization
Rechercherichtung
Lies Modules/cjkcodecs/_codecs_iso2022.c im Bereich von jisx0213_2000_2_decoder und vergleiche die Mapping-Logik für Ebene 2 mit dem Decoder für Ebene 1. Das Issue nennt das fehlende else und die betroffene Zelle; verwende den Test RoundTripBugs.test_iso2022_jp_3_mapping aus PR #160155 als Regressionstest. Fertig ist die Arbeit, wenn iso2022_jp_3 U+9B1D korrekt hin und zurück konvertiert und dabei das erwartete Mapping von 2000 beibehält.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Bug description
>>> '鬝'.encode('iso2022_jp_3')
b'\x1b$(P};\x1b(B'
>>> _.decode('iso2022_jp_3')
'鬜'
>>> hex(ord(_))
'0x9b1c'
JIS X 0213:2004 changed plane 2 row 93 cell 27 (0x7D3B) from U+9B1D to U+9B1C, and CPython emulates the 2000 mapping in the codecs named after that edition. euc_jisx0213 and shift_jisx0213 do so in both directions:
>>> '鬝'.encode('euc_jisx0213').decode('euc_jisx0213')
'鬝'
>>> '鬜'.encode('euc_jisx0213')
Traceback (most recent call last):
File "<python-input-5>", line 1, in <module>
'鬜'.encode('euc_jisx0213')
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'euc_jisx0213' codec can't encode character '鬜' in position 0: illegal multibyte sequence
iso2022_jp_3 only does it when encoding: it accepts U+9B1D and rejects U+9B1C like the other 2000 codecs, but decodes 0x7D3B as U+9B1C, as iso2022_jp_2004 does.
The cause is in jisx0213_2000_2_decoder, Modules/cjkcodecs/_codecs_iso2022.c lines 728-739. The EMULATE_JISX0213_2000_DECODE_PLANE2_CHAR macro expands to an if that sets u = 0x9B1D for this cell, but the table lookup that follows it is a plain if (TRYMAP_DEC_ST(jisx0213_2_bmp, ...)) rather than else if, so it runs regardless and overwrites u with the 2004 value. The plane 1 decoder just above uses else if after its emulation macro and is fine, as are the EUC and Shift_JIS codecs, which use the OUTCHAR form of the macro in _codecs_jp.c. So the fix is the missing else.
A scan of every code point through iso2022_jp_3 found no other character that comes back different, so it should be just this one cell.
Found by the Hypothesis tests in #160155, where it is pinned as RoundTripBugs.test_iso2022_jp_3_mapping under expectedFailure and kept out of the generated text otherwise.
CPython versions tested on
CPython main (6e1bd24e4d8)
Operating systems tested on
Linux
- Vorherrschende Sprache
- Python
- Sterne
- 77.7k
- Forks
- 38.3k
- Ø Merge
- 12 Std. 27 Min.
- Gemergte PRs (30 T.)
- 645
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus python/cpython
-
tests topic-profiling type-bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
tests topic-multiprocessing type-bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 71/100
Maintainer antworten meist innerhalb von 1 Tag
-
interpreter-core type-feature
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 78/100
python/cpython#160109 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
extension-modules type-bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
python/cpython#160001 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
stdlib topic-XML type-bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag
Ähnliche Issues
-
Python Volcengine provider returns failures instead of raising themEvtl. vergeben @Ricardo-M-L hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 79/100
agent-infra/sandbox#248 ·
-
Textractor leaves empty temporary files when remote retrieval failsEvtl. vergeben @HuaTNA hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
test(bm_generation): pin the learning parameters and CPU sync shortcutEvtl. vergeben @iloveeyjafjalla hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
qboson/kaiwu-pytorch-plugin#1341 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
elder-plinius/V3R1T4S#625 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
foxglove/mcap#1907 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag