Skip to content

Commit caa7d42

Browse files
authored
Merge pull request #27288 from anntzer/ifb
Use int.from_bytes instead of implementing the conversion ourselves.
2 parents fcbf883 + 907f0b7 commit caa7d42

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

lib/matplotlib/dviread.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -356,16 +356,10 @@ def _read(self):
356356

357357
def _arg(self, nbytes, signed=False):
358358
"""
359-
Read and return an integer argument *nbytes* long.
359+
Read and return a big-endian integer *nbytes* long.
360360
Signedness is determined by the *signed* keyword.
361361
"""
362-
buf = self.file.read(nbytes)
363-
value = buf[0]
364-
if signed and value >= 0x80:
365-
value = value - 0x100
366-
for b in buf[1:]:
367-
value = 0x100*value + b
368-
return value
362+
return int.from_bytes(self.file.read(nbytes), "big", signed=signed)
369363

370364
@_dispatch(min=0, max=127, state=_dvistate.inpage)
371365
def _set_char_immediate(self, char):

0 commit comments

Comments
 (0)