Can't Redirect Error Stream From Cython
Solution 1:
There are two ingredients for your problem and both are in your setup-file.
The first ingredient is that you have two extensions:
ext_modules = [
Extension('nebula.sfml.system', ['nebula/sfml/system.pyx'],
language='c++', ...),
Extension('nebula.sfml.graphics', ['nebula/sfml/graphics.pyx'],
language='c++', ...),
]
that means cython will create two different shared libraries: system.dll and graphics.dll which will be both loaded later on dynamically by python.
The second ingredient: the sfml-library is linked statically but contains a singleton (the error-stream in question) and this is a recipe for disaster: With your set-up it is no longer a singleton, but there are two different error-streams: The one from system.dll and the one from graphics.dll. So you are silencing the error-stream from the system.dll (because your call set_error_handler() lives there), but write to the error-stream from the graphics.dll (this where image_load_test lives).
So what can be done? There are two options:
- Use shared
sfml-libraries (at leastsfml-system-s), thus the singleton will stay a singleton. - Put the content of both pyx-files in the same pyx-file/Extension/shared library. At least right now, the content of
system.pyxis only needed forgraphics.pyx.
Post a Comment for "Can't Redirect Error Stream From Cython"