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
GH-95238: lazily compute line number for tracebacks #95237
Conversation
kumaraditya303
commented
Jul 25, 2022
•
edited by bedevere-bot
edited by bedevere-bot
- Issue: Lazily compute lineno of tracebacks for efficient exception handling #95238
This PR handles line numbers, but the issue is about lazily creating the whole traceback. |
I updated the issue title to restrict it to this specific change, I'll add a blurb entry. |
Is the tb_lineno field documented in the C API? It would appear to be public. Putting negative values there might break C code that's interpreting tracebacks somehow. You'd be surprised how many packages exist that do things like this (we found out when changing much more obscure parts of the interpreter state). |
As far as I can see on https://docs.python.org/3/search.html?q=tb_lineno&check_keywords=yes&area=default |
That's a relief -- OTOH it's still part of the "regular" API (traceback.h is included by Python.h unless in limited ABI mode) and I am not 100% comfortable changing its meaning. Maybe you can search GitHub for references to this symbol? |
We can provide a new function to get |
That doesn't answer my question -- I'm trying to answer the question of how many people will find that they have to make changes to their code to adopt 3.12 due to this change. Because we are breaking backwards compatibility for them. |
I agree with both of you. The problem is that the name of the C field is same as the Python attribute, so writers of C extensions assume that they can read the C extensions authors should not make these assumptions, and they are wrong in doing so, but they do it anyway. If we are going to change the semantics of |
@markshannon Should I create a separate issue to add a C API function or just document to read the field with |
Probably best to add a C API function, as you'll need to implement the function anyway. No need for a separate PR. |
Sure, I'll add a C API function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM