[Cython] Feature request: Flag to enable warnings when 'extern' functions are not declared 'except +'

Michael Enßlin michael at ensslin.cc
Fri Jun 12 23:24:00 CEST 2015

Hi everybody,

as you surely have guessed from the amount of Bug reports I have
recently submitted to this mailing list, I'm currently working on a
rather large Cython project.
More precisely: I'm using Cython as the glue layer between the Python
and C++ components of openage; an overview and source code may be found

In openage, almost all C++ functions that are exposed to Cython SHOULD
be declared as 'except +'.
Forgetting to do so can cause hard-to-debug issues, including useless
Exception messages, corruption of CPython and right-out program
termination, if those methods should throw a C++ exception.

As a solution, I'd like to see Cython warnings if an extern cimport has
no 'except' declaration.

To intentionally omit the "except +", I suggest a new except
declaration, "except -", or, even better, the C++11 keyword "noexcept"
(since precisely those methods that are declared 'noexcept' should be
cimported without 'except+').

Of course, those warnings (or errors?) should be disabled by default,
and enabled by a special command-line flag.

Any thoughts on this?

	~ mic_e

More information about the cython-devel mailing list