Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ def test_compile_unrecognised_flags_message():
assert False, "ValueError was not raised"


def test_compile_invalid_optimize_is_value_error():
assert_raises(ValueError, compile, "1", "<input>", "exec", optimize=5)
assert_raises(ValueError, compile, "1", "<input>", "exec", optimize=-2)


def test_dont_imply_dedent():
flags = 0x4000 | 0x200 # PyCF_ALLOW_INCOMPLETE_INPUT | PyCF_DONT_IMPLY_DEDENT
source = "def foo():\n return 42"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ private void checkSource(TruffleString source) throws PException {
@TruffleBoundary
private void checkOptimize(int optimize, Object kwOptimize) throws PException {
if (optimize < -1 || optimize > 2) {
throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.INVALID_OPTIMIZE_VALUE, kwOptimize);
throw PRaiseNode.raiseStatic(this, ValueError, ErrorMessages.INVALID_OPTIMIZE_VALUE, kwOptimize);
}
}

Expand Down