5555import java .util .concurrent .ScheduledExecutorService ;
5656import java .util .concurrent .TimeUnit ;
5757
58+ import org .graalvm .polyglot .SandboxPolicy ;
59+
5860import com .oracle .graal .python .PythonLanguage ;
5961import com .oracle .graal .python .builtins .objects .function .PArguments ;
6062import com .oracle .graal .python .builtins .objects .function .Signature ;
@@ -139,7 +141,7 @@ public final void execute(PythonContext context) {
139141 // Avoid pointless stack walks in random places
140142 PArguments .setException (args , PException .NO_EXCEPTION );
141143
142- if (debugger == null ) {
144+ if (debugger == null && ! context . getEnv (). getSandboxPolicy (). isStricterThan ( SandboxPolicy . TRUSTED ) ) {
143145 debugger = Debugger .find (context .getEnv ());
144146 }
145147 if (threadState == null ) {
@@ -153,13 +155,17 @@ public final void execute(PythonContext context) {
153155 if (!alreadyProfiling ) {
154156 threadState .profilingStart ();
155157 }
156- debugger .disableStepping ();
158+ if (debugger != null ) {
159+ debugger .disableStepping ();
160+ }
157161 try {
158162 CallDispatchers .SimpleIndirectInvokeNode .executeUncached (context .getAsyncHandler ().callTarget , args );
159163 } catch (PException e ) {
160164 handleException (e );
161165 } finally {
162- debugger .restoreStepping ();
166+ if (debugger != null ) {
167+ debugger .restoreStepping ();
168+ }
163169 if (!alreadyTracing ) {
164170 threadState .tracingStop ();
165171 }
0 commit comments