From 37965d2fb434d8343d5c70fb6a462a16ae7882b8 Mon Sep 17 00:00:00 2001 From: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com> Date: Sat, 16 Apr 2022 18:57:00 -0400 Subject: [PATCH] gh-78607: Replace __ltrace__ with __lltrace__ (GH-91619) --- Doc/using/configure.rst | 2 +- Include/internal/pycore_global_strings.h | 2 +- Include/internal/pycore_runtime_init.h | 2 +- Lib/test/test_lltrace.py | 10 +++++----- .../2022-04-16-21-54-31.gh-issue-78607._Y7bMm.rst | 1 + Misc/SpecialBuilds.txt | 2 +- Python/ceval.c | 2 +- Tools/c-analyzer/TODO | 1 - 8 files changed, 11 insertions(+), 11 deletions(-) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2022-04-16-21-54-31.gh-issue-78607._Y7bMm.rst diff --git a/Doc/using/configure.rst b/Doc/using/configure.rst index b46157cc6ad..2e632d822f9 100644 --- a/Doc/using/configure.rst +++ b/Doc/using/configure.rst @@ -273,7 +273,7 @@ Effects of a debug build: * Add :func:`sys.gettotalrefcount` function. * Add :option:`-X showrefcount <-X>` command line option. * Add :envvar:`PYTHONTHREADDEBUG` environment variable. -* Add support for the ``__ltrace__`` variable: enable low-level tracing in the +* Add support for the ``__lltrace__`` variable: enable low-level tracing in the bytecode evaluation loop if the variable is defined. * Install :ref:`debug hooks on memory allocators ` to detect buffer overflow and other memory errors. diff --git a/Include/internal/pycore_global_strings.h b/Include/internal/pycore_global_strings.h index 77f96cd5ed2..cc94662256e 100644 --- a/Include/internal/pycore_global_strings.h +++ b/Include/internal/pycore_global_strings.h @@ -137,10 +137,10 @@ struct _Py_global_strings { STRUCT_FOR_ID(__le__) STRUCT_FOR_ID(__len__) STRUCT_FOR_ID(__length_hint__) + STRUCT_FOR_ID(__lltrace__) STRUCT_FOR_ID(__loader__) STRUCT_FOR_ID(__lshift__) STRUCT_FOR_ID(__lt__) - STRUCT_FOR_ID(__ltrace__) STRUCT_FOR_ID(__main__) STRUCT_FOR_ID(__matmul__) STRUCT_FOR_ID(__missing__) diff --git a/Include/internal/pycore_runtime_init.h b/Include/internal/pycore_runtime_init.h index 371f2d23ad8..9a3a9d04324 100644 --- a/Include/internal/pycore_runtime_init.h +++ b/Include/internal/pycore_runtime_init.h @@ -760,10 +760,10 @@ extern "C" { INIT_ID(__le__), \ INIT_ID(__len__), \ INIT_ID(__length_hint__), \ + INIT_ID(__lltrace__), \ INIT_ID(__loader__), \ INIT_ID(__lshift__), \ INIT_ID(__lt__), \ - INIT_ID(__ltrace__), \ INIT_ID(__main__), \ INIT_ID(__matmul__), \ INIT_ID(__missing__), \ diff --git a/Lib/test/test_lltrace.py b/Lib/test/test_lltrace.py index 75b377b637b..63b65e4b2f8 100644 --- a/Lib/test/test_lltrace.py +++ b/Lib/test/test_lltrace.py @@ -48,9 +48,9 @@ def dont_trace_2(): x = 42 y = -x dont_trace_1() - __ltrace__ = 1 + __lltrace__ = 1 trace_me() - del __ltrace__ + del __lltrace__ dont_trace_2() """) self.assertIn("GET_ITER", stdout) @@ -67,7 +67,7 @@ def dont_trace_2(): def test_lltrace_different_module(self): stdout = self.run_code(""" from test import test_lltrace - test_lltrace.__ltrace__ = 1 + test_lltrace.__lltrace__ = 1 test_lltrace.example() """) self.assertIn("'example' in module 'test.test_lltrace'", stdout) @@ -95,13 +95,13 @@ def test_lltrace_different_module(self): def test_lltrace_does_not_crash_on_subscript_operator(self): # If this test fails, it will reproduce a crash reported as # bpo-34113. The crash happened at the command line console of - # debug Python builds with __ltrace__ enabled (only possible in console), + # debug Python builds with __lltrace__ enabled (only possible in console), # when the internal Python stack was negatively adjusted stdout = self.run_code(""" import code console = code.InteractiveConsole() - console.push('__ltrace__ = 1') + console.push('__lltrace__ = 1') console.push('a = [1, 2, 3]') console.push('a[0] = 1') print('unreachable if bug exists') diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-04-16-21-54-31.gh-issue-78607._Y7bMm.rst b/Misc/NEWS.d/next/Core and Builtins/2022-04-16-21-54-31.gh-issue-78607._Y7bMm.rst new file mode 100644 index 00000000000..808aedd5098 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2022-04-16-21-54-31.gh-issue-78607._Y7bMm.rst @@ -0,0 +1 @@ +The LLTRACE special build now looks for the name ``__lltrace__`` defined in module globals, rather than the name ``__ltrace__``, which had been introduced as a typo. diff --git a/Misc/SpecialBuilds.txt b/Misc/SpecialBuilds.txt index a7cee8098e9..5609928284d 100644 --- a/Misc/SpecialBuilds.txt +++ b/Misc/SpecialBuilds.txt @@ -94,7 +94,7 @@ Compile in support for Low Level TRACE-ing of the main interpreter loop. When this preprocessor symbol is defined, before PyEval_EvalFrame executes a frame's code it checks the frame's global namespace for a variable -"__ltrace__". If such a variable is found, mounds of information about what +"__lltrace__". If such a variable is found, mounds of information about what the interpreter is doing are sprayed to stdout, such as every opcode and opcode argument and values pushed onto and popped off the value stack. diff --git a/Python/ceval.c b/Python/ceval.c index d6f11d8f436..d358a3134bc 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1729,7 +1729,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int #ifdef LLTRACE { - int r = PyDict_Contains(GLOBALS(), &_Py_ID(__ltrace__)); + int r = PyDict_Contains(GLOBALS(), &_Py_ID(__lltrace__)); if (r < 0) { goto exit_unwind; } diff --git a/Tools/c-analyzer/TODO b/Tools/c-analyzer/TODO index 6683df5993b..43760369b19 100644 --- a/Tools/c-analyzer/TODO +++ b/Tools/c-analyzer/TODO @@ -468,7 +468,6 @@ Python/ceval.c:_PyEval_EvalFrameDefault():PyId___annotations__ _Py_IDENTIFIER( Python/ceval.c:_PyEval_EvalFrameDefault():PyId___build_class__ _Py_IDENTIFIER(__build_class__) Python/ceval.c:_PyEval_EvalFrameDefault():PyId___enter__ _Py_IDENTIFIER(__enter__) Python/ceval.c:_PyEval_EvalFrameDefault():PyId___exit__ _Py_IDENTIFIER(__exit__) -Python/ceval.c:_PyEval_EvalFrameDefault():PyId___ltrace__ _Py_IDENTIFIER(__ltrace__) Python/ceval.c:_PyEval_EvalFrameDefault():PyId_displayhook _Py_IDENTIFIER(displayhook) Python/ceval.c:_PyEval_EvalFrameDefault():PyId_send _Py_IDENTIFIER(send) Python/ceval.c:import_all_from():PyId___all__ _Py_IDENTIFIER(__all__)