[Python-checkins] r56179 - in sandbox/trunk/2to3: README fixes/fix_sysexcattrs.py fixes/fix_sysexcinfo.py tests/test_fixers.py

collin.winter python-checkins at python.org
Fri Jul 6 15:30:54 CEST 2007


Author: collin.winter
Date: Fri Jul  6 15:30:53 2007
New Revision: 56179

Added:
   sandbox/trunk/2to3/fixes/fix_sysexcattrs.py
      - copied, changed from r56177, sandbox/trunk/2to3/fixes/fix_sysexcinfo.py
Removed:
   sandbox/trunk/2to3/fixes/fix_sysexcinfo.py
Modified:
   sandbox/trunk/2to3/README
   sandbox/trunk/2to3/tests/test_fixers.py
Log:
Rename the sysexcinfo fixer to fix_sysexcattrs to reflect that it no longer warns on sys.exc_info() (per PEP 3100).

Modified: sandbox/trunk/2to3/README
==============================================================================
--- sandbox/trunk/2to3/README	(original)
+++ sandbox/trunk/2to3/README	Fri Jul  6 15:30:53 2007
@@ -64,7 +64,7 @@
 
 * **fix_repr** - swap backticks for repr() calls.
 
-* **fix_sysexcinfo** - warn on usage of sys.value, sys.type and
+* **fix_sysexcattrs** - warn on usage of sys.value, sys.type and
   sys.traceback.
 
 * **fix_throw** - fix generator.throw() calls to be 3.0-compliant (PEP 3109).

Copied: sandbox/trunk/2to3/fixes/fix_sysexcattrs.py (from r56177, sandbox/trunk/2to3/fixes/fix_sysexcinfo.py)
==============================================================================
--- sandbox/trunk/2to3/fixes/fix_sysexcinfo.py	(original)
+++ sandbox/trunk/2to3/fixes/fix_sysexcattrs.py	Fri Jul  6 15:30:53 2007
@@ -1,4 +1,4 @@
-"""Fixer/warner for sys.exc_{info,value,type,traceback}"""
+"""Fixer/warner for sys.exc_{value,type,traceback}"""
 # Author: Collin Winter
 
 # Local imports
@@ -6,24 +6,13 @@
 from fixes import basefix
 
 
-class FixSysexcinfo(basefix.BaseFix):
+class FixSysexcattrs(basefix.BaseFix):
 
     PATTERN = """
-    power< 'sys' trailer< '.' attr='exc_info'> any* >
-    |
     power< 'sys'
-           trailer< '.' attr=('exc_value' | 'exc_traceback' | 'exc_type')>
+           trailer< '.' ('exc_value' | 'exc_traceback' | 'exc_type')>
            any* >
     """
 
     def transform(self, node):
-        results = self.match(node)
-        assert results
-        attr = results['attr']
-
-        if isinstance(attr, Leaf) and attr.value == 'exc_info':
-            self.cannot_convert(node,
-                                "This function is going away in Python 3")
-        else:
-            self.cannot_convert(node,
-                                "This attribute is going away in Python 3")
+        self.cannot_convert(node, "This attribute is going away in Python 3")

Deleted: /sandbox/trunk/2to3/fixes/fix_sysexcinfo.py
==============================================================================
--- /sandbox/trunk/2to3/fixes/fix_sysexcinfo.py	Fri Jul  6 15:30:53 2007
+++ (empty file)
@@ -1,29 +0,0 @@
-"""Fixer/warner for sys.exc_{info,value,type,traceback}"""
-# Author: Collin Winter
-
-# Local imports
-from pytree import Leaf
-from fixes import basefix
-
-
-class FixSysexcinfo(basefix.BaseFix):
-
-    PATTERN = """
-    power< 'sys' trailer< '.' attr='exc_info'> any* >
-    |
-    power< 'sys'
-           trailer< '.' attr=('exc_value' | 'exc_traceback' | 'exc_type')>
-           any* >
-    """
-
-    def transform(self, node):
-        results = self.match(node)
-        assert results
-        attr = results['attr']
-
-        if isinstance(attr, Leaf) and attr.value == 'exc_info':
-            self.cannot_convert(node,
-                                "This function is going away in Python 3")
-        else:
-            self.cannot_convert(node,
-                                "This attribute is going away in Python 3")

Modified: sandbox/trunk/2to3/tests/test_fixers.py
==============================================================================
--- sandbox/trunk/2to3/tests/test_fixers.py	(original)
+++ sandbox/trunk/2to3/tests/test_fixers.py	Fri Jul  6 15:30:53 2007
@@ -877,25 +877,19 @@
         self.check(b, a)
 
 
-class Test_sysexcinfo(FixerTestCase):
-    fixer = "sysexcinfo"
+class Test_sysexcattrs(FixerTestCase):
+    fixer = "sysexcattrs"
 
     def test_1(self):
-        s = """sys.exc_info()"""
-        self.warns(s, s, "This function is going away")
+        s = """f = sys.exc_type"""
+        self.warns(s, s, "This attribute is going away")
 
     def test_2(self):
-        s = """if sys.exc_info()[1] == 1:
-                    pass"""
-
-        self.warns(s, s, "This function is going away")
+        s = """f = sys.exc_value"""
+        self.warns(s, s, "This attribute is going away")
 
     def test_3(self):
-        s = """f = sys.exc_info"""
-        self.warns(s, s, "This function is going away")
-
-    def test_4(self):
-        s = """f = sys.exc_type + ":" + sys.exc_value"""
+        s = """f = sys.exc_traceback"""
         self.warns(s, s, "This attribute is going away")
 
 


More information about the Python-checkins mailing list