[Patches] [ python-Patches-528038 ] __nonzero__ being improperly called

noreply@sourceforge.net noreply@sourceforge.net
Sun, 10 Mar 2002 06:28:07 -0800


Patches item #528038, was opened at 2002-03-10 03:16
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=528038&group_id=5470

Category: Core (C code)
Group: Python 2.2.x
Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Burton Radons (loth)
Assigned to: Guido van Rossum (gvanrossum)
Summary: __nonzero__ being improperly called

Initial Comment:
As noted in Bug #527816, if you call the __nonzero__
method of a builtin type directly it will SIGSEGV you.
 The reason is that internally the nonzero slot is
being called with "PyObject *(*) (PyObject *)" casting,
rather than the actual "int (*) (PyObject *)".  This
small patch adds a new static function that's just a
copy of wrap_hashfunc and gets it called properly later on.

If this isn't how we want bugfixes handled, please
advise and I'll revise.

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

Comment By: Guido van Rossum (gvanrossum)
Date: 2002-03-10 09:11

Message:
Logged In: YES 
user_id=6380

Thanks! Fixed in CVS, using Martin's approach.

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

Comment By: Martin v. Löwis (loewis)
Date: 2002-03-10 07:46

Message:
Logged In: YES 
user_id=21627

The patch looks good. However, wouldn't it be simpler to use
wrap_inquiry instead? (esp. since nb_nonzero is defined as
inquiryfunc).

Also, a test case (perhaps inside test_descr) which
currently crashes but succeeds under your patch would be
appreciated.

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

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