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: PyArg_ParseTuple: wrong use of seterror() clips helpful type error annotation
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, georg.brandl, pitrou, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2013-10-13 21:08 by georg.brandl, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
seterror_fix.patch georg.brandl, 2013-10-13 21:08 review
seterror_fix_2.patch georg.brandl, 2013-10-14 15:59 review
Messages (4)
msg199804 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2013-10-13 21:08
Follow-up to #6624. This issue changed a call to seterror() whose last argument is supposed to be NULL or a "custom error message" given by the ";message" format character.  This had two effects:

* the custom message (if present) is never printed
* the helpful "function() argument X " is omitted and only "must be str, not int" remains

>>> format(None, 1)     # current behavior
TypeError: must be str, not int
>>> format(None, 1)     # with #6624 reverted (= patch to this issue applied)
TypeError: format() argument 2 must be str, not int



Almost all uses of the ";" format code are currently broken: the strings must give a complete message, but only give a description of the expected arguments.  Most of them should probably just be removed.
msg199877 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-10-14 12:06
The original commit doesn't contain any tests, so you should add some to be sure there's no regression in both directions (i.e. no regression for issue #6624 and for this issue):
http://hg.python.org/cpython/rev/83b46a5988b0/
msg199915 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2013-10-14 15:59
Issue #6624 wasn't an issue, it should have been "closed-invalid" :)

But you're right, a test case is needed, see new patch.
msg265064 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-05-07 12:56
Error message was fixed in issue26198.

>>> format(None, 1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: format() argument 2 must be str, not int
History
Date User Action Args
2022-04-11 14:57:51adminsetgithub: 63452
2017-03-07 18:59:19serhiy.storchakasetstatus: pending -> closed
resolution: out of date
stage: patch review -> resolved
2016-05-16 08:09:39serhiy.storchakasetstatus: open -> pending
2016-05-07 12:56:22serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg265064
2013-10-14 15:59:35georg.brandlsetfiles: + seterror_fix_2.patch

messages: + msg199915
2013-10-14 12:06:18pitrousetmessages: + msg199877
2013-10-13 21:08:13georg.brandlcreate