b45c8c17f0
Note that the check for elem!=NULL is removed for the MP_MAP_LOOKUP_ADD_IF_NOT_FOUND case because mp_map_lookup will always return non-NULL for such a case.
40 lines
619 B
Python
40 lines
619 B
Python
class C:
|
|
def f():
|
|
pass
|
|
|
|
# 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")
|
|
|
|
# try to del an attribute of a built-in class
|
|
try:
|
|
del int.to_bytes
|
|
except (AttributeError, TypeError):
|
|
# uPy raises AttributeError, CPython raises TypeError
|
|
print('AttributeError/TypeError')
|