-
Notifications
You must be signed in to change notification settings - Fork 424
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a config param to avoid Python exception checking overheads (#26573)
Adds `Python.checkExceptions` (on by default), which allows users to turn off the exception checking to avoid overhead. This PR also includes a few other cleanups and adds a future for #26579 - [x] `start_test test/library/packages/Python` - [x] `start_test test/library/packages/Python --compopts -scheckExceptions=false` - this has 1 expected failure of `argPassingTest`, which tests exceptions Future work: - It would be nice to support this as a per-interpreter param as well, but that opens us up to issues with generics and classes. So for now thats a todo/nice-to-have [Reviewed by @DanilaFe]
- Loading branch information
Showing
12 changed files
with
112 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
nonGenericSubclassGenericSuperclass.chpl:19: internal error: RES-FUN-ION-2796 chpl version 2.4.0 pre-release (9ab0d960101) | ||
Note: This source location is a guess. | ||
|
||
Internal errors indicate a bug in the Chapel compiler, | ||
and we're sorry for the hassle. We would appreciate your reporting this bug -- | ||
please see https://chapel-lang.org/bugs.html for instructions. In the meantime, | ||
the filename + line number above may be useful in working around the issue. | ||
|
19 changes: 19 additions & 0 deletions
19
test/classes/generic/nonGenericSubclassGenericSuperclass.chpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class Generic { | ||
param x = 1; | ||
} | ||
|
||
class Parent { | ||
var x: borrowed Generic(?); | ||
proc init(x: borrowed Generic(?)) { | ||
this.x = x; | ||
} | ||
} | ||
|
||
class Child: Parent(?) { | ||
proc init(x: borrowed Generic(?)) { | ||
super.init(x); | ||
} | ||
} | ||
|
||
var g = new Generic(); | ||
var c = new Child(g); |
2 changes: 2 additions & 0 deletions
2
test/classes/generic/nonGenericSubclassGenericSuperclass.future
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bug: inheriting from a generic class in a non-generic subclass | ||
#26579 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
noExceptions.chpl:18: error: unresolved call 'Interpreter.init(0)' | ||
$CHPL_HOME/modules/packages/Python.chpl:nnnn: note: this candidate did not match: Interpreter.init() | ||
noExceptions.chpl:18: note: because call includes 1 argument | ||
$CHPL_HOME/modules/packages/Python.chpl:nnnn: note: but function can only accept 0 arguments |
32 changes: 32 additions & 0 deletions
32
test/library/packages/Python/correctness/noExceptions.chpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use Python; | ||
|
||
var hello = """ | ||
print('Hello, World!') | ||
"""; | ||
var hello_raise = """ | ||
raise Exception('Hello, World!') | ||
"""; | ||
|
||
// use default checking | ||
{ | ||
var interp = new Interpreter(); | ||
var mod = new Module(interp, 'hello', hello); | ||
} | ||
|
||
// explicitly use no checking, blocked by https://github.com/chapel-lang/chapel/issues/26579 | ||
{ | ||
var interp = new Interpreter(false); | ||
var mod = new Module(interp, 'hello', hello); | ||
} | ||
|
||
// explicitly use checking, blocked by https://github.com/chapel-lang/chapel/issues/26579 | ||
{ | ||
var interp = new Interpreter(true); | ||
try { | ||
var mod = new Module(interp, 'hello', hello_raise); | ||
} catch e: PythonException { | ||
writeln("Caught exception: ", e.message()); | ||
} catch { | ||
writeln("Caught unknown exception"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-scheckExceptions=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
feature request: ability to set override the global checkExceptions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Hello, World! | ||
Hello, World! | ||
Caught exception: Hello, World! |
3 changes: 3 additions & 0 deletions
3
test/library/packages/Python/correctness/noExceptions.prediff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
$CHPL_HOME/util/test/prediff-obscure-module-linenos $@ |
Empty file.