| Commit message (Collapse) | Author | Age |
| |
|
| |
|
|
|
|
| |
Adds new pycore_stats.h header file to help break dependencies involving the pycore_code.h header.
|
|
|
|
| |
(#117500)
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
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().
|
|
|
|
|
|
|
|
|
|
|
| |
* 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
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
* Replace PyImport_ImportModule() + PyObject_GetAttr() with
PyImport_ImportModuleAttr().
* Replace PyImport_ImportModule() + PyObject_GetAttrString() with
PyImport_ImportModuleAttrString().
|
| |
|
|
|
|
|
|
| |
(GH-127910)
After commit 10a91d7e9 introduced arena cleanup, commit 2dfbd4f36
removed the free call when _PyCompile_AstOptimize fails.
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
| |
It used to crash when passing NULL or non-dict as globals.
Now it sets a SystemError.
|
| |
|
|
|
|
|
| |
PyRun_AnyFileExFlags (gh-115916)
This simplifies the code: less lines, easier to read. Logically equivalent, as any compiler likely already determined.
|
|
|
|
|
|
| |
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>
|
|
|
|
| |
running Python (#111200)
|
| |
|
|
|
|
| |
traceback module (#110921)
|
| |
|
|
|
|
| |
C implementation (#110702)
|
| |
|
| |
|
| |
|
|
|
| |
Mention one symbol imported by each #include.
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
|
|
| |
Replace _PyObject_FastCall() calls with PyObject_Vectorcall().
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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-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.
|
|
|
|
| |
Replace PyImport_AddModuleObject() + Py_XNewRef() with
PyImport_AddModuleRef() to get directly a strong reference.
|
|
|
|
|
|
| |
* Add tests on PyImport_AddModuleRef(), PyImport_AddModule() and
PyImport_AddModuleObject().
* pythonrun.c: Replace Py_XNewRef(PyImport_AddModule(name)) with
PyImport_AddModuleRef(name).
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
| |
(#102816)
|
|
|
|
| |
sys.last_value,sys.last_traceback (#102779)
|
| |
|
|
|
|
| |
(#102743)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This change is almost entirely moving code around and hiding import state behind internal API. We introduce no changes to behavior, nor to non-internal API. (Since there was already going to be a lot of churn, I took this as an opportunity to re-organize import.c into topically-grouped sections of code.) The motivation is to simplify a number of upcoming changes.
Specific changes:
* move existing import-related code to import.c, wherever possible
* add internal API for interacting with import state (both global and per-interpreter)
* use only API outside of import.c (to limit churn there when changing the location, etc.)
* consolidate the import-related state of PyInterpreterState into a single struct field (this changes layout slightly)
* add macros for import state in import.c (to simplify changing the location)
* group code in import.c into sections
*remove _PyState_AddModule()
https://github.com/python/cpython/issues/101758
|