cpython/Include/internal
Victor Stinner 3d9a42049e
[3.13] gh-152132: Fix Py_RunMain() to return an exit code (#153446) (#153455) (#153458)
[3.14] gh-152132: Fix Py_RunMain() to return an exit code (#153446) (#153455)

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 fac72f1ee9)
(cherry picked from commit 62c34a62c2)
2026-07-09 22:50:58 +02:00
..
mimalloc [3.13] Doc: fix duplicated words (GH-136086) (#137357) 2025-08-04 06:41:47 +08:00
pycore_abstract.h
pycore_asdl.h
pycore_ast.h
pycore_ast_state.h
pycore_atexit.h [3.13] gh-127791: Fix, document, and test PyUnstable_AtExit (GH-127793) (#127819) 2024-12-11 13:40:45 +00:00
pycore_backoff.h [3.13] gh-129259: Fix AIX build failures caused by incorrect struct alignment (GH-144917) 2026-03-24 02:47:53 +01:00
pycore_bitutils.h
pycore_blocks_output_buffer.h
pycore_brc.h
pycore_bytes_methods.h
pycore_bytesobject.h [3.13] gh-133767: Fix use-after-free in the unicode-escape decoder with an error handler (GH-129648) (GH-133944) 2025-05-20 14:46:57 +02:00
pycore_call.h
pycore_capsule.h
pycore_cell.h
pycore_ceval.h [3.13] gh-143228: Fix UAF in perf trampoline during finalization (GH-143233) (#143248) 2025-12-28 14:32:16 +00:00
pycore_ceval_state.h [3.13] gh-143228: Fix UAF in perf trampoline during finalization (GH-143233) (#143248) 2025-12-28 14:32:16 +00:00
pycore_code.h [3.13] gh-129259: Fix AIX build failures caused by incorrect struct alignment (GH-144917) 2026-03-24 02:47:53 +01:00
pycore_codecs.h
pycore_compile.h
pycore_complexobject.h
pycore_condvar.h [3.13] gh-131082: Add missing guards for WIN32_LEAN_AND_MEAN (GH-131044) (#131084) 2025-03-11 11:56:54 +00:00
pycore_context.h [3.13] gh-121546: Disable contextvar caching on free-threading build (GH-121740) (#121808) 2024-07-15 16:53:52 -04:00
pycore_critical_section.h
pycore_crossinterp.h
pycore_descrobject.h
pycore_dict.h [3.13] gh-120974: Make asyncio swap_current_task safe in free-threaded build (GH-122317) (#122612) 2024-08-02 13:58:24 +00:00
pycore_dict_state.h
pycore_dtoa.h
pycore_emscripten_signal.h
pycore_emscripten_trampoline.h
pycore_exceptions.h [3.13] gh-129668: Fix thread-safety of MemoryError freelist in free threaded build (gh-129704) (gh-129742) 2025-02-06 13:27:30 -05:00
pycore_faulthandler.h
pycore_fileutils.h
pycore_fileutils_windows.h
pycore_floatobject.h
pycore_flowgraph.h
pycore_format.h
pycore_frame.h [3.13] gh-140815: Fix faulthandler for invalid/freed frame (#140921) (#140985) 2025-11-05 18:39:28 +01:00
pycore_freelist.h
pycore_function.h
pycore_gc.h [3.13] GH-124567: Revert the Incremental GC in 3.13 (#124770) 2024-09-30 21:27:29 +00:00
pycore_genobject.h
pycore_getopt.h
pycore_gil.h
pycore_global_objects.h [3.13] gh-125268: Use static string for "1e309" in AST (GH-125272) (GH-125280) 2024-10-24 13:59:23 -04:00
pycore_global_objects_fini_generated.h [3.13] gh-125268: Use static string for "1e309" in AST (GH-125272) (GH-125280) 2024-10-24 13:59:23 -04:00
pycore_global_strings.h [3.13] gh-125268: Use static string for "1e309" in AST (GH-125272) (GH-125280) 2024-10-24 13:59:23 -04:00
pycore_hamt.h
pycore_hashtable.h
pycore_identifier.h
pycore_import.h [3.13] gh-126688: Reinit import lock after fork (GH-126692) (GH-126765) 2024-11-12 22:00:42 +00:00
pycore_importdl.h [3.13] gh-122907: Fix Builds Without HAVE_DYNAMIC_LOADING Set (gh-122952) (#122984) 2024-12-03 16:46:30 +00:00
pycore_initconfig.h
pycore_instruction_sequence.h
pycore_instruments.h
pycore_interp.h [3.13] gh-137400: Fix thread-safety issues when profiling all threads (gh-137518) (gh-137733) 2025-10-09 11:42:47 -04:00
pycore_intrinsics.h
pycore_jit.h
pycore_list.h
pycore_llist.h
pycore_lock.h [3.13] gh-136759: revert rename lock.h to pylock.h (GH-137041) (#137075) (#137166) 2025-07-28 12:19:32 +00:00
pycore_long.h [3.13] gh-143050: Correct PyLong_FromString() to use _PyLong_Negate() (#145901) (#147437) 2026-03-31 17:06:38 +02:00
pycore_memoryobject.h
pycore_mimalloc.h [3.13] gh-122584: Import mimalloc headers in a C++ context (GH-122587) (#123035) 2024-08-16 01:49:17 -07:00
pycore_modsupport.h
pycore_moduleobject.h [3.13] gh-123930: Better error for "from imports" when script shadows module (GH-123929) (#125937) 2024-10-24 19:37:31 +00:00
pycore_namespace.h
pycore_object.h [3.13] gh-153083: Defer GC tracking of an array to the end of construction. (gh-153284) (gh-153338) 2026-07-08 13:12:43 +00:00
pycore_object_alloc.h
pycore_object_stack.h [3.13] gh-125859: Fix crash when gc.get_objects is called during GC (GH-125882) (GH-125921) 2024-10-24 14:08:15 +00:00
pycore_object_state.h
pycore_obmalloc.h
pycore_obmalloc_init.h
pycore_opcode_metadata.h [3.13] gh-145008: Maintain stack consistency in CALL_BOUND_METHOD_EXACT_ARGS (GH-145015) 2026-03-03 04:09:02 +08:00
pycore_opcode_utils.h
pycore_optimizer.h
pycore_parking_lot.h
pycore_parser.h [3.13] gh-122581: Avoid data races when collecting parser statistics (GH-122694) (#122733) 2024-08-07 18:29:03 +05:30
pycore_pathconfig.h
pycore_pyarena.h
pycore_pyatomic_ft_wrappers.h [3.13] gh-128759: Fix accesses to tp_version_tag. (GH-129750) (GH-130042) 2025-02-12 10:43:25 -05:00
pycore_pybuffer.h
pycore_pyerrors.h [3.13] gh-126742: Add _PyErr_SetLocaleString, use it for gdbm & dlerror messages (GH-126746) (GH-128023) 2024-12-17 11:45:29 +00:00
pycore_pyhash.h [3.13] gh-149018: Use XML_SetHashSalt16Bytes in pyexpat/_elementtree when possible (GH-149023) 2026-06-09 14:45:59 +00:00
pycore_pylifecycle.h [3.13] gh-152132: Fix Py_RunMain() to return an exit code (#153446) (#153455) (#153458) 2026-07-09 22:50:58 +02:00
pycore_pymath.h [3.13] gh-142342: Fix m68k assembler operand constraints for %fpcr access (gh-142343) (#142459) 2025-12-09 14:13:35 +00:00
pycore_pymem.h [3.13] gh-116008: Detect freed thread state in faulthandler (#141988) (#142017) 2025-11-27 17:55:31 +01:00
pycore_pymem_init.h
pycore_pystate.h
pycore_pystats.h
pycore_pythonrun.h [3.13] gh-152132: Fix Py_RunMain() to return an exit code (#153446) (#153455) (#153458) 2026-07-09 22:50:58 +02:00
pycore_pythread.h [3.13] gh-87135: Hang non-main threads that attempt to acquire the GIL during finalization (GH-105805) (GH-137827) 2025-08-17 09:08:14 -07:00
pycore_qsbr.h [3.13] GH-133136: Revise QSBR to reduce excess memory held (gh-135473) (gh-136480) 2025-07-30 11:06:44 -07:00
pycore_range.h
pycore_runtime.h [3.13] gh-133256: Add _Py_NONSTRING macro (#133257) (#135135) 2025-06-04 17:10:35 +02:00
pycore_runtime_init.h [3.13] GH-124567: Revert the Incremental GC in 3.13 (#124770) 2024-09-30 21:27:29 +00:00
pycore_runtime_init_generated.h [3.13] gh-125268: Use static string for "1e309" in AST (GH-125272) (GH-125280) 2024-10-24 13:59:23 -04:00
pycore_semaphore.h [3.13] gh-131082: Add missing guards for WIN32_LEAN_AND_MEAN (GH-131044) (#131084) 2025-03-11 11:56:54 +00:00
pycore_setobject.h
pycore_signal.h
pycore_sliceobject.h
pycore_stackref.h
pycore_strhex.h
pycore_structseq.h
pycore_symtable.h
pycore_sysmodule.h [3.13] gh-130163: Fix crashes related to PySys_GetObject() (GH-130503) (GH-130556) 2025-02-25 22:50:26 +00:00
pycore_time.h [3.13] gh-121905: Consistently use "floating-point" instead of "floating point" (GH-121907) (GH-122012) 2024-07-19 09:13:08 +00:00
pycore_token.h
pycore_traceback.h
pycore_tracemalloc.h [3.13] gh-128679: Fix tracemalloc.stop() race conditions (#128897) 2025-01-18 23:39:07 +00:00
pycore_tstate.h [3.13] gh-121621: Move asyncio_running_loop to private struct (GH-121939) (#121943) 2024-07-18 01:52:39 -07:00
pycore_tuple.h
pycore_typeobject.h [3.13] gh-130230: Fix crash in pow() with only Decimal third argument (GH-130237) (GH-130246) 2025-02-18 13:18:37 +02:00
pycore_typevarobject.h
pycore_ucnhash.h
pycore_unicodeobject.h [3.13] gh-133767: Fix use-after-free in the unicode-escape decoder with an error handler (GH-129648) (GH-133944) 2025-05-20 14:46:57 +02:00
pycore_unicodeobject_generated.h [3.13] gh-125268: Use static string for "1e309" in AST (GH-125272) (GH-125280) 2024-10-24 13:59:23 -04:00
pycore_unionobject.h
pycore_uop_ids.h [3.13] gh-132744: Check recursion limit in _PY_FRAME_GENERAL (GH-132746) (GH-138032) 2025-08-22 20:25:24 +08:00
pycore_uop_metadata.h [3.13] gh-132744: Check recursion limit in _PY_FRAME_GENERAL (GH-132746) (GH-138032) 2025-08-22 20:25:24 +08:00
pycore_warnings.h
pycore_weakref.h [3.13] gh-135607: remove null checking of weakref list in dealloc of extension modules and objects (#135614) (#136126) 2025-07-01 11:26:52 +02:00