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

Support Python 3.11 #939

Closed
fabioz opened this issue May 20, 2022 · 7 comments
Closed

Support Python 3.11 #939

fabioz opened this issue May 20, 2022 · 7 comments
Labels
enhancement New feature or request

Comments

@fabioz
Copy link
Collaborator

fabioz commented May 20, 2022

I'll start to work on this now that the first beta is out (as it seems Python 3.11 had many internal changes I think this will be a big task).

fabioz added a commit to fabioz/debugpy that referenced this issue Jun 24, 2022
Added support for setting tracing to different threads
along with some general fixes.

Main things missing:
- Compile with cython extensions
- Bytecode manipulation
- Frame eval mode (requires bytecode manipulation)
fabioz added a commit that referenced this issue Jun 30, 2022
Added support for setting tracing to different threads
along with some general fixes.

Main things missing:
- Compile with cython extensions
- Bytecode manipulation
- Frame eval mode (requires bytecode manipulation)
fabioz added a commit to fabioz/debugpy that referenced this issue Jul 1, 2022
fabioz added a commit that referenced this issue Jul 6, 2022
@int19h int19h added the enhancement New feature or request label Sep 8, 2022
@juliangilbey
Copy link

Thanks for all your work so far on supporting Python 3.11!

This is a followup to my issue and PR on pydevd (fabioz/PyDev.Debugger#238 and fabioz/PyDev.Debugger#239). While the PR fixes the "TODO" noted in the pxd file, it does not address another major issue with Python 3.11: the PyFrameObject structure has completely changed, and so the ctypedef is no longer valid. Indeed, references to frame_obj.f_code in pydevd_frame_evaluator.template.pyx need to be replaced by frame_obj.f_frame.f_code, or so it would appear.

What I don't know how to do is make Cython conditionally include cdefs and the like depending on the Python version; it would appear that #if PY_VERSION_HEX only makes sense to Cython inside a docstring, so I'm somewhat stumped. It would be quite ugly (though perhaps feasible) to have two different pxd files for different Python versions, and I'm sure there is a better way to do it.

One could perhaps have conditional Cythonizing (using Cython's IF facility) and then define macros like F_CODE(frame_obj) to expand to frame_obj.f_code or frame_obj.f_frame.f_code as appropriate. That might be a plausible intermediate solution, but it would require running Cython at compilation time and not shipping compiled files.

Anyway, it is quite possible that this is what is causing a lot of the test failures with pydevd (fabioz/PyDev.Debugger#240).

Best wishes, Julian

@fabioz
Copy link
Collaborator Author

fabioz commented Nov 17, 2022

Hello @juliangilbey.

The issue here is that the frame eval mode is not currently available for Python 3.11 at all (as a note, the solution which is also used in other places is using code generation to generate code accordingly for each Python version, but this won't be done until the frame eval mode is actually targeted -- it has a requisite of having the bytecode library available, which has ongoing work to add that support: MatthieuDartiailh/bytecode#103).

So, until the bytecode library is ported, there's no work expected to be done on the frame eval mode.

What's kind of a mystery to me is why you're having compilation errors as the frame eval mode should not be compiled on Python 3.11 (i.e.: it's explicitly skipped in https://github.com/fabioz/PyDev.Debugger/blob/pydev_debugger_2_9_2/setup_pydevd_cython.py#L238).

@juliangilbey
Copy link

Hello @fabioz,

Thanks for that really clear explanation! I have been reading through the code this evening quite carefully (before I saw your message) and reached the same conclusion: there's something funny going on with the way I've set up the Debian build and I'll have to look into that. (I think it's because I modified setup.py to explicitly build the extension as setup_pydevd_cython.py wasn't easily working in our build setup. That's tomorrow's job to sort out!)

@juliangilbey
Copy link

Also, I was confused that setup.py explicitly lists one of the Cython modules _pydevd_bundle.pydevd_cython as an extension, but ignores _pydevd_frame_eval/pydevd_frame_evaluator.

@int19h
Copy link
Contributor

int19h commented Feb 1, 2023

Since frame-eval is disabled by default for the time being, so it's not a support blocker anymore.

@int19h int19h closed this as completed Feb 1, 2023
@juliangilbey
Copy link

Amazing work - thank you so much all!

@davetapley
Copy link

I see this got closed with a few WIP commits, am I correct to assume it wasn't completed, beacuse ⬇️ ?

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

No branches or pull requests

4 participants