[New-bugs-announce] [issue28289] ImportError.__init__ doesn't reset not specified exception attributes

Serhiy Storchaka report at bugs.python.org
Tue Sep 27 14:02:52 EDT 2016


New submission from Serhiy Storchaka:

ImportError.__init__ sets only specified attributes ("msg", "name" or "path"), and left not explicitly specified attributes unchanged.

>>> err = ImportError('test', name='name')
>>> err.args, err.msg, err.name, err.path
(('test',), 'test', 'name', None)
>>> err.__init__(path='path')
>>> err.args, err.msg, err.name, err.path
((), 'test', 'name', 'path')

In above example err.__init__(path='path') sets attributes "args" and "path", but not "msg" and "name".

I'm not sure whether can this be considered as a bug.

----------
components: Interpreter Core
messages: 277533
nosy: brett.cannon, eric.snow, ncoghlan, serhiy.storchaka
priority: normal
severity: normal
status: open
title: ImportError.__init__ doesn't reset not specified exception attributes
versions: Python 3.5, Python 3.6, Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28289>
_______________________________________


More information about the New-bugs-announce mailing list