[Python-Dev] RE: PEP 285: Adding a bool type

Martin v. Loewis martin@v.loewis.de
30 Mar 2002 12:37:42 +0100


Tim Peters <tim.one@comcast.net> writes:

> > How will bool influence '__nonzero__'? Currently, Python insists that
> > '__nonzero__ should return an int'. Will this be changed to 'should
> > return a bool'?
> 
> I hope so.
> 
> > As that would break existing code, I hope not.
> 
> No, "should" != "must".  Guido won't call code that returns an int here
> broken, although he might call it deprecated, and leave you wondering when
> the hammer will drop <wink>.

Interestingly enough, the exception message says "__nonzero__ should
return an int" but really means "__nonzero__ must return an int".  I
guess under this PEP, the message needs to be changed to "should
return a bool", but not the test (or, if you want it more explicit:
"__nonzero__ must return an int and should return a bool" :-)

Regards,
Martin