Commit 62c34a6
authored
gh-152132: Fix Py_RunMain() to return an exit code (#153446)
* Fix Py_RunMain() to return an exit code, rather than calling
Py_Exit(), when running a script, a command, or the REPL.
* _PyRun_SimpleFile() now logs errors to stderr, for example if setting
__main__.__file__ fails.
* Add tests on Py_RunMain() exitcode.
* Rename functions:
* _PyRun_SimpleStringFlagsWithName() => _PyRun_SimpleString()
* _PyRun_SimpleFileObject() => _PyRun_SimpleFile()
* _PyRun_AnyFileObject() => _PyRun_AnyFile()
* _PyRun_InteractiveLoopObject() => _PyRun_InteractiveLoop()
* Change _PyRun_SimpleString(), _PyRun_SimpleFile(), _PyRun_AnyFile() and
_PyRun_InteractiveLoop() return type to PyObject*.
* pymain_repl() now displays the error if PySys_Audit() or
import _pyrepl failed.
* PyRun_SimpleFileExFlags() and PyRun_AnyFileExFlags() now log
PyUnicode_DecodeFSDefault() error. So these functions can no longer
return -1 with an exception set.
(cherry picked from commit fac72f1)
1 parent 5e08cb2 commit 62c34a6
8 files changed
Lines changed: 406 additions & 236 deletions
File tree
- Include/internal
- Lib/test
- Misc/NEWS.d/next/C_API
- Modules
- _testcapi
- Programs
- Python
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | 114 | | |
118 | 115 | | |
119 | 116 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | 23 | | |
29 | 24 | | |
30 | 25 | | |
| |||
33 | 28 | | |
34 | 29 | | |
35 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
71 | 74 | | |
72 | 75 | | |
73 | 76 | | |
| |||
117 | 120 | | |
118 | 121 | | |
119 | 122 | | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
126 | 133 | | |
127 | 134 | | |
128 | 135 | | |
| |||
554 | 561 | | |
555 | 562 | | |
556 | 563 | | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
557 | 613 | | |
558 | 614 | | |
559 | 615 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | 132 | | |
136 | 133 | | |
137 | 134 | | |
| |||
203 | 200 | | |
204 | 201 | | |
205 | 202 | | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | 203 | | |
210 | 204 | | |
211 | 205 | | |
| |||
243 | 237 | | |
244 | 238 | | |
245 | 239 | | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | 240 | | |
250 | 241 | | |
251 | 242 | | |
| |||
272 | 263 | | |
273 | 264 | | |
274 | 265 | | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | 266 | | |
279 | 267 | | |
280 | 268 | | |
| |||
310 | 298 | | |
311 | 299 | | |
312 | 300 | | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | 301 | | |
317 | 302 | | |
318 | 303 | | |
| |||
342 | 327 | | |
343 | 328 | | |
344 | 329 | | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | 330 | | |
349 | 331 | | |
350 | 332 | | |
| |||
382 | 364 | | |
383 | 365 | | |
384 | 366 | | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | 367 | | |
389 | 368 | | |
390 | 369 | | |
| |||
664 | 643 | | |
665 | 644 | | |
666 | 645 | | |
667 | | - | |
668 | | - | |
669 | | - | |
670 | 646 | | |
671 | 647 | | |
672 | 648 | | |
| |||
689 | 665 | | |
690 | 666 | | |
691 | 667 | | |
692 | | - | |
693 | | - | |
694 | | - | |
695 | 668 | | |
696 | 669 | | |
697 | 670 | | |
| |||
0 commit comments