Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 32411ca

Browse files
committed
Small cleanups to dviread.
Don't use variables whose name shadow builtins (`bytes`, `str` -- the latter is actually a bytes instance). Also use a slightly more idiomatic way to iterate over the bytestring.
1 parent 382be60 commit 32411ca

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/matplotlib/dviread.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ def _arg_raw(dvi, delta):
7373
return delta
7474

7575

76-
def _arg(bytes, signed, dvi, _):
77-
"""Read *bytes* bytes, returning the bytes interpreted as a
76+
def _arg(nbytes, signed, dvi, _):
77+
"""Read *nbytes* bytes, returning the bytes interpreted as a
7878
signed integer if *signed* is true, unsigned otherwise."""
79-
return dvi._arg(bytes, signed)
79+
return dvi._arg(nbytes, signed)
8080

8181

8282
def _arg_slen(dvi, delta):
@@ -304,12 +304,12 @@ def _arg(self, nbytes, signed=False):
304304
Read and return an integer argument *nbytes* long.
305305
Signedness is determined by the *signed* keyword.
306306
"""
307-
str = self.file.read(nbytes)
308-
value = str[0]
307+
buf = self.file.read(nbytes)
308+
value = buf[0]
309309
if signed and value >= 0x80:
310310
value = value - 0x100
311-
for i in range(1, nbytes):
312-
value = 0x100*value + str[i]
311+
for b in buf[1:]:
312+
value = 0x100*value + b
313313
return value
314314

315315
@_dispatch(min=0, max=127, state=_dvistate.inpage)

0 commit comments

Comments
 (0)