diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-05-25 13:13:44 +0000 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-05-25 13:13:44 +0000 |
commit | b7b65919bf38f9b82f96d1b282a1bc03dfdc8241 (patch) | |
tree | 4f03eb3e61939163b95e295581a6578ea7cb3046 /Lib/test/test_descr.py | |
parent | 7f87a952a28deb142826f79f9c29a3c7bc5af704 (diff) | |
download | cpython-b7b65919bf38f9b82f96d1b282a1bc03dfdc8241.tar.gz |
add a SETUP_WITH opcode
It speeds up the with statement and correctly looks up the special
methods involved.
Diffstat (limited to 'Lib/test/test_descr.py')
-rw-r--r-- | Lib/test/test_descr.py | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index c7989b1136..627f8aa097 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -1689,6 +1689,7 @@ order (MRO) for bases """ 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 @@ order (MRO) for bases """ ("__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): |