From 31a764f4a9ec54d3ea970aa9514a088c4e603ebd Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 8 Sep 2023 10:07:54 -0400 Subject: [PATCH] src/bin/sage-env: set PYDEVD_DISABLE_FILE_VALIDATION=1 Newer versions of debugpy come with a bundled pydevd that complains about >=python-3.11's frozen core modules. This causes a doctest failure, File "sage/repl/ipython_kernel/kernel.py", line 48, in sage.repl.ipython_kernel.kernel.SageKernel.__init__ Failed example: from sage.repl.ipython_kernel.kernel import SageKernel Expected nothing Got: 0.00s - Debugger warning: It seems that frozen modules are being used, which may 0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off 0.00s - to python to disable frozen modules. 0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation. The issue is simply that, with the core modules frozen, the user cannot place breakpoints in them. The warning however is displayed whenever you import debugpy, which happens inside ipykernel, i.e. whenever we merely import SageKernel. Taking the warning's advice, we set PYDEVD_DISABLE_FILE_VALIDATION=1 in src/bin/sage-env to hide the untimely warning. This does nothing to change the status quo (you couldn't put breakpoints in frozen modules before and now you still can't), but it fixes the doctest failure and makes the old/new versions of debugpy behave consistently. --- src/bin/sage-env | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/bin/sage-env b/src/bin/sage-env index 13b54fa7e92..2a63be5b7c0 100644 --- a/src/bin/sage-env +++ b/src/bin/sage-env @@ -635,3 +635,11 @@ if [ -n "$SAGE_LOCAL" ]; then fi fi + + +# Newer versions of debugpy come with a bundled pydevd that complains +# about >=python-3.11's core modules being frozen (and therefore not +# breakpoint-able). This workaround simply hides the warning to keep +# our doctests predictable (which was the status quo with earlier +# versions of debugpy). +export PYDEVD_DISABLE_FILE_VALIDATION=1