Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
4cb525a1
Commit
4cb525a1
authored
Apr 26, 2019
by
Victor Stinner
Committed by
GitHub
Apr 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-36356: pymain_exit_error() only call pymain_free() for exit (GH-12968)
Add _Py_INIT_HAS_EXITCODE() macro.
parent
00db7c73
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
3 deletions
+10
-3
Include/cpython/coreconfig.h
Include/cpython/coreconfig.h
+3
-1
Modules/main.c
Modules/main.c
+6
-1
Python/pylifecycle.c
Python/pylifecycle.c
+1
-1
No files found.
Include/cpython/coreconfig.h
View file @
4cb525a1
...
...
@@ -33,8 +33,10 @@ typedef struct {
#define _Py_INIT_NO_MEMORY() _Py_INIT_USER_ERR("memory allocation failed")
#define _Py_INIT_EXIT(EXITCODE) \
(_PyInitError){.prefix = NULL, .msg = NULL, .user_err = 0, .exitcode = (EXITCODE)}
#define _Py_INIT_HAS_EXITCODE(err) \
(err.exitcode != -1)
#define _Py_INIT_FAILED(err) \
(err.msg != NULL ||
err.exitcode != -1
)
(err.msg != NULL ||
_Py_INIT_HAS_EXITCODE(err)
)
/* --- _PyWstrList ------------------------------------------------ */
...
...
Modules/main.c
View file @
4cb525a1
...
...
@@ -570,7 +570,12 @@ exit_sigint(void)
static
void
_Py_NO_RETURN
pymain_exit_error
(
_PyInitError
err
)
{
pymain_free
();
if
(
_Py_INIT_HAS_EXITCODE
(
err
))
{
/* If it's an error rather than a regular exit, leave Python runtime
alive: _Py_ExitInitError() uses the current exception and use
sys.stdout in this case. */
pymain_free
();
}
_Py_ExitInitError
(
err
);
}
...
...
Python/pylifecycle.c
View file @
4cb525a1
...
...
@@ -2172,7 +2172,7 @@ Py_FatalError(const char *msg)
void
_Py_NO_RETURN
_Py_ExitInitError
(
_PyInitError
err
)
{
if
(
err
.
exitcode
>=
0
)
{
if
(
_Py_INIT_HAS_EXITCODE
(
err
)
)
{
exit
(
err
.
exitcode
);
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment