Terry J. Reedy <tjre...@udel.edu> added the comment:

Not a bug.  Both function docs say "reverse is a boolean value."
https://docs.python.org/3/library/stdtypes.html#boolean-values
says "Boolean values are the two constant objects False and True."  These 
should be used in new code.

For compatibility with old code, CPython generally allows 0 and 1.  In this 
case, it allows any 'integral value', but I would not necessarily expect this 
of other implementations.

[In general, the *Python language* docs do not document extra latitude allowed 
by the *CPython implementation*.  So the lack thereof here is also not a bug.]

All objects without fancy trickery have a __bool__ method, either inherited 
from *object* or overridden.  This in no way makes all such objects, including 
Xs, into boolean values.

----------
nosy: +terry.reedy
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed
title: sorted() and list.sort() don't accept non-boolean objects with 
__bool__() as `reverse` parameter -> sorted, list.sort reject non-boolean 
objects with __bool__() as `reverse` parameter

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37427>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to