[Patches] [ python-Patches-1600346 ] __bool__ instead of __nonzero__

SourceForge.net noreply at sourceforge.net
Wed Nov 22 19:55:13 CET 2006


Patches item #1600346, was opened at 2006-11-21 12:57
Message generated for change (Comment added) made by doerwalter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1600346&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Core (C code)
Group: Python 3000
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: ganges master (gangesmaster)
Assigned to: Nobody/Anonymous (nobody)
Summary: __bool__ instead of __nonzero__

Initial Comment:
this patch replaces __nonzero__ with __bool__, to make bool type symmetrical to all other types (__int__, __float__, etc.)

some notes:
* the latex docs have been updated
* the slot name was changed from nb_nonzero to nb_bool
* all XXX_nonzero methods where changed to XXX_bool
* all the comments relating to nb_nonzero have been updated
* stdlib was updated
* all the test suites were updated

otoh, i couldn't get it to compile (MSVC++2003), because of a strange bug in ceval.c (none of my code). seems the GETLOCAL macro causes syntactic problems, but i didn't have time to check it thoroughly.

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

>Comment By: Walter Dörwald (doerwalter)
Date: 2006-11-22 19:55

Message:
Logged In: YES 
user_id=89016
Originator: NO

bool5.patch removes the check for int for the __len__() result as this is
already done in the __len__() call itself. It adds a few tests to
test_bool.py::BoolTest.test_convert_to_bool() and fixes the description of
__bool__ in Doc/ref/ref3.tex.

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

Comment By: ganges master (gangesmaster)
Date: 2006-11-21 22:33

Message:
Logged In: YES 
user_id=1406776
Originator: YES

fixed a bug with type checking when using __len__

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

Comment By: ganges master (gangesmaster)
Date: 2006-11-21 19:28

Message:
Logged In: YES 
user_id=1406776
Originator: YES

* slot_nb_bool now requires __bool__ to return only a boolean
* tab-width issues (hopefully) fixed

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

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


More information about the Patches mailing list