summaryrefslogtreecommitdiffstats
path: root/Python/pythonrun.c
Commit message (Collapse)AuthorAgeFilesLines
* GH-65961: Stop setting `__cached__` on modules (GH-142165)Brett Cannon2025-12-111-6/+0
|
* gh-141070: Add PyUnstable_Object_Dump() function (#141072)Victor Stinner2025-11-181-4/+4
| | | | | | | | | | * Promote _PyObject_Dump() as a public function. * Keep _PyObject_Dump() alias to PyUnstable_Object_Dump() for backward compatibility. * Replace _PyObject_Dump() with PyUnstable_Object_Dump(). Co-authored-by: Peter Bierma <zintensitydev@gmail.com> Co-authored-by: Kumar Aditya <kumaraditya@python.org> Co-authored-by: Petr Viktorin <encukou@gmail.com>
* gh-135801: Add the module parameter to compile() etc (GH-139652)Serhiy Storchaka2025-11-131-6/+32
| | | | | | | Many functions related to compiling or parsing Python code, such as compile(), ast.parse(), symtable.symtable(), and importlib.abc.InspectLoader.source_to_code() now allow to pass the module name used when filtering syntax warnings.
* gh-137576: Fix for Basic REPL showing incorrect code in tracebacks with ↵adam j hartz2025-08-141-2/+25
| | | | | `PYTHONSTARTUP` (#137625) Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
* gh-108512: Add and use new replacements for PySys_GetObject() (GH-111035)Serhiy Storchaka2025-05-281-9/+9
| | | | | Add functions PySys_GetAttr(), PySys_GetAttrString(), PySys_GetOptionalAttr() and PySys_GetOptionalAttrString().
* gh-132775: Add _PyCode_GetScriptXIData() (gh-133480)Eric Snow2025-05-081-0/+20
| | | | | | | This converts functions, code, str, bytes, bytearray, and memoryview objects to PyCodeObject, and ensure that the object looks like a script. That means no args, no return, and no closure. _PyCode_GetPureScriptXIData() takes it a step further and ensures there are no globals. We also add _PyObject_SupportedAsScript() to the internal C-API.
* gh-126835: Rename `ast_opt.c` to `ast_preprocess.c` and related stuff after ↵Yan Yanchii2025-05-041-1/+1
| | | | moving const folding to the peephole optimizier (#131830)
* gh-131238: Remove more includes from pycore_interp.h (#131480)Victor Stinner2025-03-191-0/+2
|
* gh-130080: implement PEP 765 (#130087)Irit Katriel2025-03-171-5/+4
|
* GH-131238: More refactoring of core header files (GH-131351)Mark Shannon2025-03-171-0/+1
| | | | Adds new pycore_stats.h header file to help break dependencies involving the pycore_code.h header.
* gh-117174: Add a new route in linecache to fetch interactive source code ↵Pablo Galindo Salgado2025-03-101-1/+1
| | | | (#117500)
* Postpone <stdbool.h> inclusion after Python.h (#130641)Hugo Beauzée-Luyssen2025-02-281-2/+2
| | | | | | | Remove inclusions prior to Python.h. <stdbool.h> will cause <features.h> to be included before Python.h can define some macros to enable some additional features, causing multiple types not to be defined down the line.
* gh-130163: Fix crashes related to PySys_GetObject() (GH-130503)Serhiy Storchaka2025-02-251-28/+72
| | | | | | | | The use of PySys_GetObject() and _PySys_GetAttr(), which return a borrowed reference, has been replaced by using one of the following functions, which return a strong reference and distinguish a missing attribute from an error: _PySys_GetOptionalAttr(), _PySys_GetOptionalAttrString(), _PySys_GetRequiredAttr(), and _PySys_GetRequiredAttrString().
* GH-130396: Use computed stack limits on linux (GH-130398)Mark Shannon2025-02-251-24/+3
| | | | | | | | | | | * Implement C recursion protection with limit pointers for Linux, MacOS and Windows * Remove calls to PyOS_CheckStack * Add stack protection to parser * Make tests more robust to low stacks * Improve error messages for stack overflow
* GH-91079: Revert "GH-91079: Implement C stack limits using addresses, not ↵Petr Viktorin2025-02-241-3/+24
| | | | | | | | | counters. (GH-130007)" for now (GH130413) Revert "GH-91079: Implement C stack limits using addresses, not counters. (GH-130007)" for now Unfortunatlely, the change broke some buildbots. This reverts commit 2498c22fa0a2b560491bc503fa676585c1a603d0.
* GH-91079: Implement C stack limits using addresses, not counters. (GH-130007)Mark Shannon2025-02-191-24/+3
| | | | | | | | | | | | * Implement C recursion protection with limit pointers * Remove calls to PyOS_CheckStack * Add stack protection to parser * Make tests more robust to low stacks * Improve error messages for stack overflow
* gh-128130: Fix unhandled keyboard interrupt data race (gh-129975)Sam Gross2025-02-131-25/+8
| | | | | | | | | | Use an atomic operation when setting `_PyRuntime.signals.unhandled_keyboard_interrupt`. We now only clear the variable at the start of `_PyRun_Main`, which is the same function where we check it. This avoids race conditions where previously another thread might call `run_eval_code_obj()` and erroneously clear the unhandled keyboard interrupt.
* gh-128911: Use PyImport_ImportModuleAttr() function (#129657)Victor Stinner2025-02-051-23/+6
| | | | | | * Replace PyImport_ImportModule() + PyObject_GetAttr() with PyImport_ImportModuleAttr(). * Replace PyImport_ImportModule() + PyObject_GetAttrString() with PyImport_ImportModuleAttrString().
* gh-127350: Add Py_fopen() and Py_fclose() functions (#127821)Victor Stinner2025-01-061-1/+1
|
* Free arena on _PyCompile_AstOptimize failure in Py_CompileStringObject ↵Berker Peksag2024-12-161-0/+1
| | | | | | (GH-127910) After commit 10a91d7e9 introduced arena cleanup, commit 2dfbd4f36 removed the free call when _PyCompile_AstOptimize fails.
* gh-125842: Fix `sys.exit(0xffff_ffff)` on Windows (#125896)Sam Gross2024-10-241-33/+47
| | | | | | | | | | On Windows, `long` is a signed 32-bit integer so it can't represent `0xffff_ffff` without overflow. Windows exit codes are unsigned 32-bit integers, so if a child process exits with `-1`, it will be represented as `0xffff_ffff`. Also fix a number of other possible cases where `_Py_HandleSystemExit` could return with an exception set, leading to a `SystemError` (or fatal error in debug builds) later on during shutdown.
* gh-125604: Move _Py_AuditHookEntry, etc. Out of pycore_runtime.h (gh-125605)Eric Snow2024-10-181-1/+2
| | | | | | | | | | | | This is essentially a cleanup, moving a handful of API declarations to the header files where they fit best, creating new ones when needed. We do the following: * add pycore_debug_offsets.h and move _Py_DebugOffsets, etc. there * inline struct _getargs_runtime_state and struct _gilstate_runtime_state in _PyRuntimeState * move struct _reftracer_runtime_state to the existing pycore_object_state.h * add pycore_audit.h and move to it _Py_AuditHookEntry , _PySys_Audit(), and _PySys_ClearAuditHooks * add audit.h and cpython/audit.h and move the existing audit-related API there *move the perfmap/trampoline API from cpython/sysmodule.h to cpython/ceval.h, and remove the now-empty cpython/sysmodule.h
* gh-121804: always show error location for SyntaxError's in basic repl (#123202)Sergey B Kirpichev2024-09-031-0/+31
|
* gh-111201: A new Python REPL (GH-111567)Pablo Galindo Salgado2024-05-051-2/+0
| | | | | | | Co-authored-by: Łukasz Langa <lukasz@langa.pl> Co-authored-by: Marta Gómez Macías <mgmacias@google.com> Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* gh-116180: Check the globals argument in PyRun_* C API (GH-116637)NGRsoftlab2024-05-021-9/+12
| | | | | It used to crash when passing NULL or non-dict as globals. Now it sets a SystemError.
* gh-116437: Use new C API PyDict_Pop() to simplify the code (GH-116438)Serhiy Storchaka2024-03-071-5/+5
|
* gh-115914: minor cleanup: simplify filename_obj assignment in ↵Sergii K2024-02-251-4/+1
| | | | | PyRun_AnyFileExFlags (gh-115916) This simplifies the code: less lines, easier to read. Logically equivalent, as any compiler likely already determined.
* gh-108082: Use PyErr_FormatUnraisable() (GH-111580)Serhiy Storchaka2023-11-021-2/+3
| | | | | | Replace most of calls of _PyErr_WriteUnraisableMsg() and some calls of PyErr_WriteUnraisable(NULL) with PyErr_FormatUnraisable(). Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-67224: Show source lines in tracebacks when using the -c option when ↵Pablo Galindo Salgado2023-10-261-19/+61
| | | | running Python (#111200)
* gh-111132: Fix crash on interactive_filename in `run_mod` (#111136)Nikita Sobolev2023-10-201-1/+3
|
* gh-110912: Correctly display tracebacks for MemoryError exceptions using the ↵Pablo Galindo Salgado2023-10-161-4/+1
| | | | traceback module (#110921)
* gh-110805: Allow the repl to show source code and complete tracebacks (#110775)Pablo Galindo Salgado2023-10-131-12/+72
|
* gh-110721: Use the traceback module for PyErr_Display() and fallback to the ↵Pablo Galindo Salgado2023-10-121-518/+59
| | | | C implementation (#110702)
* gh-110079: Remove extern "C" { ...} in C code (#110080)Victor Stinner2023-09-291-9/+0
|
* gh-109611: Add convenient C API function _PyFile_Flush() (GH-109612)Serhiy Storchaka2023-09-231-10/+2
|
* gh-109179: Fix traceback display for SyntaxErrors with notes (#109197)Irit Katriel2023-09-111-13/+11
|
* gh-108765: Cleanup #include in Python/*.c files (#108977)Victor Stinner2023-09-061-5/+5
| | | Mention one symbol imported by each #include.
* gh-106320: Remove private pythonrun API (#108599)Victor Stinner2023-08-291-0/+1
| | | | | | | | | | | Remove these private functions from the public C API: * _PyRun_AnyFileObject() * _PyRun_InteractiveLoopObject() * _PyRun_SimpleFileObject() * _Py_SourceAsString() Move them to the internal C API: add a new pycore_pythonrun.h header file. No longer export these functions.
* gh-108308: Remove _PyDict_GetItemStringWithError() function (#108426)Victor Stinner2023-08-241-1/+0
| | | | | | | | Remove the internal _PyDict_GetItemStringWithError() function. It can now be replaced with the new public PyDict_ContainsString() and PyDict_GetItemStringRef() functions. getargs.c now now uses a strong reference for current_arg. find_keyword() returns a strong reference.
* gh-108314: Add PyDict_ContainsString() function (#108323)Victor Stinner2023-08-241-9/+14
|
* gh-108113: Make it possible to optimize an AST (#108282)Irit Katriel2023-08-231-21/+1
|
* gh-106320: Remove _PyDict_GetItemStringWithError() function (#108313)Victor Stinner2023-08-221-0/+1
| | | | | | | | | Remove private _PyDict_GetItemStringWithError() function of the public C API: the new PyDict_GetItemStringRef() can be used instead. * Move private _PyDict_GetItemStringWithError() to the internal C API. * _testcapi get_code_extra_index() uses PyDict_GetItemStringRef(). Avoid using private functions in _testcapi which tests the public C API.
* gh-108113: Make it possible to create an optimized AST (#108154)Irit Katriel2023-08-211-0/+25
|
* gh-106521: Remove _PyObject_LookupAttr() function (GH-106642)Serhiy Storchaka2023-07-121-2/+2
|
* gh-106023: Update code using _PyObject_FastCall() (#106257)Victor Stinner2023-06-301-5/+2
| | | Replace _PyObject_FastCall() calls with PyObject_Vectorcall().
* gh-106084: Remove old PyObject call aliases (#106085)Victor Stinner2023-06-261-2/+2
| | | | | | | | | | | | | | Remove old aliases which were kept backwards compatibility with Python 3.8: * _PyObject_CallMethodNoArgs() * _PyObject_CallMethodOneArg() * _PyObject_CallOneArg() * _PyObject_FastCallDict() * _PyObject_Vectorcall() * _PyObject_VectorcallMethod() * _PyVectorcall_Function() Update code which used these aliases to use new names.
* gh-106033: Get rid of new occurrences of PyDict_GetItem and PyObject_HasAttr ↵Serhiy Storchaka2023-06-231-7/+5
| | | | | | | | (GH-106034) These functions are broken by design because they discard any exceptions raised inside, including MemoryError and KeyboardInterrupt. They should not be used in new code.
* gh-105922: Use PyImport_AddModuleRef() function (#105999)Victor Stinner2023-06-221-1/+1
| | | | Replace PyImport_AddModuleObject() + Py_XNewRef() with PyImport_AddModuleRef() to get directly a strong reference.
* gh-105922: Add PyImport_AddModuleRef() function (#105923)Victor Stinner2023-06-201-2/+2
| | | | | | * Add tests on PyImport_AddModuleRef(), PyImport_AddModule() and PyImport_AddModuleObject(). * pythonrun.c: Replace Py_XNewRef(PyImport_AddModule(name)) with PyImport_AddModuleRef(name).
* gh-105922: Refactor PyRun_InteractiveOneObjectEx() (#105925)Victor Stinner2023-06-191-74/+108
| | | | | | | | | | | Refactor PyRun_InteractiveOneObjectEx(), _PyRun_SimpleFileObject() and PyRun_SimpleStringFlags(): * Keep a strong reference to the __main__ module while using its dictionary (PyModule_GetDict()). Use PyImport_AddModule() with Py_XNewRef(). * Declare variables closer to where they are defined. * Rename variables to use name longer than 1 character. * Add pyrun_one_parse_ast() sub-function.