[svn r46770] add py.builtin.GeneratorExit, to make it possible to write 2.3 and 2.4

compatible code. The exception is never raised there.

--HG--
branch : trunk
This commit is contained in:
cfbolz 2007-09-20 17:17:22 +02:00
parent 303a6e659a
commit 66f7db5894
4 changed files with 19 additions and 2 deletions

View File

@ -11,8 +11,8 @@ version = "0.9.1-alpha"
initpkg(__name__, initpkg(__name__,
description = "pylib and py.test: agile development and test support library", description = "pylib and py.test: agile development and test support library",
revision = int('$LastChangedRevision: 45649 $'.split(':')[1][:-1]), revision = int('$LastChangedRevision: 46770 $'.split(':')[1][:-1]),
lastchangedate = '$LastChangedDate: 2007-08-14 11:49:04 +0200 (Tue, 14 Aug 2007) $', lastchangedate = '$LastChangedDate: 2007-09-20 17:17:22 +0200 (Thu, 20 Sep 2007) $',
version = version, version = version,
url = "http://codespeak.net/py", url = "http://codespeak.net/py",
download_url = "XXX", # "http://codespeak.net/download/py/py-%s.tar.gz" %(version,), download_url = "XXX", # "http://codespeak.net/download/py/py-%s.tar.gz" %(version,),
@ -33,6 +33,7 @@ initpkg(__name__,
'test.exit' : ('./test/session.py', 'exit'), 'test.exit' : ('./test/session.py', 'exit'),
'test.broken' : ('./test/item.py', 'Broken'), 'test.broken' : ('./test/item.py', 'Broken'),
'test.notimplemented' : ('./test/item.py', '_NotImplemented'), 'test.notimplemented' : ('./test/item.py', '_NotImplemented'),
'test._pdb' : ('./test/custompdb.py', 'set_trace'),
# configuration/initialization related test api # configuration/initialization related test api
'test.config' : ('./test/config.py', 'config_per_process'), 'test.config' : ('./test/config.py', 'config_per_process'),
@ -92,6 +93,7 @@ initpkg(__name__,
'builtin.reversed' : ('./builtin/reversed.py', 'reversed'), 'builtin.reversed' : ('./builtin/reversed.py', 'reversed'),
'builtin.sorted' : ('./builtin/sorted.py', 'sorted'), 'builtin.sorted' : ('./builtin/sorted.py', 'sorted'),
'builtin.BaseException' : ('./builtin/exception.py', 'BaseException'), 'builtin.BaseException' : ('./builtin/exception.py', 'BaseException'),
'builtin.GeneratorExit' : ('./builtin/exception.py', 'GeneratorExit'),
'builtin.set' : ('./builtin/set.py', 'set'), 'builtin.set' : ('./builtin/set.py', 'set'),
'builtin.frozenset' : ('./builtin/set.py', 'frozenset'), 'builtin.frozenset' : ('./builtin/set.py', 'frozenset'),

View File

@ -2,3 +2,12 @@ try:
BaseException = BaseException BaseException = BaseException
except NameError: except NameError:
BaseException = Exception 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

View File

@ -11,3 +11,8 @@ def test_BaseException():
assert py.builtin.BaseException.__module__ == 'exceptions' assert py.builtin.BaseException.__module__ == 'exceptions'
assert Exception.__name__ == 'Exception' assert Exception.__name__ == 'Exception'
def test_GeneratorExit():
assert py.builtin.GeneratorExit.__module__ == 'exceptions'
assert issubclass(py.builtin.GeneratorExit, Exception)

View File

@ -5,6 +5,7 @@ import py
from py.__.test.outcome import ReprOutcome from py.__.test.outcome import ReprOutcome
from py.__.test import repevent from py.__.test import repevent
from py.__.test.outcome import Skipped from py.__.test.outcome import Skipped
from py.builtin import GeneratorExit
class MasterNode(object): class MasterNode(object):
def __init__(self, channel, reporter): def __init__(self, channel, reporter):