Skip to content

all: handle SystemExit #243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

aisk
Copy link
Contributor

@aisk aisk commented Jun 29, 2025

Currently raise SystemExit() or calling sys.exit() is not handled correctly. The interpreter will crash because Exception.__repr__ can't handle SystemExit, but #242 will fix this. So we should handle the SystemExit and exit the interpreter.

Copy link
Collaborator

@ncw ncw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea - thanks.

See inline for comments.

@@ -74,6 +74,36 @@ func xmain(args []string) {
} else {
_, err := py.RunFile(ctx, args[0], py.CompileOpts{}, nil)
if err != nil {
if py.IsException(py.SystemExit, err) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we factor the duplicated code out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants