-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
linecache.cache
sometimes has an entry for <string>
under Python 3.13.0a5
#117174
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
Comments
I believe this is a feature from #110805 which allows the traceback to show source code with
3.12:
3.13:
However, I can see that the secret
The code above should trigger an exception because we should not be able to get the source of I think a proper fix would be to change the code object name A simpler way would be just disable this feature for Or we could do even more aggressive and do similar numbering for dynamically compiled code and always give source code, which is a bit ambitious and definitely beyond this issue. @pablogsal thoughts on this? I can do the PR if you want. |
…ractive code objects Using <string> leads to confusion when linecache it's populated with <string> entries as the inspect module heavily relies on it. An example: ./python -c "import inspect;x=eval('lambda x: x');print(inspect.getsource(x))" The code above should trigger an exception because we should not be able to get the source of x (it's dynamically generated) but if we use <string> as name for interactive code it will return gives the full string.
…ractive code objects Using <string> leads to confusion when linecache it's populated with <string> entries as the inspect module heavily relies on it. An example: ./python -c "import inspect;x=eval('lambda x: x');print(inspect.getsource(x))" The code above should trigger an exception because we should not be able to get the source of x (it's dynamically generated) but if we use <string> as name for interactive code it will return gives the full string. Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
I have opened #117500 to do a renaming of the string to something less common. We still want to preserve this behaviour for |
…ractive code objects Using <string> leads to confusion when linecache it's populated with <string> entries as the inspect module heavily relies on it. An example: ./python -c "import inspect;x=eval('lambda x: x');print(inspect.getsource(x))" The code above should trigger an exception because we should not be able to get the source of x (it's dynamically generated) but if we use <string> as name for interactive code it will return gives the full string. Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
…h no-colorize fixes
…urce code (pythonGH-117500) (cherry picked from commit a931a8b) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
…e have always source
After this was merged I'm seeing failures like this:
|
How this was not detected in the CI? I will take a look later today |
I cannot reproduce this locally:
|
Looking at the failures this is super wrong:
|
@encukou not sure what to do here, this looks like a gdb bug that only happens inAMD64 RHEL8 LTO PR. The output from gdb makes no sense to me. Maybe this only happens under LTO... |
@vstinner, do you have any ideas? |
Add support.check_ldflags_lto().
tl; dr I created PR gh-131143 to skip test_gdb if Python is built with LTO. There are two important things on the AMD64 RHEL 8 buildbot:
I already noticed weird gdb behaviors when Python is built with LTO.
It's maybe time to declare game over and skip test_gdb if Python is built with LTO :-( We already skip test_gdb if Python is built with PGO or BOLT: if support.check_cflags_pgo():
raise unittest.SkipTest("test_gdb is not reliable on PGO builds")
if support.check_bolt_optimized():
raise unittest.SkipTest("test_gdb is not reliable on BOLT optimized builds") By the way, we recently modified test_gdb to also skip it if Python is built with |
Please let's not do it. The whole point of test gdb is to test that gdb works with released versions of CPython. If we skip it then gdb will be broken and we never know that the functionality works with the versions that people use it |
I fixed the test failures by using a different function that doesn't get super optimised to wrong DWARF so at least we are fine for now |
Oh, I didn't see that you already fixed the issue. That's why I was unable to reproduce it :-) Ok, I abandon my PR skipping test_gdb is Python is built with LTO. |
…EPL behavior (follow-up pythongh-131065) (pythonGH-131836) Adapt test to new REPL behavior (follow-up pythongh-117174) (cherry picked from commit a6cf827) Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
…e have always source (pythonGH-131065) (cherry picked from commit 4192ce1) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
…REPL behavior (follow-up gh-131065) (GH-131836) (#131841) gh-117174: Adapt `test_multiple_statements_fail_early` to new REPL behavior (follow-up gh-131065) (GH-131836) Adapt test to new REPL behavior (follow-up gh-117174) (cherry picked from commit a6cf827) Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
As of the changes to `linecache` in python/cpython#117174, logging tracebacks requires code objects to have a `co_qualname` attribute, which is true for native Python code objects as of 3.11. Adjust billiard's emulation of them to match. Spotted by pagure's tests in https://bugs.debian.org/1101621; analysis and patch by Rebecca N. Palmer <rebecca_palmer@zoho.com>.
As of the changes to `linecache` in python/cpython#117174, logging tracebacks requires code objects to have a `co_qualname` attribute, which is true for native Python code objects as of 3.11. Adjust billiard's emulation of them to match. Spotted by pagure's tests in https://bugs.debian.org/1101621; analysis and patch by Rebecca N. Palmer <rebecca_palmer@zoho.com>.
…e have always source (python#131065)
…EPL behavior (follow-up pythongh-131065) (python#131836) Adapt test to new REPL behavior (follow-up pythongh-117174)
Bug report
Bug description:
I noticed this via Hypothesis' pretty-printer for
lambda
functions, and tracked the divergence through theinspect
module tolinecache
:If I run this snippet with
python3.13 -Wignore -m pytest repro.py
, or any older Python version, you'll get the expectedKeyError
. But if I append-n2
to the command, it prints(44, None, ['import sys;exec(eval(sys.stdin.readline()))\n'], '<string>')
!(
python3.13 -m pip install pytest pytest-xdist
will get the dependencies for this)That's the
popen
bootstrap line fromexecnet
, which handles running code across multiple processes forpytest-xdist
. At this point I've foundlinecache.cache.pop("<string>", None)
to be an acceptable workaround, and since I don't have any particular knowledge of either the CPython or execnet code that's as far as I investigated.CPython versions tested on:
3.8, 3.9, 3.10, 3.11, 3.12, 3.13
Operating systems tested on:
Linux
Linked PRs
test_multiple_statements_fail_early
to new REPL behavior (follow-up gh-131065) #131836test_multiple_statements_fail_early
to new REPL behavior (follow-up gh-131065) (GH-131836) #131841The text was updated successfully, but these errors were encountered: