[pypy-svn] r78150 - in pypy/branch/fast-forward: lib-python pypy/interpreter pypy/objspace/flow

trundle at codespeak.net trundle at codespeak.net
Thu Oct 21 01:44:13 CEST 2010


Author: trundle
Date: Thu Oct 21 01:44:12 2010
New Revision: 78150

Modified:
   pypy/branch/fast-forward/lib-python/TODO
   pypy/branch/fast-forward/pypy/interpreter/pyopcode.py
   pypy/branch/fast-forward/pypy/objspace/flow/objspace.py
Log:
Catching a string exception now raises a DeprecationWarning.


Modified: pypy/branch/fast-forward/lib-python/TODO
==============================================================================
--- pypy/branch/fast-forward/lib-python/TODO	(original)
+++ pypy/branch/fast-forward/lib-python/TODO	Thu Oct 21 01:44:12 2010
@@ -32,9 +32,6 @@
 - Ast objects should be picklable, see in pypy/module/_ast/test/test_ast.py:
   test_pickle()
 
-- catching a string should emit a DeprecationWarning ("catching of
-  string exceptions is deprecated")
-
 - missing builtin: memoryview
 
 Longer tasks

Modified: pypy/branch/fast-forward/pypy/interpreter/pyopcode.py
==============================================================================
--- pypy/branch/fast-forward/pypy/interpreter/pyopcode.py	(original)
+++ pypy/branch/fast-forward/pypy/interpreter/pyopcode.py	Thu Oct 21 01:44:12 2010
@@ -747,6 +747,16 @@
         return self.space.not_(self.space.is_(w_1, w_2))
 
     def cmp_exc_match(self, w_1, w_2):
+        if self.space.is_true(self.space.isinstance(w_2, self.space.w_tuple)):
+            for w_t in self.space.fixedview(w_2):
+                if self.space.is_true(self.space.isinstance(w_t,
+                                                            self.space.w_str)):
+                    self.space.warn("catching of string exceptions is "
+                                    "deprecated",
+                                    self.space.w_DeprecationWarning)
+        elif self.space.is_true(self.space.isinstance(w_2, self.space.w_str)):
+            self.space.warn("catching of string exceptions is deprecated",
+                            self.space.w_DeprecationWarning)
         return self.space.newbool(self.space.exception_match(w_1, w_2))
 
     def COMPARE_OP(self, testnum, next_instr):

Modified: pypy/branch/fast-forward/pypy/objspace/flow/objspace.py
==============================================================================
--- pypy/branch/fast-forward/pypy/objspace/flow/objspace.py	(original)
+++ pypy/branch/fast-forward/pypy/objspace/flow/objspace.py	Thu Oct 21 01:44:12 2010
@@ -77,6 +77,9 @@
         self.specialcases = {}
         #self.make_builtins()
         #self.make_sys()
+        # w_str is needed because cmp_exc_match of frames checks against it,
+        # as string exceptions are deprecated
+        self.w_str = Constant(str)
         # objects which should keep their SomeObjectness
         self.not_really_const = NOT_REALLY_CONST
 



More information about the Pypy-commit mailing list