On Tue, 26 Oct 2021, Christopher Barker wrote:

It's not actually documented that None indicates "use the default".
Which, it turns out is because it doesn't :-)
In [24]: bisect.bisect([1,3,4,6,8,9], 5, hi=None)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-24-65fd10e3a3b5> in <module>
----> 1 bisect.bisect([1,3,4,6,8,9], 5, hi=None)

TypeError: 'NoneType' object cannot be interpreted as an integer

I guess that's because in C there is a way to define optional other than using a
sentinel? or it's using an undocumented sentinal?

Note: that's python 3.8 -- I can't imagine anything;s changed, but ...

It seems to have changed. I can reproduce the error in CPython 3.8, but the same code words in CPython 3.9 and 3.10 (all using the C version of the module, though there's also a Python version of the module that probably always supported hi=None). I think it's the result of this commit:

https://github.com/python/cpython/commit/3a855b26aed02abf87fc1163ad0d564dc3da1ea3#diff-02d3dd896d6d030e5c6c3e0961f9a4760a37b50bb05a2d89e4ab627a8f1a7b9f

On the plus side, this probably means that there aren't many people using the hi=None API. :-) So it might be safe to change to a late-bound default.

Erik
--
Erik Demaine  |  edema...@mit.edu  |  http://erikdemaine.org/
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/PXBXUWQPX4ZGOVGMPCV2ITNAPG5KEUTW/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to