diff --git a/chess/polyglot.py b/chess/polyglot.py index 44a68caa..a7d6807c 100644 --- a/chess/polyglot.py +++ b/chess/polyglot.py @@ -324,7 +324,7 @@ class MemoryMappedReader: """Maps a Polyglot opening book to memory.""" def __init__(self, filename: StrOrBytesPath) -> None: - fd = os.open(filename, os.O_RDONLY | os.O_BINARY if hasattr(os, "O_BINARY") else os.O_RDONLY) + fd = os.open(filename, os.O_RDONLY | getattr(os, "O_BINARY", 0)) try: self.mmap: Union[mmap.mmap, _EmptyMmap] = mmap.mmap(fd, 0, access=mmap.ACCESS_READ) except (ValueError, OSError): diff --git a/chess/syzygy.py b/chess/syzygy.py index 89f8c259..5ead9922 100644 --- a/chess/syzygy.py +++ b/chess/syzygy.py @@ -587,7 +587,7 @@ def __init__(self, path: str, *, variant: Type[chess.Board] = chess.Board) -> No def init_mmap(self) -> None: if self.data is None: - fd = os.open(self.path, os.O_RDONLY | os.O_BINARY if hasattr(os, "O_BINARY") else os.O_RDONLY) + fd = os.open(self.path, os.O_RDONLY | getattr(os, "O_BINARY", 0)) try: data = mmap.mmap(fd, 0, access=mmap.ACCESS_READ) finally: