Bug #1566800: make sure that EnvironmentError can be called with any

number of arguments, as was the case in Python 2.4.
This commit is contained in:
Georg Brandl 2006-09-30 09:03:42 +00:00
parent 5d59c09834
commit 3267d28f9d
3 changed files with 12 additions and 4 deletions

View File

@ -196,11 +196,16 @@ class ExceptionTests(unittest.TestCase):
(SystemExit, ('foo',), (SystemExit, ('foo',),
{'message' : 'foo', 'args' : ('foo',), 'code' : 'foo'}), {'message' : 'foo', 'args' : ('foo',), 'code' : 'foo'}),
(IOError, ('foo',), (IOError, ('foo',),
{'message' : 'foo', 'args' : ('foo',)}), {'message' : 'foo', 'args' : ('foo',), 'filename' : None,
'errno' : None, 'strerror' : None}),
(IOError, ('foo', 'bar'), (IOError, ('foo', 'bar'),
{'message' : '', 'args' : ('foo', 'bar')}), {'message' : '', 'args' : ('foo', 'bar'), 'filename' : None,
'errno' : 'foo', 'strerror' : 'bar'}),
(IOError, ('foo', 'bar', 'baz'), (IOError, ('foo', 'bar', 'baz'),
{'message' : '', 'args' : ('foo', 'bar')}), {'message' : '', 'args' : ('foo', 'bar'), 'filename' : 'baz',
'errno' : 'foo', 'strerror' : 'bar'}),
(IOError, ('foo', 'bar', 'baz', 'quux'),
{'message' : '', 'args' : ('foo', 'bar', 'baz', 'quux')}),
(EnvironmentError, ('errnoStr', 'strErrorStr', 'filenameStr'), (EnvironmentError, ('errnoStr', 'strErrorStr', 'filenameStr'),
{'message' : '', 'args' : ('errnoStr', 'strErrorStr'), {'message' : '', 'args' : ('errnoStr', 'strErrorStr'),
'strerror' : 'strErrorStr', 'errno' : 'errnoStr', 'strerror' : 'strErrorStr', 'errno' : 'errnoStr',

View File

@ -12,6 +12,9 @@ What's New in Python 2.6 alpha 1?
Core and builtins Core and builtins
----------------- -----------------
- Bug #1566800: make sure that EnvironmentError can be called with any
number of arguments, as was the case in Python 2.4.
- Patch #1567691: super() and new.instancemethod() now don't accept - Patch #1567691: super() and new.instancemethod() now don't accept
keyword arguments any more (previously they accepted them, but didn't keyword arguments any more (previously they accepted them, but didn't
use them). use them).

View File

@ -510,7 +510,7 @@ EnvironmentError_init(PyEnvironmentErrorObject *self, PyObject *args,
if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1) if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1)
return -1; return -1;
if (PyTuple_GET_SIZE(args) <= 1) { if (PyTuple_GET_SIZE(args) <= 1 || PyTuple_GET_SIZE(args) > 3) {
return 0; return 0;
} }