[Pyrex] Exception issues with Python 2.5
Francesc Altet
faltet at carabos.com
Thu Jul 13 12:41:18 UTC 2006
A Dijous 13 Juliol 2006 14:13, Francesc Altet va escriure:
> Hi,
>
> I'm having problems with a Pyrex extension that runs flawlessly in python
> 2.3 and 2.4 but fails running Python 2.5. The affected piece of code is an
> iterator made with Pyrex and it fails when it raises the StopIterator:
>
> ---------------------------------------------------------------------------
>------------------- Traceback (most recent call last):
> [snip]
> File
> "/home/faltet/PyTables/pytables/branches/professional/tables/File.py", line
> 1494, in enableUndo
> for row in self._actionlog:
> File "TableExtension.pyx", line 761, in TableExtension.Row.__next__
> File "TableExtension.pyx", line 1087, in
> TableExtension.Row.__next__general File "TableExtension.pyx", line 1095, in
> TableExtension.Row.finish_riterator TypeError: exceptions must be strings,
> classes, or instances, not type
> ---------------------------------------------------------------------------
>--------------------
>
> I think the error is probably due to the fact that exceptions are new-style
> classes from Python 2.5 on and Pyrex is too strict in allowing objects that
> may act as exceptions, hence the error.
As a followup, I've added the next patch to Pyrex:
--------------------------------------------------------------------------------------------------
--- Pyrex/Compiler/Nodes.py~ 2006-04-15 13:03:46.000000000 +0200
+++ Pyrex/Compiler/Nodes.py 2006-07-13 14:29:33.000000000 +0200
@@ -3650,6 +3650,8 @@
}
if (PyString_Check(type))
;
+ else if (PyType_Check(type))
+ ;
else if (PyClass_Check(type))
; /*PyErr_NormalizeException(&type, &value, &tb);*/
else if (PyInstance_Check(type)) {
---------------------------------------------------------------------------------------------------
and the StopIteration works well in Python 2.5 :-) However, I've still a
difficulty, because in other parts of my code I'm getting:
----------------------------------------------------------------------------------------------------
Traceback (most recent call last):
File "test_tables.py", line 2143, in test06b
row.append()
File "TableExtension.pyx", line 1168, in TableExtension.Row.append
TypeError: exceptions must be strings, classes, or instances, not
exceptions.NotImplementedError
----------------------------------------------------------------------------------------------------
So, NotImplementError seems not a new-style class (?)
--
>0,0< Francesc Altet http://www.carabos.com/
V V Cárabos Coop. V. Enjoy Data
"-"
More information about the Pyrex
mailing list