Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 852ba7e

Browse files
committed
Patch #672053: Return a result from Py_Main, instead of exiting.
1 parent e98922f commit 852ba7e

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

Modules/main.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ PYTHONCASEOK : ignore case in 'import' statements (Windows).\n\
8888
";
8989

9090

91-
static void
91+
static int
9292
usage(int exitcode, char* program)
9393
{
9494
FILE *f = exitcode ? stderr : stdout;
@@ -105,14 +105,14 @@ usage(int exitcode, char* program)
105105
#if defined(__VMS)
106106
if (exitcode == 0) {
107107
/* suppress 'error' message */
108-
exit(1);
108+
return 1;
109109
}
110110
else {
111111
/* STS$M_INHIB_MSG + SS$_ABORT */
112-
exit(0x1000002c);
112+
return 0x1000002c;
113113
}
114114
#else
115-
exit(exitcode);
115+
return exitcode;
116116
#endif
117117
/*NOTREACHED*/
118118
}
@@ -194,7 +194,7 @@ Py_Main(int argc, char **argv)
194194
fprintf(stderr,
195195
"-Q option should be `-Qold', "
196196
"`-Qwarn', `-Qwarnall', or `-Qnew' only\n");
197-
usage(2, argv[0]);
197+
return usage(2, argv[0]);
198198
/* NOTREACHED */
199199

200200
case 'i':
@@ -255,18 +255,18 @@ Py_Main(int argc, char **argv)
255255
/* This space reserved for other options */
256256

257257
default:
258-
usage(2, argv[0]);
258+
return usage(2, argv[0]);
259259
/*NOTREACHED*/
260260

261261
}
262262
}
263263

264264
if (help)
265-
usage(0, argv[0]);
265+
return usage(0, argv[0]);
266266

267267
if (version) {
268268
fprintf(stderr, "Python %s\n", PY_VERSION);
269-
exit(0);
269+
return 0;
270270
}
271271

272272
if (!saw_inspect_flag &&
@@ -291,7 +291,7 @@ Py_Main(int argc, char **argv)
291291
if ((fp = fopen(filename, "r")) == NULL) {
292292
fprintf(stderr, "%s: can't open file '%s'\n",
293293
argv[0], filename);
294-
exit(2);
294+
return 2;
295295
}
296296
else if (skipfirstline) {
297297
int ch;

0 commit comments

Comments
 (0)