add a SETUP_WITH opcode
It speeds up the with statement and correctly looks up the special
methods involved.
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index c7989b1..627f8aa 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -1689,6 +1689,7 @@
return isinstance(int, obj)
def do_issubclass(obj):
return issubclass(int, obj)
+ def swallow(*args): pass
# It would be nice to have every special method tested here, but I'm
# only listing the ones I can remember outside of typeobject.c, since it
@@ -1702,11 +1703,8 @@
("__instancecheck__", do_isinstance, return_true, set(), {}),
("__subclasscheck__", do_issubclass, return_true,
set(("__bases__",)), {}),
- # These two fail because the compiler generates LOAD_ATTR to look
- # them up. We'd have to add a new opcode to fix this, and it's
- # probably not worth it.
- # ("__enter__", run_context, iden),
- # ("__exit__", run_context, iden),
+ ("__enter__", run_context, iden, set(), {"__exit__" : swallow}),
+ ("__exit__", run_context, swallow, set(), {"__enter__" : iden}),
]
class Checker(object):