Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update bytecode to 0.13.0 and simplify patch #225

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

juliangilbey
Copy link
Contributor

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 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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant