"tuple index out of range" side effect of C extension??
andymac at bullseye.apana.org.au
Thu Sep 18 15:02:54 CEST 2003
I'm seeing a bizarre situation where IndexErrors are being thrown with
"tuple index out of range" error strings.
The scenario is something like:
l = [(v1a, v1b), (v2a, v2b), ..., (vna, vnb)]
for a, b in l:
with the IndexError being thrown on the "for..." line after the last
element of l has been through the for loop.
I've also seen the same exception thrown on first access to an attribute
of a simple class.
The exception being thrown is not consistent, and reducing the number of
tuples and lists in the code seems to reduce the likelihood of the
exception being thrown.
The only thing unusual is the presence of a C extension which I am testing
- an Ingres DB interface module, most of whose functionality seems to work
when the IndexErrors don't get thrown.
Perusal of the source, while not exhaustive, hasn't turned up anything
obvious; other than the embedded SQL stuff it seems to be in tune with the
module layout in the Python docs.
The complications are:-
- I don't have MSVC, so can't build a standard Windows Python debug setup
to really look at the internals;
- I built the module with MinGW32 1.1 (gcc 2.95.3, it compiles with only
1 warning which surprised me a bit) and Python can't yet be built by
MinGW (so that I could use gdb) AFAIK.
Platform is Windows2000.
Other than the obvious sources of this exception (attempting to explicitly
access a non-existent tuple element), googling turned up a reference to
this exception being encountered with Boost.Python based extensions which
doesn't seem to help as this module is pure C.
Has anyone ever encountered this sort of bizarreness while working with a
Replies cc'ed to the reply-to address in addition to the list appreciated.
Andrew I MacIntyre "These thoughts are mine alone..."
E-mail: andymac at bullseye.apana.org.au (pref) | Snail: PO Box 370
andymac at pcug.org.au (alt) | Belconnen ACT 2616
Web: http://www.andymac.org/ | Australia
More information about the Python-list