py: Remove DELETE_SUBSCR opcode, combine with STORE_SUBSCR.

This makes the runtime and object APIs more consistent.  mp_store_subscr
functionality now moved into objects (ie list and dict store_item).
This commit is contained in:
Damien George
2014-04-08 21:32:29 +01:00
parent 4671392d90
commit f4c9b33abf
12 changed files with 107 additions and 40 deletions

28
tests/basics/del-attr.py Normal file
View File

@@ -0,0 +1,28 @@
# del a class attribute
del C.f
try:
print(C.x)
except AttributeError:
print("AttributeError")
try:
del C.f
except AttributeError:
print("AttributeError")
# del an instance attribute
c = C()
c.x = 1
print(c.x)
del c.x
try:
print(c.x)
except AttributeError:
print("AttributeError")
try:
del c.x
except AttributeError:
print("AttributeError")

18
tests/basics/del-name.py Normal file
View File

@@ -0,0 +1,18 @@
# del global
x = 1
print(x)
del x
try:
print(x)
except NameError:
print("NameError")
try:
del x
except: # NameError:
# FIXME uPy returns KeyError for this
print("NameError")
class C:
def f():
pass

View File

@@ -0,0 +1,13 @@
l = [1, 2, 3]
print(l)
del l[0]
print(l)
del l[-1]
print(l)
d = {1:2, 3:4, 5:6}
del d[1]
del d[3]
print(d)
del d[5]
print(d)