Support chained assignment statements, e.g. a = b = c
.
We know when we have begun a chained assignment when we process a DUP_TOP with non-null on the stack. Push a NODE_CHAINSTORE onto the stack when this happens, and keep it 'floating' on top of the stack for all STORE_X operations until the stack is empty. To support versions of Python <= 2.5 which use DUP_TOP in more places, I modified ROT_TWO, ROT_THREE and ROT_FOUR to get rid of NODE_CHAINSTORE on the stack if it is present.
This commit is contained in:
39
tests/input/chain_assignment.py
Normal file
39
tests/input/chain_assignment.py
Normal file
@@ -0,0 +1,39 @@
|
||||
a = [y, z] = x = (k1, k2, k3) = [] = c = myfunc(x) + 3
|
||||
|
||||
x = y = g = {keyA: X}
|
||||
|
||||
global store_global
|
||||
Gx = Gy = Gz = Gq1
|
||||
Gx = [Gy, Gz] = Gq2
|
||||
a = b = store_global = c
|
||||
|
||||
def func_with_global():
|
||||
global Gx, Gy, Gz, Gq
|
||||
Gx = Gy = Gz = Gq
|
||||
|
||||
y = store_subscr[0] = x
|
||||
a[0] = b[x] = c[3] = D[4]
|
||||
a[0] = (b[x], c[3]) = D[4]
|
||||
a[0] = Q = [b[x], c[3]] = F = D[4]
|
||||
q = v = arr[a:b:c] = x
|
||||
|
||||
class store_attr1:
|
||||
def __init__(self, a,b,c):
|
||||
self.a = self.b = self.c = x
|
||||
self.d = y
|
||||
|
||||
class store_attr2:
|
||||
def __init__(self, a,b,c): self.a = (self.b, self.c) = x
|
||||
|
||||
a.b = c.d = e.f + g.h
|
||||
|
||||
def store_deref():
|
||||
a = I
|
||||
a = b = c = R1
|
||||
a = (b, c) = R2
|
||||
def store_fast():
|
||||
x = a
|
||||
y = b
|
||||
z = c
|
||||
p = q = r = s
|
||||
p = [q, r] = s
|
Reference in New Issue
Block a user