@@ -526,7 +526,7 @@ public RootCallTarget parseForBytecodeInterpreter(PythonContext context, Source
526
526
Parser parser = Compiler .createParser (source .getCharacters ().toString (), errorCb , type , interactiveTerminal );
527
527
ModTy mod = (ModTy ) parser .parse ();
528
528
assert mod != null ;
529
- return compileForBytecodeInterpreter (context , mod , source , topLevel , optimize , argumentNames );
529
+ return compileForBytecodeInterpreter (context , mod , source , topLevel , optimize , argumentNames , errorCb );
530
530
} catch (PException e ) {
531
531
if (topLevel ) {
532
532
PythonUtils .getOrCreateCallTarget (new TopLevelExceptionHandler (this , e )).call ();
@@ -536,8 +536,12 @@ public RootCallTarget parseForBytecodeInterpreter(PythonContext context, Source
536
536
}
537
537
538
538
@ TruffleBoundary
539
- public RootCallTarget compileForBytecodeInterpreter (PythonContext context , ModTy mod , Source source , boolean topLevel , int optimize , List <String > argumentNames ) {
540
- RaisePythonExceptionErrorCallback errorCb = new RaisePythonExceptionErrorCallback (source , PythonOptions .isPExceptionWithJavaStacktrace (this ));
539
+ public RootCallTarget compileForBytecodeInterpreter (PythonContext context , ModTy mod , Source source , boolean topLevel , int optimize , List <String > argumentNames ,
540
+ RaisePythonExceptionErrorCallback errorCallback ) {
541
+ RaisePythonExceptionErrorCallback errorCb = errorCallback ;
542
+ if (errorCb == null ) {
543
+ errorCb = new RaisePythonExceptionErrorCallback (source , PythonOptions .isPExceptionWithJavaStacktrace (this ));
544
+ }
541
545
try {
542
546
Compiler compiler = new Compiler (errorCb );
543
547
boolean hasArguments = argumentNames != null && !argumentNames .isEmpty ();
@@ -547,9 +551,9 @@ public RootCallTarget compileForBytecodeInterpreter(PythonContext context, ModTy
547
551
CompilationUnit cu = compiler .compile (mod , EnumSet .noneOf (Compiler .Flags .class ), optimize );
548
552
CodeUnit co = cu .assemble ();
549
553
RootNode rootNode = PBytecodeRootNode .create (this , co , source , errorCb );
550
- GilNode gil = GilNode .getUncached ();
551
- boolean wasAcquired = gil .acquire (context , rootNode );
552
554
if (topLevel ) {
555
+ GilNode gil = GilNode .getUncached ();
556
+ boolean wasAcquired = gil .acquire (context , rootNode );
553
557
try {
554
558
errorCb .triggerDeprecationWarnings ();
555
559
} finally {
0 commit comments