mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #28289: ImportError.__init__ now resets not specified attributes.
This commit is contained in:
parent
2e8c939e3d
commit
e9e44484a5
3 changed files with 23 additions and 9 deletions
|
@ -1112,6 +1112,20 @@ class ImportErrorTests(unittest.TestCase):
|
|||
with self.assertRaisesRegex(TypeError, msg):
|
||||
ImportError('test', invalid='keyword', another=True)
|
||||
|
||||
def test_reset_attributes(self):
|
||||
exc = ImportError('test', name='name', path='path')
|
||||
self.assertEqual(exc.args, ('test',))
|
||||
self.assertEqual(exc.msg, 'test')
|
||||
self.assertEqual(exc.name, 'name')
|
||||
self.assertEqual(exc.path, 'path')
|
||||
|
||||
# Reset not specified attributes
|
||||
exc.__init__()
|
||||
self.assertEqual(exc.args, ())
|
||||
self.assertEqual(exc.msg, None)
|
||||
self.assertEqual(exc.name, None)
|
||||
self.assertEqual(exc.path, None)
|
||||
|
||||
def test_non_str_argument(self):
|
||||
# Issue #15778
|
||||
with check_warnings(('', BytesWarning), quiet=True):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue