This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Misleading error when initing ImportError
Type: enhancement Stage: resolved
Components: Interpreter Core Versions: Python 3.6, Python 3.4, Python 3.5
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Misleading error message when ImportError called with invalid keyword args
View: 21578
Assigned To: Nosy List: Sebastian Kreft, berker.peksag, brett.cannon
Priority: normal Keywords:

Created on 2015-09-16 14:48 by Sebastian Kreft, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg250850 - (view) Author: Sebastian Kreft (Sebastian Kreft) Date: 2015-09-16 14:48
ImportError now supports the keyword arguments name and path. However, when passing invalid keyword arguments, the reported error is misleading, as shown below.

In [1]: ImportError('lib', name='lib')
Out[1]: ImportError('lib')

In [2]: ImportError('lib', name='lib', foo='foo')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-5af12651187f> in <module>()
----> 1 ImportError('lib', name='lib', foo='foo')

TypeError: ImportError does not take keyword arguments
msg250854 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2015-09-16 16:34
I bet it's because of https://hg.python.org/cpython/file/tip/Objects/exceptions.c#l64 which is called by https://hg.python.org/cpython/file/tip/Objects/exceptions.c#l643 .
msg250856 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2015-09-16 17:20
Thanks for the report. This is a duplicate of issue 21578.
History
Date User Action Args
2022-04-11 14:58:21adminsetgithub: 69329
2015-09-16 17:20:42berker.peksagsetstatus: open -> closed

superseder: Misleading error message when ImportError called with invalid keyword args

nosy: + berker.peksag
messages: + msg250856
resolution: duplicate
stage: resolved
2015-09-16 16:34:35brett.cannonsetnosy: + brett.cannon
messages: + msg250854

components: + Interpreter Core
type: enhancement
2015-09-16 14:48:47Sebastian Kreftcreate