I am trying to use the python bindings for Radare2 found here:
These are based on ctypes
and the compiled libraries from radare2. These libraries output text to stderr
even under normal usage. This type of c-level stream cannot be redirected using the standard library contextlib.redirect_stderr()
.
According to the following guide, there is an alternative recipe to make a contextmanager
based way to redirect the output from ctypes
correctly. However, this way requires sys.stdout.close()
which conflicts with Jupyter. If this is run in Jupyter, the cell enters what appears to be an infinite loop.
https://eli.thegreenplace.net/2015/redirecting-all-kinds-of-stdout-in-python/
The native Jupyter cell magic, %%capture
also does not work to redirect stderr
from ctypes
.
Am I stuck between a rock and a hard place, or is there another way that this can work in Jupyter?