macRes: fix OverflowError while reading resource on 32-bit Python
Fixes https://github.com/behdad/fonttools/issues/436
This commit is contained in:
parent
cba2220446
commit
e4ab85e90a
@ -53,10 +53,16 @@ class ResourceReader(MutableMapping):
|
||||
|
||||
def _read(self, numBytes, offset=None):
|
||||
if offset is not None:
|
||||
self.file.seek(offset)
|
||||
try:
|
||||
self.file.seek(offset)
|
||||
except OverflowError:
|
||||
raise ResourceError("Failed to seek offset ('offset' is too large)")
|
||||
if self.file.tell() != offset:
|
||||
raise ResourceError('Failed to seek offset (reached EOF)')
|
||||
data = self.file.read(numBytes)
|
||||
try:
|
||||
data = self.file.read(numBytes)
|
||||
except OverflowError:
|
||||
raise ResourceError("Cannot read resource ('numBytes' is too large)")
|
||||
if len(data) != numBytes:
|
||||
raise ResourceError('Cannot read resource (not enough data)')
|
||||
return data
|
||||
|
Loading…
x
Reference in New Issue
Block a user