You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Issue #363: Convert 14 statements to the usage of augmented assignments
Augmented assignment statements became available with Python 2. https://docs.python.org/3/whatsnew/2.0.html#augmented-assignment Thus adjust 14 source code places accordingly. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
This commit is contained in:
@@ -14,11 +14,11 @@ def a():
|
|||||||
def c():
|
def c():
|
||||||
k = 34
|
k = 34
|
||||||
global i
|
global i
|
||||||
i = i+k
|
i += k
|
||||||
l = 42
|
l = 42
|
||||||
c()
|
c()
|
||||||
global j
|
global j
|
||||||
j = j+l
|
j += l
|
||||||
b()
|
b()
|
||||||
print i, j # should print 35, 49
|
print i, j # should print 35, 49
|
||||||
|
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
def f():
|
def f():
|
||||||
print x # would result in a 'NameError' or 'UnboundLocalError'
|
print x # would result in a 'NameError' or 'UnboundLocalError'
|
||||||
x = x+1
|
x += 1
|
||||||
print x
|
print x
|
||||||
|
|
||||||
raise "This program can't be run"
|
raise "This program can't be run"
|
||||||
|
@@ -28,7 +28,7 @@ else:
|
|||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
while i < 10:
|
while i < 10:
|
||||||
i = i+1
|
i += 1
|
||||||
if i == 3:
|
if i == 3:
|
||||||
continue
|
continue
|
||||||
if i == 5:
|
if i == 5:
|
||||||
@@ -40,7 +40,7 @@ print
|
|||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
while i < 10:
|
while i < 10:
|
||||||
i = i+1
|
i += 1
|
||||||
if i == 3:
|
if i == 3:
|
||||||
continue
|
continue
|
||||||
print i,
|
print i,
|
||||||
|
@@ -55,9 +55,9 @@ class DBRecIO:
|
|||||||
if self.closed:
|
if self.closed:
|
||||||
raise ValueError, "I/O operation on closed file"
|
raise ValueError, "I/O operation on closed file"
|
||||||
if mode == 1:
|
if mode == 1:
|
||||||
pos = pos + self.pos
|
pos += self.pos
|
||||||
elif mode == 2:
|
elif mode == 2:
|
||||||
pos = pos + self.len
|
pos += self.len
|
||||||
self.pos = max(0, pos)
|
self.pos = max(0, pos)
|
||||||
|
|
||||||
def tell(self):
|
def tell(self):
|
||||||
@@ -84,7 +84,7 @@ class DBRecIO:
|
|||||||
if self.closed:
|
if self.closed:
|
||||||
raise ValueError, "I/O operation on closed file"
|
raise ValueError, "I/O operation on closed file"
|
||||||
if self.buflist:
|
if self.buflist:
|
||||||
self.buf = self.buf + string.joinfields(self.buflist, '')
|
self.buf += string.joinfields(self.buflist, '')
|
||||||
self.buflist = []
|
self.buflist = []
|
||||||
i = string.find(self.buf, '\n', self.pos)
|
i = string.find(self.buf, '\n', self.pos)
|
||||||
if i < 0:
|
if i < 0:
|
||||||
|
@@ -3,7 +3,7 @@ def flatten(tup):
|
|||||||
elts = []
|
elts = []
|
||||||
for elt in tup:
|
for elt in tup:
|
||||||
if isinstance(elt, tuple):
|
if isinstance(elt, tuple):
|
||||||
elts = elts + flatten(elt)
|
elts += flatten(elt)
|
||||||
else:
|
else:
|
||||||
elts.append(elt)
|
elts.append(elt)
|
||||||
return elts
|
return elts
|
||||||
@@ -53,7 +53,7 @@ def mangle(name, klass):
|
|||||||
try:
|
try:
|
||||||
i = 0
|
i = 0
|
||||||
while klass[i] == '_':
|
while klass[i] == '_':
|
||||||
i = i + 1
|
i += 1
|
||||||
except IndexError:
|
except IndexError:
|
||||||
return name
|
return name
|
||||||
klass = klass[i:]
|
klass = klass[i:]
|
||||||
|
@@ -30,7 +30,7 @@ class SyntaxErrorChecker:
|
|||||||
self.errors = 0
|
self.errors = 0
|
||||||
|
|
||||||
def error(self, node, msg):
|
def error(self, node, msg):
|
||||||
self.errors = self.errors + 1
|
self.errors += 1
|
||||||
if self.multi is not None:
|
if self.multi is not None:
|
||||||
print "%s:%s: %s" % (node.filename, node.lineno, msg)
|
print "%s:%s: %s" % (node.filename, node.lineno, msg)
|
||||||
else:
|
else:
|
||||||
|
@@ -9,11 +9,11 @@ def normpath(comps):
|
|||||||
del comps[i]
|
del comps[i]
|
||||||
elif comps[i] == '..' and i > 0 and comps[i-1] not in ('', '..'):
|
elif comps[i] == '..' and i > 0 and comps[i-1] not in ('', '..'):
|
||||||
del comps[i-1:i+1]
|
del comps[i-1:i+1]
|
||||||
i = i - 1
|
i -= 1
|
||||||
elif comps[i] == '' and i > 0 and comps[i-1] != '':
|
elif comps[i] == '' and i > 0 and comps[i-1] != '':
|
||||||
del comps[i]
|
del comps[i]
|
||||||
else:
|
else:
|
||||||
i = i + 1
|
i += 1
|
||||||
return comps
|
return comps
|
||||||
|
|
||||||
assert normpath(['.']) == []
|
assert normpath(['.']) == []
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
# messing up control flow detection
|
# messing up control flow detection
|
||||||
def _format_usage(self, usage, actions, groups, prefix):
|
def _format_usage(self, usage, actions, groups, prefix):
|
||||||
if usage:
|
if usage:
|
||||||
usage = usage % dict(prog=self._prog)
|
usage %= dict(prog=self._prog)
|
||||||
|
|
||||||
elif usage is None:
|
elif usage is None:
|
||||||
prog = 5
|
prog = 5
|
||||||
|
Reference in New Issue
Block a user