]> granicus.if.org Git - python/commitdiff
Issue #21578: Fixed misleading error message when ImportError called with
authorSerhiy Storchaka <storchaka@gmail.com>
Tue, 27 Sep 2016 17:51:04 +0000 (20:51 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Tue, 27 Sep 2016 17:51:04 +0000 (20:51 +0300)
invalid keyword args.

1  2 
Lib/test/test_exceptions.py
Misc/NEWS
Objects/exceptions.c

index 458ddc1ed82f901a852197e21e16bf7b22a668c1,96c3a48c317eb71c023192427a8e6f472559187f..48379222c3765920fbe727cdb8683077c1955655
@@@ -1096,6 -1096,23 +1096,22 @@@ class ImportErrorTests(unittest.TestCas
          self.assertEqual(exc.name, 'somename')
          self.assertEqual(exc.path, 'somepath')
  
 -        msg = "'invalid|another' is an invalid keyword argument for this function"
+         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')
+         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 7cbc98c318b8d5b3ffac9a61aebef62465bc03ce,b6363b65a4122c8c48043f02013f9742a4312461..67b2274958f0031f27d7cac3bf6cd5acc54c5ef7
+++ b/Misc/NEWS
@@@ -10,14 -10,11 +10,17 @@@ What's New in Python 3.6.0 beta 
  Core and Builtins
  -----------------
  
 -- Issue #28203: Fix incorrect type in error message from
 -  ``complex(1.0, {2:3})``. Patch by Soumya Sharma.
+ - Issue #21578: Fixed misleading error message when ImportError called with
+   invalid keyword args.
 +- 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.
Simple merge