This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: String methods don't support explicit None arguments
Type: enhancement Stage:
Components: Interpreter Core Versions: Python 2.6
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ncoghlan
Priority: normal Keywords:

Created on 2006-08-25 11:39 by ncoghlan, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg29684 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2006-08-25 11:39
Unlike normal slicing, string methods do not currently
support passing an explicit None argument (you either
have to omit the arguments, or pass an actual integer
or object with an __index__ method).

This was the case in previous Python versions, so no
existing code is going to break.

However these methods issue the same TypeError message
as normal slicing which now explicitly lists None as an
acceptable value, which is confusing as all heck when
the call that breaks is "s.index(sub, start, stop)"m
and printing out start and stop shows them both to be None.

Given that the string docs say things like (from
str.count) "Optional arguments start and end are
interpreted as in slice notation", I think this should
be fixed (which is why I put it on the bug tracker for
2.5, not the RFE one for 2.6).
msg58122 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2007-12-03 13:15
This has been implemented for 2.6
Date User Action Args
2022-04-11 14:56:19adminsetgithub: 43898
2007-12-03 13:15:18ncoghlansetstatus: open -> closed
versions: + Python 2.6, - Python 2.5
type: enhancement
messages: + msg58122
priority: high -> normal
resolution: later -> fixed
2006-08-25 11:39:10ncoghlancreate