From: Serhiy Storchaka Date: Tue, 27 Sep 2016 17:51:04 +0000 (+0300) Subject: Issue #21578: Fixed misleading error message when ImportError called with X-Git-Tag: v3.6.0b2~109 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=389ef9dcdabe3ed83023ea50deff4b1cd3927dd3;p=python Issue #21578: Fixed misleading error message when ImportError called with invalid keyword args. --- 389ef9dcdabe3ed83023ea50deff4b1cd3927dd3 diff --cc Lib/test/test_exceptions.py index 458ddc1ed8,96c3a48c31..48379222c3 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@@ -1096,6 -1096,23 +1096,22 @@@ class ImportErrorTests(unittest.TestCas self.assertEqual(exc.name, 'somename') self.assertEqual(exc.path, 'somepath') + msg = "'invalid' is an invalid keyword argument for this function" + with self.assertRaisesRegex(TypeError, msg): + ImportError('test', invalid='keyword') + + with self.assertRaisesRegex(TypeError, msg): + ImportError('test', name='name', invalid='keyword') + + with self.assertRaisesRegex(TypeError, msg): + ImportError('test', path='path', invalid='keyword') + + with self.assertRaisesRegex(TypeError, msg): + ImportError(invalid='keyword') + - msg = "'invalid|another' is an invalid keyword argument for this function" + with self.assertRaisesRegex(TypeError, msg): + ImportError('test', invalid='keyword', another=True) + def test_non_str_argument(self): # Issue #15778 with check_warnings(('', BytesWarning), quiet=True): diff --cc Misc/NEWS index 7cbc98c318,b6363b65a4..67b2274958 --- a/Misc/NEWS +++ b/Misc/NEWS @@@ -10,14 -10,11 +10,17 @@@ What's New in Python 3.6.0 beta Core and Builtins ----------------- + - Issue #21578: Fixed misleading error message when ImportError called with + invalid keyword args. + -- Issue #28203: Fix incorrect type in error message from - ``complex(1.0, {2:3})``. Patch by Soumya Sharma. +- Issue #28203: Fix incorrect type in complex(1.0, {2:3}) error message. + Patch by Soumya Sharma. + +- Issue #28086: Single var-positional argument of tuple subtype was passed + unscathed to the C-defined function. Now it is converted to exact tuple. + +- Issue #28214: Now __set_name__ is looked up on the class instead of the + instance. - Issue #27955: Fallback on reading /dev/urandom device when the getrandom() syscall fails with EPERM, for example when blocked by SECCOMP.