In my attempts to package pydevd for Debian, I have packaged bytecode separately. (Debian is quite against having vendored copies of software in other packages wherever it can be avoided.) In the process of doing so, I discovered that the patched version of bytecode in pydevd fails some of the bytecode package tests because of a subtle issue: having stream=sys.stdout as a default argument in dump_bytecode means that contextlib.redirect_stdout() fails to actually redirect stdout.
This PR does several different things:
It updates the bytecode package from a pre-release version of 0.13.0 to the released version. The differences between them are cosmetic only (black was applied to the source code).
It explicitly includes the patch applied to bytecode in the vendored directory rather than referring to a now-out-of-date commit; it also modifies the README.txt file to refer to this patch file.
The patch no longer touches the dump_bytecode function. Instead it wraps the call to it in _pydevd_frame_eval/pydevd_modify_bytecode.py inside a contextlib.redirect_stdout context manager. This simplifies the patch significantly and separates concerns more cleanly. (This function was introduced in Python 3.4 so is available for all versions of Python 3.x that pydevd supports.)
The patch no longer changes the order of arguments in the internal _pack_linetable method; there seems to be no benefit in doing so.
This reduces the entire patch size to about 11 changed lines (depending on how you count!).
All of the pydevd tests still pass with both Python 3.9 and 3.10 (except for the two mentioned in #222).
Hi Fabio,
In my attempts to package pydevd for Debian, I have packaged bytecode separately. (Debian is quite against having vendored copies of software in other packages wherever it can be avoided.) In the process of doing so, I discovered that the patched version of bytecode in pydevd fails some of the bytecode package tests because of a subtle issue: having
stream=sys.stdout
as a default argument indump_bytecode
means thatcontextlib.redirect_stdout()
fails to actually redirect stdout.This PR does several different things:
dump_bytecode
function. Instead it wraps the call to it in_pydevd_frame_eval/pydevd_modify_bytecode.py
inside acontextlib.redirect_stdout
context manager. This simplifies the patch significantly and separates concerns more cleanly. (This function was introduced in Python 3.4 so is available for all versions of Python 3.x that pydevd supports.)_pack_linetable
method; there seems to be no benefit in doing so.This reduces the entire patch size to about 11 changed lines (depending on how you count!).
All of the pydevd tests still pass with both Python 3.9 and 3.10 (except for the two mentioned in #222).