[pypy-commit] pypy py3k: kill sys.exc_clear(). Also kill OperationError.clear, which seems to be no longer used anywhere else now. I hope not to be wrong :-)

antocuni noreply at buildbot.pypy.org
Wed Feb 15 16:00:26 CET 2012


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: py3k
Changeset: r52507:35c013f9b1a5
Date: 2012-02-15 15:44 +0100
http://bitbucket.org/pypy/pypy/changeset/35c013f9b1a5/

Log:	kill sys.exc_clear(). Also kill OperationError.clear, which seems to
	be no longer used anywhere else now. I hope not to be wrong :-)

diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py
--- a/pypy/interpreter/error.py
+++ b/pypy/interpreter/error.py
@@ -35,14 +35,6 @@
         if not we_are_translated():
             self.debug_excs = []
 
-    def clear(self, space):
-        # for sys.exc_clear()
-        self.w_type = space.w_None
-        self._w_value = space.w_None
-        self._application_traceback = None
-        if not we_are_translated():
-            del self.debug_excs[:]
-
     def match(self, space, w_check_class):
         "Check if this application-level exception matches 'w_check_class'."
         return space.exception_match(self.w_type, w_check_class)
diff --git a/pypy/module/sys/__init__.py b/pypy/module/sys/__init__.py
--- a/pypy/module/sys/__init__.py
+++ b/pypy/module/sys/__init__.py
@@ -47,7 +47,6 @@
         'setcheckinterval'      : 'vm.setcheckinterval', 
         'getcheckinterval'      : 'vm.getcheckinterval', 
         'exc_info'              : 'vm.exc_info', 
-        'exc_clear'             : 'vm.exc_clear', 
         'settrace'              : 'vm.settrace',
         'gettrace'              : 'vm.gettrace',
         'setprofile'            : 'vm.setprofile',
diff --git a/pypy/module/sys/test/test_sysmodule.py b/pypy/module/sys/test/test_sysmodule.py
--- a/pypy/module/sys/test/test_sysmodule.py
+++ b/pypy/module/sys/test/test_sysmodule.py
@@ -223,51 +223,6 @@
     # FIXME: testing the code for a lost or replaced excepthook in
     # Python/pythonrun.c::PyErr_PrintEx() is tricky.
 
-    def test_exc_clear(self):
-        import sys
-        raises(TypeError, sys.exc_clear, 42)
-
-        # Verify that exc_info is present and matches exc, then clear it, and
-        # check that it worked.
-        def clear_check(exc):
-            typ, value, traceback = sys.exc_info()
-            assert typ is not None
-            assert value is exc
-            assert traceback is not None
-
-            sys.exc_clear()
-
-            typ, value, traceback = sys.exc_info()
-            assert typ is None
-            assert value is None
-            assert traceback is None
-
-        def clear():
-            try:
-                raise ValueError(42)
-            except ValueError as exc:
-                clear_check(exc)
-
-        # Raise an exception and check that it can be cleared
-        clear()
-
-        # Verify that a frame currently handling an exception is
-        # unaffected by calling exc_clear in a nested frame.
-        try:
-            raise ValueError(13)
-        except ValueError as exc:
-            typ1, value1, traceback1 = sys.exc_info()
-            clear()
-            typ2, value2, traceback2 = sys.exc_info()
-
-            assert typ1 is typ2
-            assert value1 is exc
-            assert value1 is value2
-            assert traceback1 is traceback2
-
-        # Check that an exception can be cleared outside of an except block
-        clear_check(exc)
-
     def test_exit(self):
         import sys
         raises(TypeError, sys.exit, 42, 42)
diff --git a/pypy/module/sys/vm.py b/pypy/module/sys/vm.py
--- a/pypy/module/sys/vm.py
+++ b/pypy/module/sys/vm.py
@@ -96,15 +96,6 @@
         return space.newtuple([operror.w_type, operror.get_w_value(space),
                                space.wrap(operror.get_traceback())])
 
-def exc_clear(space):
-    """Clear global information on the current exception.  Subsequent calls
-to exc_info() will return (None,None,None) until another exception is
-raised and caught in the current thread or the execution stack returns to a
-frame where another exception is being handled."""
-    operror = space.getexecutioncontext().sys_exc_info()
-    if operror is not None:
-        operror.clear(space)
-
 def settrace(space, w_func):
     """Set the global debug tracing function.  It will be called on each
 function call.  See the debugger chapter in the library manual."""


More information about the pypy-commit mailing list