diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-05-25 13:13:44 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-05-25 13:13:44 (GMT) |
commit | 1880d8b8231d0085700d5d3c03ee9b16c619720d (patch) | |
tree | 5ee56e8c0e04567dd7fb793a5c510007f623e3f3 /Lib/test | |
parent | 179bf213ea0432f2219c9b72ff4c4e18062fb588 (diff) | |
download | cpython-1880d8b8231d0085700d5d3c03ee9b16c619720d.zip cpython-1880d8b8231d0085700d5d3c03ee9b16c619720d.tar.gz cpython-1880d8b8231d0085700d5d3c03ee9b16c619720d.tar.bz2 |
add a SETUP_WITH opcode
It speeds up the with statement and correctly looks up the special
methods involved.
Diffstat (limited to 'Lib/test')
-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 c7989b1..627f8aa 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): |