[Python-Dev] Iterating generator from C (PostgreSQL's pl/python RETUN SETOF/RECORD iterator support broken on RedHat buggy libs)

Hannu Krosing hannu at tm.ee
Sat May 20 18:53:56 CEST 2006


I try to move this to -dev as I hope there more people reading it who
are competent in internal working :). So please replay to -dev only.

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

The question is about use of generators in embedde v2.4 with asserts
enabled.

Can somebody explain, why the code in try2.c works with wrappers 2 and 3
but crashes on buggy exception for all others, that is pure generator
and wrappers 1,4,5 ?

In other words, what does [i in i for gen] do differently than other
ways of iterating over gen, which helps it to avoid the assert, and
also, how could I write something that is still a generator, but does
not trigger the assert.

While the right solution is to just fix python (which is done for v2.5)
we need a workaround for the following reason

We have added support for returning rows (as tuples and or dictionaries
or classes) and sets of boths scalars and rows to PostgreSQL's
pl/plpython embedded language, but have some objections to getting this
into distribution, because there is a bug in python 2.4 doing a wrong
assert and additional bug in how RedHat rpm build process which leaves
the buggy asserts in python.so.

So I hoped to write a simple wrapper class, but it only seems to work,
when the generator is turned into list, which is not a good solution as
it works directly against what generators are good for.

-- 
----------------
Hannu Krosing
Database Architect
Skype Technologies OÜ
Akadeemia tee 21 F, Tallinn, 12618, Estonia

Skype me:  callto:hkrosing
Get Skype for free:  http://www.skype.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: try2.c
Type: text/x-csrc
Size: 1998 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-dev/attachments/20060520/7ab05f48/attachment.c 


More information about the Python-Dev mailing list