Skip to content

Commit 8ba7c48

Browse files
committed
Fix exit codes; add a simple test case
1 parent de0d5c6 commit 8ba7c48

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Lib/test/test_pyrepl/test_pyrepl.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,3 +1339,12 @@ def test_readline_history_file(self):
13391339
def test_keyboard_interrupt_after_isearch(self):
13401340
output, exit_code = self.run_repl(["\x12", "\x03", "exit"])
13411341
self.assertEqual(exit_code, 0)
1342+
1343+
def test_exit_code(self):
1344+
_, exit_code = self.run_repl(["exit(128)"])
1345+
self.assertEqual(exit_code, 128)
1346+
1347+
env = os.environ.copy()
1348+
env["PYTHON_BASIC_REPL"] = "1"
1349+
_, exit_code = self.run_repl(["exit(64)"], env=env)
1350+
self.assertEqual(exit_code, 64)

Modules/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,10 +569,10 @@ pymain_run_stdin(PyConfig *config)
569569
|| _Py_GetEnv(config->use_environment, "PYTHON_BASIC_REPL")) {
570570
PyCompilerFlags cf = _PyCompilerFlags_INIT;
571571
int run = PyRun_AnyFileExFlags(stdin, "<stdin>", 0, &cf);
572-
return (run != 0);
572+
return run;
573573
}
574574
int run = pymain_run_module(L"_pyrepl", 0);
575-
return (run != 0);
575+
return run;
576576
}
577577

578578

0 commit comments

Comments
 (0)