Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 02:20 AM
Phil Dumont
Guest
 
Posts: n/a
Default deleting, but not getting, slices

>>> import sys[color=blue][color=green][color=darkred]
>>> sys.version[/color][/color][/color]
'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


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles