exceptions not present in plpy with Python 3
Hi,
there seems to be a problem in the way we add exceptions to the plpy
module in PL/Python compiled with Python 3k.
Try this: DO $$ plpy.SPIError $$ language plpython3u;
I'm not a Python 3 expert, but I nicked some code from the Internet and
came up with this patch (passes regression tests on both Python 2 and 3).
The funny thing is that it never blew up earlier, because we only used
plpy.SPIError in except: blocks that weren't even executed, as errors in
plpy.execute just terminate the function.
With my changes they turn into catchable exceptions, and so accessing
plpy.SPIError in Python 3 becomes essential.
BTW: do we have any buildfarm animal that uses Python 3?
Cheers,
Jan
Attachments:
plpython3-exceptions.difftext/x-patch; name=plpython3-exceptions.diffDownload+66-21
On 18/12/10 18:56, Jan Urbański wrote:
I'm not a Python 3 expert, but I nicked some code from the Internet and
came up with this patch (passes regression tests on both Python 2 and 3).
I tried to be too cute with the regression test, it fails with Python
2.3.7 (the latest 2.3 release).
Attached is a fixed test that should work in Pythons 2.3+
I don't want to open that can of worms just yet, but do we have any
formal policy on the oldest Python version we support? I tested on 2.3
just because looking at http://python.org/download/releases/ I saw that
2.2 was last released in 2003, so I thought 2.3 was as far as I'd go...
Cheers,
Jan
Attachments:
plpython3-exceptions-v2.difftext/x-patch; name=plpython3-exceptions-v2.diffDownload+66-21
On lör, 2010-12-18 at 18:56 +0100, Jan Urbański wrote:
there seems to be a problem in the way we add exceptions to the plpy
module in PL/Python compiled with Python 3k.Try this: DO $$ plpy.SPIError $$ language plpython3u;
I'm not a Python 3 expert, but I nicked some code from the Internet and
came up with this patch (passes regression tests on both Python 2 and 3).
It looks like the PyModule_AddObject() approach also works in Python 2.
Anyone see an issue with using that uniformly?
On tor, 2011-01-20 at 22:30 +0200, Peter Eisentraut wrote:
On lör, 2010-12-18 at 18:56 +0100, Jan Urbański wrote:
there seems to be a problem in the way we add exceptions to the plpy
module in PL/Python compiled with Python 3k.Try this: DO $$ plpy.SPIError $$ language plpython3u;
I'm not a Python 3 expert, but I nicked some code from the Internet and
came up with this patch (passes regression tests on both Python 2 and 3).It looks like the PyModule_AddObject() approach also works in Python 2.
Anyone see an issue with using that uniformly?
Committed using PyModule_AddObject.