deleting, but not getting, slices

P

Phil Dumont

import sys'2.3.4 (#1, Feb 4 2005, 12:19:08) \n[GCC 3.2.3 20030502 (Red Hat Linux
3.2.3-42)]'


I'm implementing a type that supports a subset of the sequence
abstraction in which I want to allow the deletion of elements/slices,
but don't need/want to allow the fetching of a slice. So I filled
in the tp_as_sequence slot, filled in the sq_ass_slice slot, and
did not fill in sq_slice.

I was surprised to find that this did not work.

On further investigation, I found out that it was because in
assign_slice(), the call to PySequence_(Del|Set)Slice is inside
this test:

if (sq && sq->sq_slice && ISINT(v) && ISINT(w)) {
...

It baffles me why the test if for sq_slice, not sq_ass_slice,
when neither of PySequence_(Del|Set)Slice reference sq_slice,
but both reference sq_ass_slice.

My attempts to find an explanation in the docs/faqs/code have
been thusfar fruitless.

I'm able to work around it by defining a sq_slice that does
nothing but unconditionally raise an exception. But the check
for sq_slice in assign_slice() makes me wonder if this is the
right thing to do. (Seems ok so far.)

Any hints would be appreciated

phil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,239
Messages
2,571,200
Members
47,838
Latest member
elibuskamoSeAve

Latest Threads

Top