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: __nonzero__ being improperly called
Type: Stage:
Components: Interpreter Core Versions: Python 2.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: gvanrossum, loewis, loth
Priority: normal Keywords: patch

Created on 2002-03-10 08:16 by loth, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
typeobject.patch.nonzero loth, 2002-03-10 08:16 Patches as described (diff -Naur old new)
Messages (3)
msg39217 - (view) Author: Burton Radons (loth) Date: 2002-03-10 08:16
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.
msg39218 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-03-10 12:46
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.
msg39219 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-03-10 14:11
Logged In: YES 
user_id=6380

Thanks! Fixed in CVS, using Martin's approach.
History
Date User Action Args
2022-04-10 16:05:05adminsetgithub: 36235
2002-03-10 08:16:00lothcreate