[Patches] [ python-Patches-723201 ] PyArg_ParseTuple problem with 'L' format

SourceForge.net noreply at sourceforge.net
Thu Mar 3 10:27:19 CET 2005


Patches item #723201, was opened at 2003-04-17 18:03
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=723201&group_id=5470

Category: Core (C code)
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Thomas Heller (theller)
Assigned to: Nobody/Anonymous (nobody)
Summary: PyArg_ParseTuple problem with 'L' format

Initial Comment:
PyArg_ParseTuple(tup, "B", &value) will raise 'Bad
Argument to internal function' if the object is not a
Python integer or long.
I believe the patch fixes the problem, but it is untested.

This problem probably exists since 2.2.

----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2005-03-03 10:27

Message:
Logged In: YES 
user_id=21627

I agree that the proposed double-type check is redundant.
OTOH, relying on the exception in the _As* function loses
information which argument specifically cannot be converted.
As a solution, I now clear the exception before invoking
converterr.

Fixed in
test_capi.py 1.8.2.1
NEWS 1.1193.2.24
getargs.c 2.102.2.1
test_capi.py 1.9
NEWS 1.1252
getargs.c 2.103


----------------------------------------------------------------------

Comment By: Michiel de Hoon (mdehoon)
Date: 2005-01-20 06:15

Message:
Logged In: YES 
user_id=488897

The PyLong_AsLongLong function (in Objects/longobject.c)
also contains a call to PyLong_Check and PyInt_Check, so I
would think that there is no need for another call to a
PyLong_Check and a PyInt_Check.
Instead, I would suggest to replace the
PyErr_BadInternalCall() (which raises the 'Bad Argument to
internal function') in PyLong_AsLongLong by

PyErr_SetString(PyExc_TypeError, "an integer is required").

This would also make it consistent with PyInt_AsLong in
Objects/intobject.c.


----------------------------------------------------------------------

Comment By: Michiel de Hoon (mdehoon)
Date: 2005-01-19 05:04

Message:
Logged In: YES 
user_id=488897

I can replicate this bug with the "L" format but not with
"B". Is the 'B' in PyArg_ParseTuple(tup, "B",
&value)  a typo?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=723201&group_id=5470


More information about the Patches mailing list