3 ms·
Another interesting one, byteplay [1] makes bytecode-hacking childs play. The most evil code I ever wrote [2] actually used this to modify the caller's bytecod
by peterwaller 13y ago
Another interesting one, byteplay [1] makes bytecode-hacking childs play.
The most evil code I ever wrote [2] actually used this to modify the caller's bytecode in order to turn a log message into an exception with the correct stack trace from behind a C callback. I wouldn't recommend doing this, and I plan to excise this nasty hack at some point. Remarkably it works, even with a pretty intense multi-threaded unit test. I still don't like the idea of trusting this in production though.. You know the code in front of you must be evil if it contains a function named `re_execute_with_exception(frame, exception, traceback)`.
The problem is that the "correct" solution requires writing C/C++ code which we don't want to introduce to the project (distribution is a pain in the highly heterogeneous software environments that high energy physics has). The other correct solution is to fix upstream, which I hope will happen at some point. I look forward to the time when I can delete this code, anyway.
[1] https://code.google.com/p/byteplay/ https://code.google.com/p/byteplay/
[2] https://github.com/rootpy/rootpy/blob/master/rootpy/logger/magic.py#L194 https://github.com/rootpy/rootpy/blob/master/rootpy/logger/m...