summaryrefslogtreecommitdiffstats
path: root/Include
Commit message (Collapse)AuthorAgeFilesLines
...
* gh-99845: Change _PyDict_KeysSize() return type to size_t (#99848)Victor Stinner2022-11-291-1/+1
| | | | | | | | * Change _PyDict_KeysSize() and shared_keys_usable_size() return type from signed (Py_ssize_t) to unsigned (size_t) type. * new_values() argument type is now unsigned (size_t). * init_inline_values() now uses size_t rather than int for the 'i' iterator variable. * type.__sizeof__() implementation now uses unsigned (size_t) type.
* Use _Py_RVALUE() in macros (#99844)Victor Stinner2022-11-285-6/+6
| | | | | | | | | | | | | | The following macros are modified to use _Py_RVALUE(), so they can no longer be used as l-value: * DK_LOG_SIZE() * _PyCode_CODE() * _PyList_ITEMS() * _PyTuple_ITEMS() * _Py_SLIST_HEAD() * _Py_SLIST_ITEM_NEXT() _PyCode_CODE() is private and other macros are part of the internal C API.
* gh-89653: PEP 670: Convert macros to functions (#99843)Victor Stinner2022-11-288-27/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Convert macros to static inline functions to avoid macro pitfalls, like duplication of side effects: * DK_ENTRIES() * DK_UNICODE_ENTRIES() * PyCode_GetNumFree() * PyFloat_AS_DOUBLE() * PyInstanceMethod_GET_FUNCTION() * PyMemoryView_GET_BASE() * PyMemoryView_GET_BUFFER() * PyMethod_GET_FUNCTION() * PyMethod_GET_SELF() * PySet_GET_SIZE() * _PyHeapType_GET_MEMBERS() Changes: * PyCode_GetNumFree() casts PyCode_GetNumFree.co_nfreevars from int to Py_ssize_t to be future proof, and because Py_ssize_t is commonly used in the C API. * PyCode_GetNumFree() doesn't cast its argument: the replaced macro already required the exact type PyCodeObject*. * Add assertions in some functions using "CAST" macros to check the arguments type when Python is built with assertions (debug build). * Remove an outdated comment in unicodeobject.h.
* Revert "gh-98724: Fix Py_CLEAR() macro side effects" (#99737)Victor Stinner2022-11-242-36/+27
| | | | | Revert "gh-98724: Fix Py_CLEAR() macro side effects (#99100)" This reverts commit c03e05c2e72f3ea5e797389e7d1042eef85ad37a.
* gh-64490: Fix bugs in argument clinic varargs processing (#32092)colorfulappl2022-11-244-0/+25
|
* gh-99706: unicodeobject: Fix padding in `PyASCIIObject.state` (GH-99707)David Hewitt2022-11-241-1/+1
|
* gh-79315: Add Include/cpython/memoryobject.h header (#99723)Victor Stinner2022-11-232-41/+45
| | | | Move non-limited C API from Include/memoryobject.h to a new Include/cpython/memoryobject.h header file.
* GH-98831: Add `macro` and `op` and their implementation to DSL (#99495)Guido van Rossum2022-11-231-0/+6
| | | | | | | | | | | | | | Newly supported interpreter definition syntax: - `op(NAME, (input_stack_effects -- output_stack_effects)) { ... }` - `macro(NAME) = OP1 + OP2;` Also some other random improvements: - Convert `WITH_EXCEPT_START` to use stack effects - Fix lexer to balk at unrecognized characters, e.g. `@` - Fix moved output names; support object pointers in cache - Introduce `error()` method to print errors - Introduce read_uint16(p) as equivalent to `*p` Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
* gh-91053: Add an optional callback that is invoked whenever a function is ↵mpage2022-11-223-0/+57
| | | | modified (#98175)
* gh-47146: Soft-deprecate structmember.h, expose its contents via Python.h ↵Petr Viktorin2022-11-222-57/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (GH-99014) The ``structmember.h`` header is deprecated, though it continues to be available and there are no plans to remove it. There are no deprecation warnings. Old code can stay unchanged (unless the extra include and non-namespaced macros bother you greatly). Specifically, no uses in CPython are updated -- that would just be unnecessary churn. The ``structmember.h`` header is deprecated, though it continues to be available and there are no plans to remove it. Its contents are now available just by including ``Python.h``, with a ``Py`` prefix added if it was missing: - `PyMemberDef`, `PyMember_GetOne` and`PyMember_SetOne` - Type macros like `Py_T_INT`, `Py_T_DOUBLE`, etc. (previously ``T_INT``, ``T_DOUBLE``, etc.) - The flags `Py_READONLY` (previously ``READONLY``) and `Py_AUDIT_READ` (previously all uppercase) Several items are not exposed from ``Python.h``: - `T_OBJECT` (use `Py_T_OBJECT_EX`) - `T_NONE` (previously undocumented, and pretty quirky) - The macro ``WRITE_RESTRICTED`` which does nothing. - The macros ``RESTRICTED`` and ``READ_RESTRICTED``, equivalents of `Py_AUDIT_READ`. - In some configurations, ``<stddef.h>`` is not included from ``Python.h``. It should be included manually when using ``offsetof()``. The deprecated header continues to provide its original contents under the original names. Your old code can stay unchanged, unless the extra include and non-namespaced macros bother you greatly. There is discussion on the issue to rename `T_PYSSIZET` to `PY_T_SSIZE` or similar. I chose not to do that -- users will probably copy/paste that with any spelling, and not renaming it makes migration docs simpler. Co-Authored-By: Alexander Belopolsky <abalkin@users.noreply.github.com> Co-Authored-By: Matthias Braun <MatzeB@users.noreply.github.com>
* gh-96002: Add functional test for Argument Clinic (#96178)colorfulappl2022-11-214-0/+15
| | | | Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* gh-99284: [ctypes] remove `_use_broken_old_ctypes_structure_semantics_` ↵Nikita Sobolev2022-11-194-5/+0
| | | | | (GH-99285) It was untested and undocumented. No code has been found in the wild that ever used it.
* GH-99298: Clean up attribute specializations (GH-99398)Brandt Bucher2022-11-171-3/+3
|
* GH-98686: Get rid of BINARY_OP_GENERIC and COMPARE_OP_GENERIC (GH-99399)Brandt Bucher2022-11-172-89/+87
|
* gh-81057: Move the global Dict-Related Versions to _PyRuntimeState (gh-99497)Eric Snow2022-11-166-26/+67
| | | | | We also move the global func version. https://github.com/python/cpython/issues/81057
* gh-81057: Move contextvars-related Globals to _PyRuntimeState (gh-99400)Eric Snow2022-11-165-4/+33
| | | | | This is part of the effort to consolidate global variables, to make them easier to manage (and make it easier to later move some of them to PyInterpreterState). https://github.com/python/cpython/issues/81057
* gh-81057: Move More Globals in Core Code to _PyRuntimeState (gh-99516)Eric Snow2022-11-1610-21/+87
| | | https://github.com/python/cpython/issues/81057
* gh-81057: Move Globals in Core Code to _PyRuntimeState (gh-99496)Eric Snow2022-11-156-3/+56
| | | | | This is the first of several changes to consolidate non-object globals in core code. https://github.com/python/cpython/issues/81057
* Merge the 3.12.0a2 release into main.Thomas Wouters2022-11-1512-8/+65
|\
| * GH-99205: remove `_static` field from `PyThreadState` and ↵Kumar Aditya2022-11-153-8/+0
| | | | | | | | `PyInterpreterState` (GH-99385)
| * gh-81057: Move the Remaining Import State Globals to _PyRuntimeState (gh-99488)Eric Snow2022-11-142-0/+21
| | | | | | https://github.com/python/cpython/issues/81057
| * gh-81057: Move Global Variables Holding Objects to _PyRuntimeState. (gh-99487)Eric Snow2022-11-144-0/+32
| | | | | | | | | | This moves nearly all remaining object-holding globals in core code (other than static types). https://github.com/python/cpython/issues/81057
| * gh-87092: expose the compiler's codegen to python for unit tests (GH-99111)Irit Katriel2022-11-145-0/+12
| |
* | Post 3.12.0a2Thomas Wouters2022-11-151-1/+1
| |
* | Python 3.12.0a2v3.12.0a2Thomas Wouters2022-11-141-2/+2
|/
* gh-83638: Add sqlite3.Connection.autocommit for PEP 249 compliant behaviour ↵Erlend E. Aasland2022-11-124-0/+5
| | | | | | | | | | (#93823) Introduce the autocommit attribute to Connection and the autocommit parameter to connect() for PEP 249-compliant transaction handling. Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM> Co-authored-by: Géry Ogam <gery.ogam@gmail.com>
* gh-81057: Move PyImport_Inittab to _PyRuntimeState (gh-99402)Eric Snow2022-11-123-0/+4
| | | | | We actually don't move PyImport_Inittab. Instead, we make a copy that we keep on _PyRuntimeState and use only that after Py_Initialize(). We also prevent folks from modifying PyImport_Inittab (the best we can) after that point. https://github.com/python/cpython/issues/81057
* gh-81057: Move the Allocators to _PyRuntimeState (gh-99217)Eric Snow2022-11-116-15/+877
| | | | | The global allocators were stored in 3 static global variables: _PyMem_Raw, _PyMem, and _PyObject. State for the "small block" allocator was stored in another 13. That makes a total of 16 global variables. We are moving all 16 to the _PyRuntimeState struct as part of the work for gh-81057. (If PEP 684 is accepted then we will follow up by moving them all to PyInterpreterState.) https://github.com/python/cpython/issues/81057
* gh-81057: Add PyInterpreterState.static_objects (gh-99397)Eric Snow2022-11-114-2/+30
| | | | | As we consolidate global variables, we find some objects that are almost suitable to add to _PyRuntimeState.global_objects, but have some small/sneaky bit of per-interpreter state (e.g. a weakref list). We're adding PyInterpreterState.static_objects so we can move such objects there. (We'll removed the _not_used field once we've added others.) https://github.com/python/cpython/issues/81057
* gh-81057: Move the Extension Modules Cache to _PyRuntimeState (gh-99355)Eric Snow2022-11-114-0/+52
| | | | | We also move the closely related max_module_number and add comments documenting the group of struct members. https://github.com/python/cpython/issues/81057
* gh-81057: Generate a Separate Initializer For Each Part of the Global ↵Eric Snow2022-11-113-1469/+1479
| | | | | | | Objects Initializer (gh-99389) Up until now we had a single generated initializer macro for all the statically declared global objects in _PyRuntimeState, including several one-offs (e.g. the empty tuple). The one-offs don't need to be generated, but were because we had one big initializer. Having separate initializers for set of generated global objects allows us to generate only the ones we need to. This allows us to add initializers for one-off global objects without having to generate them. https://github.com/python/cpython/issues/81057
* GH-96421: Insert shim frame on entry to interpreter (GH-96319)Mark Shannon2022-11-108-94/+108
| | | | | | * Adds EXIT_INTERPRETER instruction to exit PyEval_EvalDefault() * Simplifies RETURN_VALUE, YIELD_VALUE and RETURN_GENERATOR instructions as they no longer need to check for entry frames.
* GH-98686: Get rid of "adaptive" and "quick" instructions (GH-99182)Brandt Bucher2022-11-093-136/+148
|
* GH-90699: disallow `_Py_IDENTIFIER` in core code (GH-99210)Kumar Aditya2022-11-091-2/+2
|
* gh-98724: Fix Py_CLEAR() macro side effects (#99100)Victor Stinner2022-11-092-27/+36
| | | | | | | The Py_CLEAR(), Py_SETREF() and Py_XSETREF() macros now only evaluate their argument once. If an argument has side effects, these side effects are no longer duplicated. Add test_py_clear() and test_py_setref() unit tests to _testcapi.
* gh-90868: Add _PyStaticObject_CheckRefcnt() function (#99261)Victor Stinner2022-11-091-5777/+1456
| | | | | | Add _PyStaticObject_CheckRefcnt() function to make _PyStaticObjects_CheckRefcnt() shorter. Use _PyObject_ASSERT_FAILED_MSG() to log the object causing the fatal error.
* gh-90868: Adjust the Generated Objects (gh-99223)Eric Snow2022-11-083-7081/+7114
| | | | | | | | | | | We do the following: * move the generated _PyUnicode_InitStaticStrings() to its own file * move the generated _PyStaticObjects_CheckRefcnt() to its own file * include pycore_global_objects.h in extension modules instead of pycore_runtime_init.h These changes help us avoid including things that aren't needed. https://github.com/python/cpython/issues/90868
* gh-91248: Add PyFrame_GetVar() function (#95712)Victor Stinner2022-11-081-1/+2
| | | | | | Add PyFrame_GetVar() and PyFrame_GetVarString() functions to get a frame variable by its name. Move PyFrameObject C API tests from test_capi to test_frame.
* GH-90699: Remove remaining `_Py_IDENTIFIER` stdlib usage (GH-99067)Kumar Aditya2022-11-073-7/+71
|
* GH-96793: Specialize FOR_ITER for generators. (GH-98772)Mark Shannon2022-11-074-44/+47
|
* gh-99139: Improve NameError error suggestion for instances (#99140)Pablo Galindo Salgado2022-11-062-0/+8
|
* gh-98284: better error message for undefined abstractmethod (#97971)Kaushik Kulkarni2022-11-052-6/+0
|
* GH-90699: Remove `_Py_IDENTIFIER` usage from `_ctypes` (GH-99054)Kumar Aditya2022-11-032-0/+128
|
* GH-96793: Implement PEP 479 in bytecode. (GH-99006)Mark Shannon2022-11-032-49/+50
| | | | | * Handle converting StopIteration to RuntimeError in bytecode. * Add custom instruction for converting StopIteration into RuntimeError.
* GH-98686: Quicken everything (GH-98687)Brandt Bucher2022-11-024-75/+52
|
* GH-90699: Remove `_Py_IDENTIFIER` usage from `_asyncio` module (#99010)Kumar Aditya2022-11-022-0/+128
|
* GH-90699: Remove `_Py_IDENTIFIER` usage from `_json` module (GH-98956)Kumar Aditya2022-11-022-0/+38
|
* gh-87092: do not allocate PyFutureFeatures dynamically (GH-98913)Irit Katriel2022-11-021-3/+4
|
* gh-98610: Adjust the Optional Restrictions on Subinterpreters (GH-98618)Eric Snow2022-10-312-8/+19
| | | | | | | Previously, the optional restrictions on subinterpreters were: disallow fork, subprocess, and threads. By default, we were disallowing all three for "isolated" interpreters. We always allowed all three for the main interpreter and those created through the legacy `Py_NewInterpreter()` API. Those settings were a bit conservative, so here we've adjusted the optional restrictions to: fork, exec, threads, and daemon threads. The default for "isolated" interpreters disables fork, exec, and daemon threads. Regular threads are allowed by default. We continue always allowing everything For the main interpreter and the legacy API. In the code, we add `_PyInterpreterConfig.allow_exec` and `_PyInterpreterConfig.allow_daemon_threads`. We also add `Py_RTFLAGS_DAEMON_THREADS` and `Py_RTFLAGS_EXEC`.
* gh-98410: move getbufferproc and releasebufferproc to buffer.h (#31158)David Hewitt2022-10-312-4/+3
| | | This adds them to the Limited API.