Skip to content

Commit

Permalink
Link open() docs rather than recommendeing replace
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Jul 29, 2022
1 parent cff414b commit 2379c55
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions chess/pgn.py
Original file line number Diff line number Diff line change
Expand Up @@ -1466,14 +1466,11 @@ def read_game(handle: TextIO, *, Visitor: Any = GameBuilder) -> Any:
By using text mode, the parser does not need to handle encodings. It is the
caller's responsibility to open the file with the correct encoding.
PGN files are usually ASCII or UTF-8 encoded, sometimes with BOM (which
this parser automatically ignores).
this parser automatically ignores). See :func:`open` for options to
deal with encoding errors.
>>> pgn = open("data/pgn/kasparov-deep-blue-1997.pgn", encoding="utf-8")
If you get a UnicodeDecodeError, including the following parameters might help:
>>> pgn = open("data/pgn/kasparov-deep-blue-1997.pgn", 'r', errors='replace')
Use :class:`~io.StringIO` to parse games from a string.
>>> import io
Expand Down

0 comments on commit 2379c55

Please sign in to comment.