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.
Created on 2014年05月26日 04:31 by eric.snow, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| issue21578_v2.diff | berker.peksag, 2014年05月27日 19:09 | review | ||
| issue21578_v3.diff | berker.peksag, 2014年06月27日 23:53 | review | ||
| import_error_parse_args.patch | serhiy.storchaka, 2016年08月04日 18:53 | Use PyArg_ParseTupleAndKeywords() | review | |
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 552 | closed | dstufft, 2017年03月31日 16:36 | |
| Messages (17) | |||
|---|---|---|---|
| msg219125 - (view) | Author: Eric Snow (eric.snow) * (Python committer) | Date: 2014年05月26日 04:31 | |
>>> ImportError(spam='spam') Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: ImportError does not take keyword arguments However, it *does* take keyword arguments: >>> ImportError(name='spam', path='spam') ImportError() |
|||
| msg219148 - (view) | Author: Berker Peksag (berker.peksag) * (Python committer) | Date: 2014年05月26日 09:33 | |
Here's a patch with a simple test case. |
|||
| msg219235 - (view) | Author: Berker Peksag (berker.peksag) * (Python committer) | Date: 2014年05月27日 19:09 | |
Thanks for the review, Eric. Here's a new patch. |
|||
| msg219240 - (view) | Author: Eric Snow (eric.snow) * (Python committer) | Date: 2014年05月27日 21:16 | |
Looks good to me. Thanks for doing this. If no one objects in the meantime, I'll commit this in a few days. |
|||
| msg221640 - (view) | Author: Berker Peksag (berker.peksag) * (Python committer) | Date: 2014年06月26日 19:59 | |
Eric, do you want me to commit the patch? Should this also be committed to the 3.4 branch? |
|||
| msg221755 - (view) | Author: Berker Peksag (berker.peksag) * (Python committer) | Date: 2014年06月27日 23:53 | |
Here's a new patch which uses assertRaisesRegex instead of assertRaises. |
|||
| msg227735 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2014年09月27日 21:29 | |
The standard error message for this case is: xxx() got an unexpected keyword argument 'foo' I have no idea where that gets generated (a grep didn't teach me anything useful), but I think it would make sense to use that form for the message. I think the fix can be applied to 3.4. |
|||
| msg228527 - (view) | Author: Berker Peksag (berker.peksag) * (Python committer) | Date: 2014年10月05日 02:23 | |
Thanks for the review, David. > The standard error message for this case is: > > xxx() got an unexpected keyword argument 'foo' I found two similar messages in the codebase: * In Modules/itertoolsmodule.c: PyErr_SetString(PyExc_TypeError, "zip_longest() got an unexpected keyword argument"); * In Python/ceval.c: PyErr_Format(PyExc_TypeError, "%U() got an unexpected " "keyword argument '%S'", co->co_name, keyword); But, in ImportError case it can take more than one keyword arguments: ImportError(spam="SPAM", eggs=True) What error message should be printed for the above case? |
|||
| msg228540 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2014年10月05日 05:07 | |
Just the first unexpected keyword. That's what happens if you pass more than one unexpected keyword to a python function. |
|||
| msg271995 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2016年08月04日 18:11 | |
Assigning to Berker to apply his own patch since Eric has not gotten around to this. |
|||
| msg271996 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2016年08月04日 18:53 | |
Why not use PyArg_ParseTupleAndKeywords()? |
|||
| msg272005 - (view) | Author: Xiang Zhang (xiang.zhang) * (Python committer) | Date: 2016年08月05日 02:31 | |
I am a little uncomfortable with the empty tuple. It's only used as a placeholder for PyArg_ParseTupleAndKeywords. But this way we can achieve consistent error message. Don't know how to choose. |
|||
| msg277516 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2016年09月27日 14:03 | |
Ping. |
|||
| msg277519 - (view) | Author: Berker Peksag (berker.peksag) * (Python committer) | Date: 2016年09月27日 15:59 | |
Serhiy's patch looks good to me. It would be nice to add a test for multiple invalid keyword arguments:
with self.assertRaisesRegex(TypeError, msg):
ImportError('test', invalid='keyword', another=True)
Using empty_tuple seems reasonable to me. Brett and Eric, what do you think?
|
|||
| msg277521 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2016年09月27日 16:14 | |
Left a review, but basically LGTM. |
|||
| msg277531 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2016年09月27日 17:52 | |
New changeset 9b8f0db1944f by Serhiy Storchaka in branch '3.5': Issue #21578: Fixed misleading error message when ImportError called with https://hg.python.org/cpython/rev/9b8f0db1944f New changeset 95549f4970d0 by Serhiy Storchaka in branch '3.6': Issue #21578: Fixed misleading error message when ImportError called with https://hg.python.org/cpython/rev/95549f4970d0 New changeset 59268ac85f4e by Serhiy Storchaka in branch 'default': Issue #21578: Fixed misleading error message when ImportError called with https://hg.python.org/cpython/rev/59268ac85f4e |
|||
| msg277534 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2016年09月27日 18:03 | |
Added a test for multiple invalid keyword arguments, added braces, fixed a leak. But there is other oddity in ImportError constructor (issue28289). |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:04 | admin | set | github: 65777 |
| 2017年03月31日 16:36:11 | dstufft | set | pull_requests: + pull_request873 |
| 2016年09月27日 18:03:54 | serhiy.storchaka | set | status: open -> closed resolution: fixed messages: + msg277534 stage: patch review -> resolved |
| 2016年09月27日 17:52:20 | python-dev | set | nosy:
+ python-dev messages: + msg277531 |
| 2016年09月27日 16:14:52 | brett.cannon | set | assignee: berker.peksag -> serhiy.storchaka |
| 2016年09月27日 16:14:41 | brett.cannon | set | messages: + msg277521 |
| 2016年09月27日 15:59:18 | berker.peksag | set | messages: + msg277519 |
| 2016年09月27日 14:03:30 | serhiy.storchaka | set | messages:
+ msg277516 versions: + Python 3.7, - Python 3.4 |
| 2016年08月05日 02:31:40 | xiang.zhang | set | nosy:
+ xiang.zhang messages: + msg272005 |
| 2016年08月04日 18:53:18 | serhiy.storchaka | set | files:
+ import_error_parse_args.patch messages: + msg271996 |
| 2016年08月04日 18:40:52 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka |
| 2016年08月04日 18:11:12 | brett.cannon | set | assignee: eric.snow -> berker.peksag messages: + msg271995 |
| 2016年08月04日 17:26:40 | berker.peksag | link | issue27684 superseder |
| 2015年09月16日 17:21:23 | berker.peksag | set | stage: needs patch -> patch review versions: + Python 3.6 |
| 2015年09月16日 17:20:42 | berker.peksag | link | issue25142 superseder |
| 2014年10月05日 05:07:34 | r.david.murray | set | messages: + msg228540 |
| 2014年10月05日 02:24:00 | berker.peksag | set | messages: + msg228527 |
| 2014年09月27日 21:29:52 | r.david.murray | set | type: enhancement -> behavior stage: commit review -> needs patch messages: + msg227735 versions: + Python 3.4 |
| 2014年07月05日 18:28:47 | berker.peksag | set | versions: - Python 3.4 |
| 2014年06月27日 23:54:01 | berker.peksag | set | files: - issue21578.diff |
| 2014年06月27日 23:53:53 | berker.peksag | set | files:
+ issue21578_v3.diff messages: + msg221755 |
| 2014年06月26日 19:59:05 | berker.peksag | set | nosy:
+ r.david.murray messages: + msg221640 |
| 2014年05月27日 21:16:49 | eric.snow | set | assignee: eric.snow messages: + msg219240 stage: patch review -> commit review |
| 2014年05月27日 19:09:11 | berker.peksag | set | files:
+ issue21578_v2.diff messages: + msg219235 |
| 2014年05月26日 09:33:05 | berker.peksag | set | files:
+ issue21578.diff nosy: + berker.peksag messages: + msg219148 keywords: + patch stage: needs patch -> patch review |
| 2014年05月26日 04:31:35 | eric.snow | create | |