[issue38500] Provide a way to get/set PyInterpreterState.frame_eval without needing to access interpreter internals

Fabio Zadrozny report at bugs.python.org
Thu Nov 21 12:01:22 EST 2019


Fabio Zadrozny <fabioz at users.sourceforge.net> added the comment:

@Mark

First you have to explain to me how you envision changing the method code reliably in the debugger... 

Import hooks don't work (they'd break with something as simple as the code below)

def method():
   a = 10

mod = reload(old_mod)
old_mod.method.__code__ = mod.method.__code__

using the tracing also doesn't work (it's too late to change the code)

Note: consider the reload just an example, not the only use case (say, the user could pickle code objects to remote execution and the debugger should still work).

Also, consider you have to change the bytecode of methods which are only internal to a function (and thus can't be accessed from the outside).

Then, if you have a reliable way to do it, how do you keep track of those code objects to reapply the patching when breakpoints change? What if it adds a breakpoint to a new method, how do you locate it? Creating strong references to methods isn't an option because it would prevent things from being garbage collected (and you'd have to track all objects containing code objects for it to be reliable).

As a note, pydevd does have some support for hot-reloading, but there are too many corner-cases and it doesn't work 100% for live coding (it's an unsolved problem is Python) -- and I can't really envision it working for regular breakpoints as there are too many corner cases to handle.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38500>
_______________________________________


More information about the Python-bugs-list mailing list