summaryrefslogtreecommitdiffstats
path: root/Doc/c-api
Commit message (Collapse)AuthorAgeFilesLines
* Fix typos in Doc folder (#100880)Semen Zhydenko2023-01-101-1/+1
|
* docs: fix `ssizeobjargproc` parameters (#100736)David Lechner2023-01-041-1/+2
|
* Fix deprecation doc for `PyEval_InitThreads` (#100667)Alexander Shadchin2023-01-021-2/+2
|
* gh-98712: Clarify "readonly bytes-like object" semantics in C arg-parsing ↵Petr Viktorin2022-12-231-19/+35
| | | | docs (#98710)
* Docs: Use `PY_VERSION_HEX` for version comparison (#100179)Hugo van Kemenade2022-12-171-0/+2
|
* gh-97909: Fix markup for `PyMethodDef` members (#100089)ram vikram singh2022-12-171-17/+18
|
* gh-99767: mark `PyTypeObject.tp_watched` as internal use only in table (#100271)Carl Meyer2022-12-161-1/+1
|
* GH-99767: update PyTypeObject docs for type watchers (GH-99928)Carl Meyer2022-12-151-0/+9
|
* gh-98724: Fix Py_CLEAR() macro side effects (#99100) (#100070)Victor Stinner2022-12-071-2/+44
| | | | | | | | | | | | | | The Py_CLEAR(), Py_SETREF() and Py_XSETREF() macros now only evaluate their arguments once. If an argument has side effects, these side effects are no longer duplicated. Use temporary variables to avoid duplicating side effects of macro arguments. If available, use _Py_TYPEOF() to avoid type punning. Otherwise, use memcpy() for the assignment to prevent a miscompilation with strict aliasing caused by type punning. Add _Py_TYPEOF() macro: __typeof__() on GCC and clang. Add test_py_clear() and test_py_setref() unit tests to _testcapi.
* GH-91054: Add code object watchers API (GH-99859)Itamar Ostricher2022-12-021-0/+48
| | | | | | * Add API to allow extensions to set callback function on creation and destruction of PyCodeObject Co-authored-by: Ye11ow-Flash <janshah@cs.stonybrook.edu>
* gh-99249: Clarify "read-only" slots tp_bases & tp_mro (GH-99342)Petr Viktorin2022-11-281-6/+25
| | | | | | | | | | | | | | | | | These slots are marked "should be treated as read-only" in the table at the start of the document. That doesn't say anything about setting them in the static struct. `tp_bases` docs did say that it should be ``NULL`` (TIL!). If you ignore that, seemingly nothing bad happens. However, some slots may not be inherited, depending on which sub-slot structs are present. (FWIW, NumPy sets tp_bases and is affected by the quirk -- though to be fair, its DUAL_INHERIT code probably predates tp_bases docs, and also the result happens to be benign.) This patch makes things explicit. It also makes the summary table legend easier to scan. Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
* Revert "gh-98724: Fix Py_CLEAR() macro side effects" (#99737)Victor Stinner2022-11-241-44/+2
| | | | | Revert "gh-98724: Fix Py_CLEAR() macro side effects (#99100)" This reverts commit c03e05c2e72f3ea5e797389e7d1042eef85ad37a.
* gh-93937: Document PyFrame_Check and PyFrame_Type (GH-99695)Petr Viktorin2022-11-221-0/+18
|
* gh-91053: Add an optional callback that is invoked whenever a function is ↵mpage2022-11-221-0/+60
| | | | modified (#98175)
* gh-47146: Soft-deprecate structmember.h, expose its contents via Python.h ↵Petr Viktorin2022-11-221-61/+184
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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>
* Doc: Replace question mark with fullstop (#99558)Rafael Fontenelle2022-11-181-1/+1
| | | | The sentence "Set the LC_CTYPE locale to the user preferred locale." should end with a period instead of a question mark.
* gh-99377: Revert audit events for thread state creation and free, because ↵Steve Dower2022-11-171-13/+0
| | | | the GIL is not properly held at these times (GH-99543)
* gh-99377: Add audit events for thread creation and clear (GH-99378)Steve Dower2022-11-161-0/+13
|
* gh-91248: Optimize PyFrame_GetVar() (#99252)Victor Stinner2022-11-131-0/+2
| | | | PyFrame_GetVar() no longer creates a temporary dictionary to get a variable.
* gh-98724: Fix Py_CLEAR() macro side effects (#99100)Victor Stinner2022-11-091-2/+44
| | | | | | | 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-91248: Add PyFrame_GetVar() function (#95712)Victor Stinner2022-11-081-0/+19
| | | | | | 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-96746: Docs: Clear up Py_TPFLAGS_DISALLOW_INSTANTIATION inheritance ↵Petr Viktorin2022-11-071-0/+11
| | | | | | | (GH-99002) The flag is not inherited, but its effect -- a NULL tp_new -- is. Drop hints for people who come here wanting to “disallow instantiation”.
* gh-98586: Add What's New entry and update docs (#99056)Wenzel Jakob2022-11-061-1/+1
| | | | Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* gh-97909: PyMemberDef & PyGetSetDef members are not marked up (GH-98810)Johnny115022022-11-031-17/+19
|
* gh-96997: Clarify the contract of PyMem_SetAllocator() (#98977)Pablo Galindo Salgado2022-11-021-0/+21
|
* gh-98608: Change _Py_NewInterpreter() to _Py_NewInterpreterFromConfig() ↵Eric Snow2022-10-261-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | (gh-98609) (see https://github.com/python/cpython/issues/98608) This change does the following: 1. change the argument to a new `_PyInterpreterConfig` struct 2. rename the function to `_Py_NewInterpreterFromConfig()`, inspired by `Py_InitializeFromConfig()` (takes a `_PyInterpreterConfig` instead of `isolated_subinterpreter`) 3. split up the boolean `isolated_subinterpreter` into the corresponding multiple granular settings * allow_fork * allow_subprocess * allow_threads 4. add `PyInterpreterState.feature_flags` to store those settings 5. add a function for checking if a feature is enabled on an opaque `PyInterpreterState *` 6. drop `PyConfig._isolated_interpreter` The existing default (see `Py_NewInterpeter()` and `Py_Initialize*()`) allows fork, subprocess, and threads and the optional "isolated" interpreter (see the `_xxsubinterpreters` module) disables all three. None of that changes here; the defaults are preserved. Note that the given `_PyInterpreterConfig` will not be used outside `_Py_NewInterpreterFromConfig()`, nor preserved. This contrasts with how `PyConfig` is currently preserved, used, and even modified outside `Py_InitializeFromConfig()`. I'd rather just avoid that mess from the start for `_PyInterpreterConfig`. We can preserve it later if we find an actual need. This change allows us to follow up with a number of improvements (e.g. stop disallowing subprocess and support disallowing exec instead). (Note that this PR adds "private" symbols. We'll probably make them public, and add docs, in a separate change.)
* gh-97909: Mark up members of PyMemberDef (GH-98473)Johnny115022022-10-241-21/+21
| | | Co-authored-by: T <tnie@tuta.io>
* no-issue: typo fix in c-api/tuple.rst (gh-98560)wim glenn2022-10-231-1/+1
|
* gh-91051: allow setting a callback hook on PyType_Modified (GH-97875)Carl Meyer2022-10-211-0/+49
|
* Doc: Found some remaining default roles. (GH-98392)Julien Palard2022-10-181-1/+1
|
* gh-96258: move Py_REFCNT and Py_SET_REFCNT to reference counting page (#96259)QuakeIV2022-10-152-21/+22
|
* Fix types in buffer/memoryview docs (#98118)da-woods2022-10-102-2/+2
| | | | | | | | The definition of obj in the `Py_buffer` struct is as a PyObject* https://github.com/python/cpython/blob/ec091bd47e2f968b0d1631b9a8104283a7beeb1b/Include/pybuffer.h#L22 PyMemoryView_GET_BASE returns `.obj` - thus its return type should be a PyObject* (or at least a void*). It definitely doesn't return `Py_buffer`
* gh-91052: Add PyDict_Unwatch for unwatching a dictionary (#98055)Carl Meyer2022-10-081-1/+20
|
* Add a warning message about PyOS_snprintf (#95993)Eric Wieser2022-10-071-1/+2
|
* Docs: Fix backtick errors found by sphinx-lint (#97998)Hugo van Kemenade2022-10-072-2/+2
| | | Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
* GH-91052: Add C API for watching dictionaries (GH-31787)Carl Meyer2022-10-071-0/+51
|
* gh-65961: Do not rely solely on `__cached__` (GH-97990)Brett Cannon2022-10-061-0/+9
| | | Make sure `__spec__.cached` (at minimum) can be used.
* gh-93738: Documentation C syntax (:c:type:<C type> -> :c:expr:<C type>) (#97768)Adam Turner2022-10-0514-116/+116
| | | | | :c:type:`<C type>` -> :c:expr:`<C type>` Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* gh-93738: Documentation C syntax (Function glob patterns -> literal markup) ↵Adam Turner2022-10-055-14/+14
| | | | (#97774)
* gh-93738: Documentation C syntax (:c:type:`PyTypeObject*` -> ↵Adam Turner2022-10-052-2/+2
| | | | | :c:expr:`PyTypeObject*`) (#97778) Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
* gh-93738: Documentation C syntax (:c:type: to :c:expr:, misc. cases) (#97775)Adam Turner2022-10-042-4/+4
| | | | | * :c:type: to :c:expr: * Update Doc/whatsnew/2.4.rst
* gh-93738: Documentation C syntax (:c:type:`FILE` -> :c:expr:`FILE`) (#97769)Adam Turner2022-10-043-8/+8
| | | :c:type:`FILE` -> :c:expr:`FILE`
* gh-93738: Documentation C syntax (:c:type:`TYPE` -> :c:expr:`TYPE`) (#97770)Adam Turner2022-10-041-2/+2
| | | :c:type:`TYPE` -> :c:expr:`TYPE`
* gh-93738: Documentation C syntax (Use `c:struct`) (#97772)Adam Turner2022-10-042-5/+5
| | | Use `c:struct`
* gh-93738: Documentation C syntax (:c:data:`view->obj` -> ↵Adam Turner2022-10-041-5/+5
| | | | | :c:expr:`view->obj`) (#97773) :c:data:`view->obj` -> :c:expr:`view->obj`
* gh-93738: Documentation C syntax (:c:type:`PyObject` -> :c:expr:`PyObject`) ↵Adam Turner2022-10-049-28/+28
| | | | | (#97776) :c:type:`PyObject` -> :c:expr:`PyObject`
* gh-93738: Documentation C syntax (:c:type:`PyInterpreterState *` -> ↵Adam Turner2022-10-041-1/+1
| | | | | :c:expr:`PyInterpreterState *`) (#97777) :c:type:`PyInterpreterState *` -> :c:expr:`PyInterpreterState *`
* gh-93738: Documentation C syntax (:c:type:`PyTupleObject*` -> ↵Adam Turner2022-10-041-1/+1
| | | | | :c:expr:`PyTupleObject*`) (#97780) :c:type:`PyTupleObject*` -> :c:expr:`PyTupleObject*`
* gh-93738: Documentation C syntax (:c:type:`PyBytesObject*` -> ↵Adam Turner2022-10-041-1/+1
| | | | | :c:expr:`PyBytesObject*`) (#97782) :c:type:`PyBytesObject*` -> :c:expr:`PyBytesObject*`
* gh-93738: Documentation C syntax (:c:type:`PyUnicodeObject*` -> ↵Adam Turner2022-10-041-1/+1
| | | | | :c:expr:`PyUnicodeObject*`) (#97783) :c:type:`PyUnicodeObject*` -> :c:expr:`PyUnicodeObject*`