
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/3a855b26aed02abf87fc1163ad0d564dc3d... 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 | edemaine@mit.edu | http://erikdemaine.org/