summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
* gh-108767: Replace ctype.h functions with pyctype.h functions (#108772)Victor Stinner2023-09-011-4/+4
| | | | | | | | | | | | | | Replace <ctype.h> locale dependent functions with Python "pyctype.h" locale independent functions: * Replace isalpha() with Py_ISALPHA(). * Replace isdigit() with Py_ISDIGIT(). * Replace isxdigit() with Py_ISXDIGIT(). * Replace tolower() with Py_TOLOWER(). Leave Modules/_sre/sre.c unchanged, it uses locale dependent functions on purpose. Include explicitly <ctype.h> in _decimal.c to get isascii().
* gh-108634: PyInterpreterState_New() no longer calls Py_FatalError() (#108748)Victor Stinner2023-09-013-45/+87
| | | | | | | | | | | | pycore_create_interpreter() now returns a status, rather than calling Py_FatalError(). * PyInterpreterState_New() now calls Py_ExitStatusException() instead of calling Py_FatalError() directly. * Replace Py_FatalError() with PyStatus in init_interpreter() and _PyObject_InitState(). * _PyErr_SetFromPyStatus() now raises RuntimeError, instead of ValueError. It can now call PyErr_NoMemory(), raise MemoryError, if it detects _PyStatus_NO_MEMORY() error message.
* gh-108727: Fix segfault due to missing tp_dealloc definition for ↵Irit Katriel2023-09-011-0/+1
| | | | CounterOptimizer_Type (GH-108734)
* gh-107603: Argument Clinic: Only include pycore_gc.h if needed (#108726)Victor Stinner2023-08-319-46/+22
| | | | | | | | | | | | | | | | | | | | Argument Clinic now only includes pycore_gc.h if PyGC_Head is needed, and only includes pycore_runtime.h if _Py_ID() is needed. * Add 'condition' optional argument to Clinic.add_include(). * deprecate_keyword_use() includes pycore_runtime.h when using the _PyID() function. * Fix rendering of includes: comments start at the column 35. * Mark PC/clinic/_wmimodule.cpp.h and "Objects/stringlib/clinic/*.h.h" header files as generated in .gitattributes. Effects: * 42 header files generated by AC no longer include the internal C API, instead of 4 header files before. For example, Modules/clinic/_abc.c.h no longer includes the internal C API. * Fix _testclinic_depr.c.h: it now always includes pycore_runtime.h to get _Py_ID().
* gh-108634: Py_TRACE_REFS uses a hash table (#108663)Victor Stinner2023-08-314-15/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Python built with "configure --with-trace-refs" (tracing references) is now ABI compatible with Python release build and debug build. Moreover, it now also supports the Limited API. Change Py_TRACE_REFS build: * Remove _PyObject_EXTRA_INIT macro. * The PyObject structure no longer has two extra members (_ob_prev and _ob_next). * Use a hash table (_Py_hashtable_t) to trace references (all objects): PyInterpreterState.object_state.refchain. * Py_TRACE_REFS build is now ABI compatible with release build and debug build. * Limited C API extensions can now be built with Py_TRACE_REFS: xxlimited, xxlimited_35, _testclinic_limited. * No longer rename PyModule_Create2() and PyModule_FromDefAndSpec2() functions to PyModule_Create2TraceRefs() and PyModule_FromDefAndSpec2TraceRefs(). * _Py_PrintReferenceAddresses() is now called before finalize_interp_delete() which deletes the refchain hash table. * test_tracemalloc find_trace() now also filters by size to ignore the memory allocated by _PyRefchain_Trace(). Test changes for Py_TRACE_REFS: * Add test.support.Py_TRACE_REFS constant. * Add test_sys.test_getobjects() to test sys.getobjects() function. * test_exceptions skips test_recursion_normalizing_with_no_memory() and test_memory_error_in_PyErr_PrintEx() if Python is built with Py_TRACE_REFS. * test_repl skips test_no_memory(). * test_capi skisp test_set_nomemory().
* GH-108614: Remove non-debug uses of `#if TIER_ONE` and `#if TIER_TWO` from ↵Mark Shannon2023-08-316-64/+121
| | | | `_POP_FRAME` op. (GH-108685)
* gh-107149: Make PyUnstable_ExecutableKinds public (#108440)Victor Stinner2023-08-311-6/+6
| | | | | | Move PyUnstable_ExecutableKinds and associated macros from the internal C API to the public C API. Rename constants: replace "PY_" prefix with "PyUnstable_" prefix.
* gh-108654: restore comprehension locals before handling exception (#108659)Carl Meyer2023-08-301-14/+53
| | | Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
* gh-108488: Initialize JUMP_BACKWARD cache to 0, not 17 (#108591)Guido van Rossum2023-08-291-1/+3
| | | This mis-initialization caused the executor optimization to kick in sooner than intended. It also set the lower 4 bits of the counter to `1` -- those bits are supposed to be reserved (the actual counter is in the upper 12 bits).
* gh-107557: Remove unnecessary SAVE_IP instructions (#108583)Guido van Rossum2023-08-291-24/+116
| | | | | Also remove NOP instructions. The "stubs" are not optimized in this fashion (their SAVE_IP should always be preserved since it's where to jump next, and they don't contain NOPs by their nature).
* gh-106320: Remove private pythonrun API (#108599)Victor Stinner2023-08-292-0/+2
| | | | | | | | | | | 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-107149: Rename _PyUnstable_GetUnaryIntrinsicName() function (#108441)Victor Stinner2023-08-281-2/+2
| | | | | | * Rename _PyUnstable_GetUnaryIntrinsicName() to PyUnstable_GetUnaryIntrinsicName() * Rename _PyUnstable_GetBinaryIntrinsicName() to PyUnstable_GetBinaryIntrinsicName().
* gh-108487: Move assert(self != NULL) down beyond DEOPT_IF() (#108510)Guido van Rossum2023-08-282-2/+2
|
* gh-107265: Fix initialize/remove_tools for ENTER_EXECUTOR case (gh-108482)Dong-hee Na2023-08-271-4/+32
|
* gh-107913: Fix possible losses of OSError error codes (GH-107930)Serhiy Storchaka2023-08-261-1/+3
| | | | | | Functions like PyErr_SetFromErrno() and SetFromWindowsErr() should be called immediately after using the C API which sets errno or the Windows error code.
* gh-106320: Remove private AC converter functions (#108505)Victor Stinner2023-08-262-1/+3
| | | | | | | | | | | | | | Move these private functions to the internal C API (pycore_abstract.h): * _Py_convert_optional_to_ssize_t() * _PyNumber_Index() Argument Clinic now emits #include "pycore_abstract.h" when these functions are used. The parser of the c-analyzer tool now uses a list of files which use the limited C API, rather than a list of files using the internal C API.
* GH-106581: Fix instrumentation in tier 2 (GH-108493)Brandt Bucher2023-08-253-12/+18
|
* gh-107265: Revert "Ensure _PyCode_Quicken does not handle ENTER_EXECUTOR" ↵Dong-hee Na2023-08-251-2/+0
| | | | | | | (#108485) This reverts commit d6ac5c7b105fe57266bd71248e3ada41fedb5ba9. Reason: the assert we just added could be triggered (see issue).
* gh-108444: Remove _PyLong_AsInt() function (#108461)Victor Stinner2023-08-251-1/+1
| | | | * Update Parser/asdl_c.py to regenerate Python/Python-ast.c. * Remove _PyLong_AsInt() alias to PyLong_AsInt().
* gh-106581: Split CALL_BOUND_METHOD_EXACT_ARGS into uops (#108462)Guido van Rossum2023-08-254-20/+143
| | | Instead of using `GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS)` we just add the macro elements of the latter to the macro for the former. This requires lengthening the uops array in struct opcode_macro_expansion. (It also required changes to stacking.py that were merged already.)
* gh-106320: Remove private _PyTraceback functions (#108453)Victor Stinner2023-08-241-3/+2
| | | | | | Move private functions to the internal C API (pycore_traceback.h): * _Py_DisplaySourceLine() * _PyTraceback_Add()
* gh-107265: Ensure _PyCode_Quicken does not handle ENTER_EXECUTOR (gh-108460)Dong-hee Na2023-08-241-0/+2
|
* gh-108444: Replace _PyLong_AsInt() with PyLong_AsInt() (#108459)Victor Stinner2023-08-245-10/+10
| | | | | | Change generated by the command: sed -i -e 's!_PyLong_AsInt!PyLong_AsInt!g' \ $(find -name "*.c" -o -name "*.h")
* gh-108444: Argument Clinic uses PyLong_AsInt() (#108458)Victor Stinner2023-08-247-37/+37
| | | | Argument Clinic now uses the new public PyLong_AsInt(), rather than the old name _PyLong_AsInt().
* gh-106320: Remove private _PySys functions (#108452)Victor Stinner2023-08-245-1/+7
| | | | | | | | | | Move private functions to the internal C API (pycore_sysmodule.h): * _PySys_GetAttr() * _PySys_GetSizeOf() No longer export most of these functions. Fix also a typo in Include/cpython/optimizer.h: add a missing space.
* gh-106320: Remove private _PyDict functions (#108449)Victor Stinner2023-08-241-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Move private functions to the internal C API (pycore_dict.h): * _PyDictView_Intersect() * _PyDictView_New() * _PyDict_ContainsId() * _PyDict_DelItemId() * _PyDict_DelItem_KnownHash() * _PyDict_GetItemIdWithError() * _PyDict_GetItem_KnownHash() * _PyDict_HasSplitTable() * _PyDict_NewPresized() * _PyDict_Next() * _PyDict_Pop() * _PyDict_SetItemId() * _PyDict_SetItem_KnownHash() * _PyDict_SizeOf() No longer export most of these functions. Move also the _PyDictViewObject structure to the internal C API. Move dict_getitem_knownhash() function from _testcapi to the _testinternalcapi extension. Update test_capi.test_dict for this change.
* gh-106581: Fix two bugs in the code generator's copy optimization (#108380)Guido van Rossum2023-08-241-3/+0
| | | | | | | | | | | | | | | | | | I was comparing the last preceding poke with the *last* peek, rather than the *first* peek. Unfortunately this bug obscured another bug: When the last preceding poke is UNUSED, the first peek disappears, leaving the variable unassigned. This is how I fixed it: - Rename CopyEffect to CopyItem. - Change CopyItem to contain StackItems instead of StackEffects. - Update those StackItems when adjusting the manager higher or lower. - Assert that those StackItems' offsets are equivalent. - Other clever things. --------- Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
* gh-106320: Remove private PyLong C API functions (#108429)Victor Stinner2023-08-241-2/+3
| | | | | | | | | | | | | | | | Remove private PyLong C API functions: * _PyLong_AsByteArray() * _PyLong_DivmodNear() * _PyLong_Format() * _PyLong_Frexp() * _PyLong_FromByteArray() * _PyLong_FromBytes() * _PyLong_GCD() * _PyLong_Lshift() * _PyLong_Rshift() Move these functions to the internal C API. No longer export _PyLong_FromBytes() function.
* gh-108308: Remove _PyDict_GetItemStringWithError() function (#108426)Victor Stinner2023-08-243-30/+36
| | | | | | | | 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-242-13/+19
|
* gh-108308: config_dict_get() uses PyDict_GetItemRef() (#108371)Victor Stinner2023-08-231-6/+19
| | | | Replace _PyDict_GetItemStringWithError() with PyDict_GetItemRef() in config_dict_get() to get a strong reference to the item.
* gh-108308: Replace _PyDict_GetItemStringWithError() (#108372)Victor Stinner2023-08-233-24/+22
| | | | | | | Replace _PyDict_GetItemStringWithError() calls with PyDict_GetItemStringRef() which returns a strong reference to the item. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-105481: remove regen-opcode. Generated _PyOpcode_Caches in regen-cases. ↵Irit Katriel2023-08-238-9/+13
| | | | (#108367)
* gh-107265: Ensure de_instrument does not handle ENTER_EXECUTOR (#108366)Dong-hee Na2023-08-231-0/+1
|
* gh-108308: Replace PyDict_GetItem() with PyDict_GetItemRef() (#108309)Victor Stinner2023-08-234-32/+105
| | | | | | | | | Replace PyDict_GetItem() calls with PyDict_GetItemRef() or PyDict_GetItemWithError() to handle errors. * Replace PyLong_AS_LONG() with _PyLong_AsInt() and check for errors. * Check for PyDict_Contains() error. * pycore_init_builtins() checks for _PyType_Lookup() failure.
* gh-108113: Make it possible to optimize an AST (#108282)Irit Katriel2023-08-233-32/+47
|
* gh-106320: Remove _PyDict_GetItemStringWithError() function (#108313)Victor Stinner2023-08-224-1/+5
| | | | | | | | | 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.
* Ignore _Py_write_noraise() result: cast to (void) (#108291)Victor Stinner2023-08-223-7/+7
| | | | Code using _Py_write_noraise() usually cannot report. Ignore errors is the least surprising behavior for users.
* gh-107901: Fix missing line number on BACKWARD_JUMP at the end of a for loop ↵Irit Katriel2023-08-211-1/+1
| | | | (#108242)
* gh-108113: Make it possible to create an optimized AST (#108154)Irit Katriel2023-08-212-0/+28
|
* gh-107916: Save the error code before decoding the filename in ↵Serhiy Storchaka2023-08-211-0/+8
| | | | PyErr_SetFromErrnoWithFilename() etc (GH-107929)
* gh-107526: Revert "gh-100357: Convert several functions in bltinsmodule to ↵Nikita Sobolev2023-08-212-303/+99
| | | | AC" (#107542)
* gh-107915: Handle errors in C API functions PyErr_Set*() and PyErr_Format() ↵Serhiy Storchaka2023-08-191-8/+29
| | | | | | | | (GH-107918) Such C API functions as PyErr_SetString(), PyErr_Format(), PyErr_SetFromErrnoWithFilename() and many others no longer crash or ignore errors if it failed to format the error message or decode the filename. Instead, they keep a corresponding error.
* gh-108014: Add Py_IsFinalizing() function (#108032)Victor Stinner2023-08-182-2/+2
| | | Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-107944: Improve error message for function calls with bad keyword ↵Pablo Galindo Salgado2023-08-172-10/+35
| | | | arguments (#107969)
* gh-106581: Project through calls (#108067)Guido van Rossum2023-08-177-64/+264
| | | | This finishes the work begun in gh-107760. When, while projecting a superblock, we encounter a call to a short, simple function, the superblock will now enter the function using `_PUSH_FRAME`, continue through it, and leave it using `_POP_FRAME`, and then continue through the original code. Multiple frame pushes and pops are even possible. It is also possible to stop appending to the superblock in the middle of a called function, when running out of space or encountering an unsupported bytecode.
* GH-108035: Remove the `_PyCFrame` struct as it is no longer needed for ↵Mark Shannon2023-08-1713-67/+51
| | | | performance. (GH-108036)
* gh-106581: Split `CALL_PY_EXACT_ARGS` into uops (#107760)Guido van Rossum2023-08-168-58/+273
| | | | | | | | | | | | * Split `CALL_PY_EXACT_ARGS` into uops This is only the first step for doing `CALL` in Tier 2. The next step involves tracing into the called code object and back. After that we'll have to do the remaining `CALL` specialization. Finally we'll have to deal with `KW_NAMES`. Note: this moves setting `frame->return_offset` directly in front of `DISPATCH_INLINED()`, to make it easier to move it into `_PUSH_FRAME`.
* gh-105481: generate op IDs from bytecode.c instead of hard coding them in ↵Irit Katriel2023-08-162-168/+166
| | | | opcode.py (#107971)
* gh-105724: Add location information to `assert` errors (GH-105935)Nikita Sobolev2023-08-161-1/+1
|