[issue37980] regression when passing numpy bools to sorted(..., reverse=r)
lizardlizard
report at bugs.python.org
Tue Aug 25 20:13:06 EDT 2020
lizardlizard <nomadiclizard at gmail.com> added the comment:
I found this bug searching after noticing weird behaviour in an error message saying sorted expects the reverse flag to be an integer, after it rejected None. This is very surprising. Why isn't it just casting the reverse parameter using bool() to discover it's truthyness?
In [1]: bool(None)
Out[1]: False
In [2]: sorted(['a','c','b'], reverse=None)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-2-45ce9ce13044> in <module>()
----> 1 sorted(['a','c','b'], reverse=None)
TypeError: an integer is required (got type NoneType)
----------
nosy: +lizardlizard
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37980>
_______________________________________
More information about the Python-bugs-list
mailing list