I've read some topics (like this one) regarding this issue, but it was a side issue and only workarounds were proposed/accepted as an solution.
So is there a way to fix the issue as is, without "read by chunks in a loop":
with open(fileName, 'rb') as bytestream:
buf = bytestream.read()
When file is larger then ~2GB (presumably signed int32) it produces this error:
OSError: [Errno 22] Invalid argument
My config:
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 26 2016, 10:47:25)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
OS: macOS Sierra Version 10.12.6 (16G1212)