[py-svn] r46770 - in py/trunk/py: . builtin builtin/testing test/rsession

cfbolz at codespeak.net cfbolz at codespeak.net
Thu Sep 20 17:17:23 CEST 2007


Author: cfbolz
Date: Thu Sep 20 17:17:22 2007
New Revision: 46770

Modified:
   py/trunk/py/__init__.py
   py/trunk/py/builtin/exception.py
   py/trunk/py/builtin/testing/test_exception.py
   py/trunk/py/test/rsession/master.py
Log:
add py.builtin.GeneratorExit, to make it possible to write 2.3 and 2.4
compatible code. The exception is never raised there.


Modified: py/trunk/py/__init__.py
==============================================================================
--- py/trunk/py/__init__.py	(original)
+++ py/trunk/py/__init__.py	Thu Sep 20 17:17:22 2007
@@ -33,6 +33,7 @@
     'test.exit'              : ('./test/session.py', 'exit'),
     'test.broken'            : ('./test/item.py', 'Broken'),
     'test.notimplemented'    : ('./test/item.py', '_NotImplemented'),
+    'test._pdb'              : ('./test/custompdb.py', 'set_trace'),
 
     # configuration/initialization related test api
     'test.config'            : ('./test/config.py', 'config_per_process'),
@@ -92,6 +93,7 @@
     'builtin.reversed'       : ('./builtin/reversed.py',  'reversed'),
     'builtin.sorted'         : ('./builtin/sorted.py',    'sorted'),
     'builtin.BaseException'  : ('./builtin/exception.py', 'BaseException'),
+    'builtin.GeneratorExit'  : ('./builtin/exception.py', 'GeneratorExit'),
     'builtin.set'            : ('./builtin/set.py',       'set'),
     'builtin.frozenset'      : ('./builtin/set.py',       'frozenset'),
 

Modified: py/trunk/py/builtin/exception.py
==============================================================================
--- py/trunk/py/builtin/exception.py	(original)
+++ py/trunk/py/builtin/exception.py	Thu Sep 20 17:17:22 2007
@@ -2,3 +2,12 @@
     BaseException = BaseException
 except NameError:
     BaseException = Exception
+
+try:
+    GeneratorExit = GeneratorExit
+except NameError:
+    class GeneratorExit(Exception):
+        """ This exception is never raised, it is there to make it possible to
+        write code compatible with CPython 2.5 even in lower CPython
+        versions."""
+        pass

Modified: py/trunk/py/builtin/testing/test_exception.py
==============================================================================
--- py/trunk/py/builtin/testing/test_exception.py	(original)
+++ py/trunk/py/builtin/testing/test_exception.py	Thu Sep 20 17:17:22 2007
@@ -11,3 +11,8 @@
 
     assert py.builtin.BaseException.__module__ == 'exceptions'
     assert Exception.__name__ == 'Exception'
+
+
+def test_GeneratorExit():
+    assert py.builtin.GeneratorExit.__module__ == 'exceptions'
+    assert issubclass(py.builtin.GeneratorExit, Exception)

Modified: py/trunk/py/test/rsession/master.py
==============================================================================
--- py/trunk/py/test/rsession/master.py	(original)
+++ py/trunk/py/test/rsession/master.py	Thu Sep 20 17:17:22 2007
@@ -5,6 +5,7 @@
 from py.__.test.outcome import ReprOutcome
 from py.__.test import repevent
 from py.__.test.outcome import Skipped
+from py.builtin import GeneratorExit
 
 class MasterNode(object):
     def __init__(self, channel, reporter):


More information about the py-svn mailing list