From 3267d28f9db6f5594167f6262d8882b31542dccf Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sat, 30 Sep 2006 09:03:42 +0000 Subject: Bug #1566800: make sure that EnvironmentError can be called with any number of arguments, as was the case in Python 2.4. --- Lib/test/test_exceptions.py | 11 ++++++++--- Misc/NEWS | 3 +++ Objects/exceptions.c | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index 27d88a0..585d6fe 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -196,11 +196,16 @@ class ExceptionTests(unittest.TestCase): (SystemExit, ('foo',), {'message' : 'foo', 'args' : ('foo',), 'code' : 'foo'}), (IOError, ('foo',), - {'message' : 'foo', 'args' : ('foo',)}), + {'message' : 'foo', 'args' : ('foo',), 'filename' : None, + 'errno' : None, 'strerror' : None}), (IOError, ('foo', 'bar'), - {'message' : '', 'args' : ('foo', 'bar')}), + {'message' : '', 'args' : ('foo', 'bar'), 'filename' : None, + 'errno' : 'foo', 'strerror' : 'bar'}), (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'), {'message' : '', 'args' : ('errnoStr', 'strErrorStr'), 'strerror' : 'strErrorStr', 'errno' : 'errnoStr', diff --git a/Misc/NEWS b/Misc/NEWS index 23b9bbb..3bca93d 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,6 +12,9 @@ What's New in Python 2.6 alpha 1? 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 keyword arguments any more (previously they accepted them, but didn't use them). diff --git a/Objects/exceptions.c b/Objects/exceptions.c index bfe28a9..c0b813d 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -510,7 +510,7 @@ EnvironmentError_init(PyEnvironmentErrorObject *self, PyObject *args, if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1) return -1; - if (PyTuple_GET_SIZE(args) <= 1) { + if (PyTuple_GET_SIZE(args) <= 1 || PyTuple_GET_SIZE(args) > 3) { return 0; } -- cgit v0.12