[ python-Bugs-1226404 ] Can't take sequence slice past 32K

SourceForge.net noreply at sourceforge.net
Thu Jun 23 19:36:29 CEST 2005


Bugs item #1226404, was opened at 2005-06-23 13:30
Message generated for change (Comment added) made by tim_one
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1226404&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.4
>Status: Open
>Resolution: None
Priority: 5
Submitted By: Gene Cash (gcash)
Assigned to: Nobody/Anonymous (nobody)
Summary: Can't take sequence slice past 32K

Initial Comment:
If you have a string/list/etc longer than 32K and you
attempt to take a slice beyond the 32K size, you get
"TypeError: indices must be integers".

For example, if x='spam'*16000, then something like
x[34000, 34100] fails, and x[y, z] also fails if
y=34000 and z=34100

It affects lists and tuples as well as strings.

This is present in 2.4 and 2.4.1, and happens on at
least the Linux and Windows platforms.

----------------------------------------------------------------------

>Comment By: Tim Peters (tim_one)
Date: 2005-06-23 13:36

Message:
Logged In: YES 
user_id=31435

Something's confused here.  x[y, z] doesn't ask for a slice, 
it's trying to index x by the two-tuple (y, z).  x[y:z] (with a 
colon) is the way to ask for a slice.  I don't have any trouble 
with slice notation regardless of how large the slice bounds 
are, but of course a sequence complains if you try to index it 
with a tuple.

>>> x = 'spam' * 16000
>>> len(x[34000:34100])   # slice notation
100
>>> len(x[34000, 34100])  # trying to index with a tuple
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: string indices must be integers

Is that all there is to this?

----------------------------------------------------------------------

Comment By: Reinhold Birkenfeld (birkenfeld)
Date: 2005-06-23 13:36

Message:
Logged In: YES 
user_id=1188172

Did you actually try this with "indices" below 32k? It won't
work there, either.

Reason: The syntax for slices is x[y:z], not x[y,z]. The
latter calls __getitem__ with the tuple (y,z) as the second
argument.

Closing as Invalid.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1226404&group_id=5470


More information about the Python-bugs-list mailing list