[issue26653] bisect raises a TypeError when hi is None

2016-03-30 Thread Mike Lenzen

Mike Lenzen added the comment:

Sounds good, but then I think the docs could be clearer about this. I scratched 
my head at the function signature bisect.bisect_left(a, x, lo=0, hi=len(a)) 
because it isn't valid (in Python, maybe in C?), so I checked the source and 
saw hi=None. I'm not sure how to concisely describe it though. Listing two 
signatures doesn't seem ideal.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26653] bisect raises a TypeError when hi is None

2016-03-30 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
resolution:  -> not a bug
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26653] bisect raises a TypeError when hi is None

2016-03-28 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Sorry, I don't think that is a good idea.  The use of None as a placeholder for 
optional arguments is legitimate and well enshrined in Python history.  The 
code is bisect is very old, stable, and battle-tested.  There isn't a real bug 
here, nothing is broken; instead, we have a near pedantic notion that the 
C-version must be forced to replicate a minor and irrelevant implementation 
detail of the Python version that goes beyond what the docs guarantee.  I 
recommend closing this as "not a bug".

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26653] bisect raises a TypeError when hi is None

2016-03-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

May be change the placeholder? For example to sys.maxsize, float('inf') or 
['len(a)'].

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26653] bisect raises a TypeError when hi is None

2016-03-28 Thread Raymond Hettinger

Raymond Hettinger added the comment:

The pure python code used None as a placeholder for an optional argument.  It 
is not an intended input value.  The documented signature
is:  bisect.bisect_left(a, x, lo=0, hi=len(a)).

--
priority: normal -> low

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26653] bisect raises a TypeError when hi is None

2016-03-28 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee:  -> rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26653] bisect raises a TypeError when hi is None

2016-03-27 Thread Xiang Zhang

Xiang Zhang added the comment:

The C version bisect_right can only accept number as hi, which conflicts with 
the python version using None as the default value.

--
nosy: +xiang.zhang

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26653] bisect raises a TypeError when hi is None

2016-03-27 Thread Mike Lenzen

New submission from Mike Lenzen:

>>> bisect.bisect([1, 2, 3], 1, hi=None)
TypeError: 'NoneType' object cannot be interpreted as an integer

I'm assuming this is an error in the C implementation because the Python source 
has:

if hi is None:
hi = len(a)

--
components: Library (Lib)
messages: 262551
nosy: Mike Lenzen, rhettinger
priority: normal
severity: normal
status: open
title: bisect raises a TypeError when hi is None
type: behavior
versions: Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com