[Checkins] SVN: zope.exceptions/branches/tseaver-no_2to3/ Removed use of '2to3' and associated fixers when installing under Py3k.

Tres Seaver cvs-admin at zope.org
Fri Apr 6 19:37:16 UTC 2012


Log message for revision 125032:
  Removed use of '2to3' and associated fixers when installing under Py3k.
  
  The code is now in a "compatible subset" which supports Python 2.6, 2.7,
  and 3.2
  
  We also now explicitly support PyPy 1.8 (the version compatible with the
  2.7 language spec).

Changed:
  U   zope.exceptions/branches/tseaver-no_2to3/CHANGES.txt
  U   zope.exceptions/branches/tseaver-no_2to3/setup.py
  U   zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/__init__.py
  U   zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/interfaces.py
  U   zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/log.py
  U   zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/tests/test_exceptionformatter.py

-=-
Modified: zope.exceptions/branches/tseaver-no_2to3/CHANGES.txt
===================================================================
--- zope.exceptions/branches/tseaver-no_2to3/CHANGES.txt	2012-04-06 19:37:08 UTC (rev 125031)
+++ zope.exceptions/branches/tseaver-no_2to3/CHANGES.txt	2012-04-06 19:37:12 UTC (rev 125032)
@@ -5,6 +5,11 @@
 4.0.0 (unreleased)
 ------------------
 
+- Removed use of '2to3' and associated fixers when installing under Py3k.
+  The code is now in a "compatible subset" which supports Python 2.6, 2.7,
+  and 3.2, including PyPy 1.8 (the version compatible with the 2.7 language
+  spec).
+
 - 100% unit test coverage.
 
 - Dropped explicit support for Python 2.4 / 2.5 / 3.1.

Modified: zope.exceptions/branches/tseaver-no_2to3/setup.py
===================================================================
--- zope.exceptions/branches/tseaver-no_2to3/setup.py	2012-04-06 19:37:08 UTC (rev 125031)
+++ zope.exceptions/branches/tseaver-no_2to3/setup.py	2012-04-06 19:37:12 UTC (rev 125032)
@@ -28,13 +28,7 @@
                       }
 }
 
-if sys.version_info >= (3, ):
-    # Python 3 support:
-    extra['use_2to3'] = True
-    extra['setup_requires'] = ['zope.fixers']
-    extra['use_2to3_fixers'] = ['zope.fixers']
 
-
 def read(*rnames):
     return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
 
@@ -57,6 +51,8 @@
           'Programming Language :: Python :: 2.7',
           'Programming Language :: Python :: 3',
           'Programming Language :: Python :: 3.2',
+          "Programming Language :: Python :: Implementation :: CPython",
+          "Programming Language :: Python :: Implementation :: PyPy",
           'Natural Language :: English',
           'Operating System :: OS Independent',
           'Topic :: Internet :: WWW/HTTP',

Modified: zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/__init__.py
===================================================================
--- zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/__init__.py	2012-04-06 19:37:08 UTC (rev 125031)
+++ zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/__init__.py	2012-04-06 19:37:12 UTC (rev 125032)
@@ -22,7 +22,7 @@
 # avoid dependency on zope.security:
 try:
     import zope.security
-except ImportError, v: #pragma NO COVER
+except ImportError as v: #pragma NO COVER
     # "ImportError: No module named security"
     if not str(v).endswith('security'):
         raise

Modified: zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/interfaces.py
===================================================================
--- zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/interfaces.py	2012-04-06 19:37:08 UTC (rev 125031)
+++ zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/interfaces.py	2012-04-06 19:37:12 UTC (rev 125032)
@@ -28,16 +28,18 @@
 effort to clearly present the information provided by the
 ITracebackSupplement.
 """
-from zope.interface import Interface, Attribute, implements
+from zope.interface import Interface
+from zope.interface import Attribute
+from zope.interface import implementer
 
 
 class IDuplicationError(Interface):
     pass
 
 
+ at implementer(IDuplicationError)
 class DuplicationError(Exception):
     """A duplicate registration was attempted"""
-    implements(IDuplicationError)
 
 
 class IUserError(Interface):
@@ -45,13 +47,13 @@
     """
 
 
+ at implementer(IUserError)
 class UserError(Exception):
     """User errors
 
     These exceptions should generally be displayed to users unless
     they are handled.
     """
-    implements(IUserError)
 
 
 class ITracebackSupplement(Interface):

Modified: zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/log.py
===================================================================
--- zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/log.py	2012-04-06 19:37:08 UTC (rev 125031)
+++ zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/log.py	2012-04-06 19:37:12 UTC (rev 125032)
@@ -15,7 +15,10 @@
 """
 
 import logging
-import cStringIO
+try:
+    from StringIO import StringIO
+except ImportError:
+    from io import StringIO
 
 from zope.exceptions.exceptionformatter import print_exception
 
@@ -27,7 +30,7 @@
 
         Uses zope.exceptions.exceptionformatter to generate the traceback.
         """
-        sio = cStringIO.StringIO()
+        sio = StringIO()
         print_exception(ei[0], ei[1], ei[2], file=sio, with_filenames=True)
         s = sio.getvalue()
         if s.endswith("\n"):

Modified: zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/tests/test_exceptionformatter.py
===================================================================
--- zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/tests/test_exceptionformatter.py	2012-04-06 19:37:08 UTC (rev 125031)
+++ zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/tests/test_exceptionformatter.py	2012-04-06 19:37:12 UTC (rev 125032)
@@ -572,13 +572,13 @@
 
     def test_multiline_exception(self):
         try:
-            exec 'syntax error\n'
+            exec('syntax error\n')
         except Exception:
             s = self._callFUT(False)
-        self.assertEqual(s.splitlines()[-3:],
-                         ['    syntax error',
-                          '               ^',
-                          'SyntaxError: invalid syntax'])
+        lines = s.splitlines()[-3:]
+        self.assertEqual(lines[0], '    syntax error')
+        self.assertTrue(lines[1].endswith('    ^')) #PyPy has a shorter prefix
+        self.assertEqual(lines[2], 'SyntaxError: invalid syntax')
 
     def test_recursion_failure(self):
         import sys
@@ -612,7 +612,10 @@
 class Test_print_exception(unittest.TestCase):
 
     def _callFUT(self, as_html=False):
-        from StringIO import StringIO
+        try:
+            from StringIO import StringIO
+        except ImportError:
+            from io import StringIO
         buf = StringIO()
         import sys
         from zope.exceptions.exceptionformatter import print_exception



More information about the checkins mailing list