Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit c7d7ee0

Browse files
author
Anselm Kruis
committed
Stackless issue #254: bpo-36763: _Py_RunMain() doesn't call Py_Exit()
anymore Adapt Stackless to upstream commit 1208328. Replace PyStackless_HandleSystemExit() by _Py_HandleSystemExit().
1 parent ecbc077 commit c7d7ee0

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Python/pythonrun.c

+4
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,11 @@ _Py_HandleSystemExit(int *exitcode_p)
597597
return 0;
598598
}
599599

600+
#ifdef STACKLESS
601+
if (!PyErr_ExceptionMatches(PyExc_SystemExit) && !PyErr_ExceptionMatches(PyExc_TaskletExit)) {
602+
#else
600603
if (!PyErr_ExceptionMatches(PyExc_SystemExit)) {
604+
#endif
601605
return 0;
602606
}
603607

Stackless/module/scheduling.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "structmember.h"
33
#include "pythread.h"
44
#include "pycore_object.h"
5+
#include "pycore_pylifecycle.h"
56

67
#ifdef STACKLESS
78
#include "pycore_stackless.h"
@@ -1320,8 +1321,6 @@ schedule_task_destruct(PyObject **retval, PyTaskletObject *prev, PyTaskletObject
13201321
return fail;
13211322
}
13221323

1323-
/* defined in pythonrun.c */
1324-
extern void PyStackless_HandleSystemExit(void);
13251324
/* defined in stacklessmodule.c */
13261325
extern int PyStackless_CallErrorHandler(void);
13271326

@@ -1352,7 +1351,10 @@ slp_tasklet_end(PyObject *retval)
13521351
/* but if it is truly a SystemExit on the main thread, we want the exit! */
13531352
if (ts == SLP_INITIAL_TSTATE(ts) && !PyErr_ExceptionMatches(PyExc_TaskletExit)) {
13541353
if (ts->interp == _PyRuntime.interpreters.main) {
1355-
PyStackless_HandleSystemExit();
1354+
int exitcode;
1355+
if (_Py_HandleSystemExit(&exitcode)) {
1356+
Py_Exit(exitcode);
1357+
}
13561358
handled = 1; /* handler returned, it wants us to silence it */
13571359
}
13581360
} else {

0 commit comments

Comments
 (0)