You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The PGN specification represents a quote inside a string as \" and a backslash as \\. Header values are string tokens, but python-chess currently exposes those representation escapes through read_game() / read_headers() and writes semantic quotes or backslashes without escaping them.
For example, a valid [Event "The \"Open\""] header is returned as The \"Open\", while assigning the semantic value The "Open" exports an invalid header with bare inner quotes.
Fix
Decode the two PGN-defined string escapes before dispatching parsed header values. Unknown backslash sequences retain the existing forgiving import behavior.
Escape backslashes and quotes in StringExporterMixin, covering both string and file exporters.
Add a shared table of ordinary, quote, backslash, mixed, trailing-backslash, and bracket cases across read_game, read_headers, StringExporter, FileExporter, and export/read round trips.
The seven Ubuntu test jobs all stopped in .github/workflows/setup-ubuntu-latest.sh before installing this branch or running tests: apt returned 404 for libatopology2t64_1.2.11-1ubuntu0.2. Windows tests, all typing jobs, perft, and the README job passed. The README job runs apt-get update first, which is why the same Ubuntu dependency setup succeeded there. I cannot rerun failed jobs without repository admin rights.
The ubuntu job failures are environmental: the runner image's baked-in apt lists point at libatopology2t64_1.2.11-1ubuntu0.2, which the mirror no longer carries (404), and setup-ubuntu-latest.sh installs without refreshing the index. Added sudo apt-get update at the top of the script — that should unblock CI for every PR hitting image ubuntu24/20260714.240, not just this one. Happy to drop the commit if you'd rather fix it separately.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The PGN specification represents a quote inside a string as
\"and a backslash as\\. Header values are string tokens, but python-chess currently exposes those representation escapes throughread_game()/read_headers()and writes semantic quotes or backslashes without escaping them.For example, a valid
[Event "The \"Open\""]header is returned asThe \"Open\", while assigning the semantic valueThe "Open"exports an invalid header with bare inner quotes.Fix
StringExporterMixin, covering both string and file exporters.read_game,read_headers,StringExporter,FileExporter, and export/read round trips.Specification: https://www.saremba.de/chessgml/standards/pgn/pgn-complete.htm#c7
Testing
python test.py— 294 passed, 22 skipped (external engines/tablebases)python -m mypy --strict chess— cleanpython -m mypy --strict examples/**/*.py— cleanpython -m pyright chess examples/**/*.py— zero errorsThe README doctest needs a local
stockfishbinary; its three resulting failures reproduce unchanged on pristineorigin/master.