Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 907f0b7

Browse filesBrowse files
committed
Use int.from_bytes instead of implementing the conversion ourselves.
int.from_bytes has been around since Python 3.2.
1 parent ea66786 commit 907f0b7
Copy full SHA for 907f0b7

File tree

Expand file treeCollapse file tree

1 file changed

+2
-8
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+2
-8
lines changed

‎lib/matplotlib/dviread.py

Copy file name to clipboardExpand all lines: lib/matplotlib/dviread.py
+2-8Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -392,16 +392,10 @@ def _read(self):
392392

393393
def _arg(self, nbytes, signed=False):
394394
"""
395-
Read and return an integer argument *nbytes* long.
395+
Read and return a big-endian integer *nbytes* long.
396396
Signedness is determined by the *signed* keyword.
397397
"""
398-
buf = self.file.read(nbytes)
399-
value = buf[0]
400-
if signed and value >= 0x80:
401-
value = value - 0x100
402-
for b in buf[1:]:
403-
value = 0x100*value + b
404-
return value
398+
return int.from_bytes(self.file.read(nbytes), "big", signed=signed)
405399

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.