You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
lib.h
=====
void foo();
good.pyx
========
cdef extern from "lib.h":
void foo()
foo()
Everything's OK.
But with:
bad.pyx
=======
cdef extern from "lib.h":
void foo() except +
foo()
g++ reports:
bad.c: In function `void __Pyx_CppExn2PyErr()':
bad.c:189: error: expected unqualified-id before '&' token
bad.c:189: error: ISO C++ forbids declaration of `type name' with no type
bad.c:189: error: expected `)' before '&' token
bad.c:189: error: expected `{' before '&' token
bad.c:189: error: `exn' was not declared in this scope
bad.c:189: error: expected `;' before ')' token
bad.c:192: error: expected primary-expression before "catch"
bad.c:192: error: expected `;' before "catch"
bad.c:195: error: expected primary-expression before "catch"
bad.c:195: error: expected `;' before "catch"
bad.c:189: warning: unused variable 'exn'
Here is bad.c extract:
182 #ifndef __Pyx_CppExn2PyErr
183 static void __Pyx_CppExn2PyErr() {
184 try {
185 if (PyErr_Occurred())
186 ; // let the latest Python exn pass through and ignore the current one
187 else
188 throw;
189 } catch (const std::out_of_range& exn) {
190 // catch out_of_range explicitly so the proper Python exn may be raised
191 PyErr_SetString(PyExc_IndexError, exn.what());
192 } catch (const std::exception& exn) {
193 PyErr_SetString(PyExc_RuntimeError, exn.what());
194 }
195 catch (...)
196 {
197 PyErr_SetString(PyExc_RuntimeError, "Unknown exception");
198 }
199 }
200 #endif
To fix that I need to add in bad.pyx:
cdef extern from "stdexcept":
pass
Stephane Drouard:
Migrated from http://trac.cython.org/ticket/261
The text was updated successfully, but these errors were encountered: