Commit Graph

1675 Commits

Author SHA1 Message Date
Richard Hansen 616468b87b
gh-125674: Doc: Fix type of `newfunc` first parameter (GH-125675)
* gh-125674: Doc: Fix type of `newfunc` first parameter

* fixup! gh-125674: Doc: Fix type of `newfunc` first parameter

---------

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-10-30 13:27:37 -07:00
Victor Stinner db96327203
gh-121654: Add PyType_Freeze() function (#122457)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2024-10-25 11:12:48 +02:00
Richard Hansen d880c83ff7
Doc: C API: Move `tp_dealloc` paragraph to `tp_dealloc` section (#125737)
It looks like commit 43cf44ddcc
(gh-31501) accidentally moved the paragraph to the `tp_finalize`
section when the intent was to move it to the `tp_dealloc` section
(according to the commit message).

Also:
  * Convert the paragraph to a warning.
  * Apply the appropriate font style to `tp_dealloc`.
  * Unlinkify the first mention of `tp_dealloc` since the paragraph is
    already in the `tp_dealloc` section.
2024-10-21 09:46:37 -07:00
Y5 7d88140d52
gh-125313: Prefer `sys.base_*` paths in `Py_Get(Exec)Prefix` deprecation notes (#125317)
Prefer `sys.base_*` paths in `Py_Get(Exec)Prefix` deprecation notes.

Signed-off-by: y5c4l3 <y5c4l3@proton.me>
2024-10-21 11:35:54 +02:00
ember91 ded105a62b
Doc: Fix typos (#125728) 2024-10-21 10:44:18 +02:00
Kirill Podoprigora bee112a94d
gh-124872: Replace enter/exit events with "switched" (#125532)
Users want to know when the current context switches to a different
context object.  Right now this happens when and only when a context
is entered or exited, so the enter and exit events are synonymous with
"switched".  However, if the changes proposed for gh-99633 are
implemented, the current context will also switch for reasons other
than context enter or exit.  Since users actually care about context
switches and not enter or exit, replace the enter and exit events with
a single switched event.

The former exit event was emitted just before exiting the context.
The new switched event is emitted after the context is exited to match
the semantics users expect of an event with a past-tense name.  If
users need the ability to clean up before the switch takes effect,
another event type can be added in the future.  It is not added here
because YAGNI.

I skipped 0 in the enum as a matter of practice.  Skipping 0 makes it
easier to troubleshoot when code forgets to set zeroed memory, and it
aligns with best practices for other tools (e.g.,
https://protobuf.dev/programming-guides/dos-donts/#unspecified-enum).

Co-authored-by: Richard Hansen <rhansen@rhansen.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
2024-10-16 13:53:21 +02:00
Hugo van Kemenade 8cdaca8b25 Python 3.14.0a1 2024-10-15 22:34:54 +03:00
Kirill Podoprigora d3c82b9cce
gh-125512: Revert "gh-124872: Replace enter/exit events with "switched" (#124776)" (#125513) 2024-10-15 17:42:16 +03:00
sobolevn c8a1818fb0
gh-125517: Fix unreachable code warnings in `_testembed.c` (#125518) 2024-10-15 13:12:32 +00:00
RUANG (Roy James) 546dddca43
gh-125234: Make PyInitConfig_Free(NULL) a no-op (#125266) 2024-10-15 09:21:16 +00:00
Richard Hansen 843d28f59d
gh-124872: Replace enter/exit events with "switched" (#124776)
Users want to know when the current context switches to a different
context object.  Right now this happens when and only when a context
is entered or exited, so the enter and exit events are synonymous with
"switched".  However, if the changes proposed for gh-99633 are
implemented, the current context will also switch for reasons other
than context enter or exit.  Since users actually care about context
switches and not enter or exit, replace the enter and exit events with
a single switched event.

The former exit event was emitted just before exiting the context.
The new switched event is emitted after the context is exited to match
the semantics users expect of an event with a past-tense name.  If
users need the ability to clean up before the switch takes effect,
another event type can be added in the future.  It is not added here
because YAGNI.

I skipped 0 in the enum as a matter of practice.  Skipping 0 makes it
easier to troubleshoot when code forgets to set zeroed memory, and it
aligns with best practices for other tools (e.g.,
https://protobuf.dev/programming-guides/dos-donts/#unspecified-enum).
2024-10-14 12:28:41 -07:00
Sergey B Kirpichev c6d7b644c2
gh-101291: Add versionadded directives for PyUnstable_Long_* (#125384) 2024-10-13 19:38:42 +02:00
Richard Hansen 330c527299
gh-124872: Change PyContext_WatchCallback to take PyObject (#124737)
The PyContext struct is not intended to be public, and users of the
API don't need anything more specific than PyObject.  Also see
gh-78943.
2024-10-12 13:57:27 -07:00
Richard Hansen 99400930ac
gh-124872: Refine contextvars documentation (#124773)
* Add definitions for "context", "current context", and "context
    management protocol".
  * Update related definitions to be consistent with the new
    definitions.
  * Restructure the documentation for the `contextvars.Context` class
    to prepare for adding context manager support, and for consistency
    with the definitions.
  * Use `testcode` and `testoutput` to test the `Context.run` example.
  * Expand the documentation for the `Py_CONTEXT_EVENT_ENTER` and
    `Py_CONTEXT_EVENT_EXIT` events to clarify and to prepare for
    planned changes.
2024-10-09 16:44:03 -07:00
Victor Stinner 1b2a5485f9
gh-125196: PyUnicodeWriter_Discard(NULL) does nothing (#125222) 2024-10-09 23:32:02 +00:00
Alex Waygood 3024b16d51
gh-101100: Consolidate documentation on `ModuleType` attributes (#124709)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Barry Warsaw <barry@python.org>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-10-09 10:53:57 +00:00
Alyssa Coghlan 7c4b6a68f2
bpo-34206: Improve docs and test coverage for pre-init functions (#8023)
- move the Py_Main documentation from the very high level API section
  to the initialization and finalization section
- make it clear that it encapsulates a full Py_Initialize/Finalize
  cycle of its own
- point out that exactly which settings will be read and applied
  correctly when Py_Main is called after a separate runtime
  initialization call is version dependent
- be explicit that Py_IsInitialized can be called prior to
  initialization
- actually test that Py_IsInitialized can be called prior to
  initialization
- flush stdout in the embedding tests that run code so it appears
  in the expected order when running with "-vv"
- make "-vv" on the subinterpreter embedding tests less spammy

---------

Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
2024-10-08 08:34:11 +00:00
Alyssa Coghlan 27390990fa
gh-70870: Clarify dual usage of 'free variable' (#122545)
The term "free variable" has unfortunately become genuinely
ambiguous over the years (presumably due to the names of
some relevant code object instance attributes).

While we can't eliminate that ambiguity at this late date, we can
at least alert people to the potential ambiguity by describing
both the formal meaning of the term and the common
alternative use as a direct synonym for "closure variable".

---------

Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
2024-10-08 07:52:12 +00:00
Victor Stinner a7f0727ca5
gh-124502: Add PyUnicode_Equal() function (#124504) 2024-10-07 21:24:53 +00:00
ffelixg 3287c834e5
gh-124182: Explain naming rules for struct sequence types (#124335) 2024-10-07 19:52:34 +02:00
Donghee Na 9eeb21bf76
gh-115145: Update documentation about ``PyThreadState_DeleteCurrent`` (gh-124920) 2024-10-03 19:34:47 +09:00
Jeremy Maitin-Shepard 8cc5aa47ee
gh-87135: Hang non-main threads that attempt to acquire the GIL during finalization (GH-105805)
Instead of surprise crashes and memory corruption, we now hang threads that attempt to re-enter the Python interpreter after Python runtime finalization has started. These are typically daemon threads (our long standing mis-feature) but could also be threads spawned by extension modules that then try to call into Python. This marks the `PyThread_exit_thread` public C API as deprecated as there is no plausible safe way to accomplish that on any supported platform in the face of things like C++ code with finalizers anywhere on a thread's stack. Doing this was the least bad option.

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2024-10-02 09:17:49 -07:00
Pablo Galindo Salgado 02b49c5150
gh-107954: Fix configuration type for the perf profiler (#124636) 2024-09-28 01:50:16 +02:00
Petr Viktorin 425587a110
gh-124385: Document and soft-deprecate PyLong_AS_LONG (GH-124386) 2024-09-27 23:40:50 +00:00
Victor Stinner d8cf587dc7
doc: PyUnicode_AsUTF8String() fails if string contains surrogates (#124605) 2024-09-27 20:13:29 +00:00
Max Bachmann b79a21ea42
GH-95079: document error behaviour for some unicode C APIs (#95080) 2024-09-27 12:35:55 +02:00
Petr Viktorin 7d24ea9db3
gh-121277: Allow `.. versionadded:: next` in docs (GH-121278)
Make `versionchanged:: next`` expand to current (unreleased) version.

When a new CPython release is cut, the release manager will replace
all such occurences of "next" with the just-released version.
(See the issue for release-tools and devguide PRs.)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-09-25 23:30:40 +02:00
Alex Waygood 0d9d56c4e4
gh-101100: Add a table of class attributes to the "Custom classes" section of the data model docs (#124480) 2024-09-25 19:29:58 +00:00
Jason Fried d87482bc4e
gh-119333: Add C api to have contextvar enter/exit callbacks (#119335)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2024-09-23 20:40:17 -07:00
Adam Turner 9d0a75269c
GH-109975: Copyedit 3.13 What's New: C API (#124313) 2024-09-23 14:28:17 +01:00
Petr Viktorin 32119fc377
gh-118915: Add/fix docs entries for some new 3.13 C API (GH-124134) 2024-09-18 14:15:43 +02:00
Sergey B Kirpichev 8a284e1896
gh-119771: Set errno on overflows in _Py_c_pow() (#120256)
Before we did this in complex_pow() and behavior of the public C API
function _Py_c_pow() was different from the pure-python pow().
2024-09-18 10:39:11 +02:00
neonene 646f16bdee
gh-124153: Implement `PyType_GetBaseByToken()` and `Py_tp_token` slot (GH-124163) 2024-09-18 09:18:19 +02:00
Rafael Fontenelle 33eeccf6d4
Use pep role instead of url (#121611) 2024-09-17 16:02:14 +03:00
Oleg Iarygin 4f25e282ad
gh-100554: Fix formatting of type.rst modifications (#124066) 2024-09-13 18:35:08 +00:00
Wenzel Jakob 74330d992b
gh-100554: Add ``Py_tp_vectorcall`` slot to set ``PyTypeObject.tp_vectorcall`` using the ``PyType_FromSpec`` function family. (#123332) 2024-09-13 17:40:25 +02:00
Donghee Na e6bb1a2b28
gh-119802: Update memory management docs for free-threaded build (gh-124006)
* gh-119802: Update memory management docs for free-threaded build

* nit

* nit

* Address code review

* nit

* Update Doc/c-api/memory.rst

Co-authored-by: Sam Gross <colesbury@gmail.com>

---------

Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-09-13 15:15:44 +00:00
Petr Viktorin 432bf31327
gh-123909: PyType_From*: Disallow metaclasses with custom tp_new (GH-123947) 2024-09-13 13:18:49 +02:00
Peter Bierma 962304a54c
gh-123609: Clarify usage of standalone `PyBUF_FORMAT` (GH-123778) 2024-09-10 15:05:28 +02:00
Victor Stinner d343f977ba
gh-121645: Fix typo in PyBytes_Join() doc (#123783) 2024-09-06 16:08:17 +02:00
Rafael Fontenelle 6e43928831
Swap the and from in sentence in init_config.rst (#120086) 2024-09-05 23:04:15 +03:00
Petr Viktorin 16be8db6be
gh-123465: Allow Py_RELATIVE_OFFSET for __*offset__ members (GH-123474) 2024-09-05 14:14:05 +02:00
Victor Stinner 0d6b6e34a2
gh-107954, PEP 741: Add PyInitConfig_AddModule() function (#123668) 2024-09-04 11:41:57 +00:00
Victor Stinner ef9d54703f
gh-107954, PEP 741: Add PyInitConfig C API (#123502)
Add Doc/c-api/config.rst documentation.
2024-09-03 12:33:49 +00:00
Victor Stinner 33b790978d
gh-107954, PEP 741: Add PyConfig_Get()/Set() functions (#123472)
Add PyConfig_Get(), PyConfig_GetInt(), PyConfig_Set() and
PyConfig_Names() functions to get and set the current runtime Python
configuration.

Add visibility and "sys spec" to config and preconfig specifications.

_PyConfig_AsDict() now converts PyConfig.xoptions as a dictionary.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-09-02 23:25:08 +02:00
Wei-Hsiang (Matt) Wang cf472577e2
gh-123517: Remove unnecessary ``:meth:`` parentheses (#123518) 2024-09-01 05:59:42 +01:00
Victor Stinner d8e69b2c1b
gh-122854: Add Py_HashBuffer() function (#122855) 2024-08-30 15:42:27 +00:00
Victor Stinner 3d60dfbe17
gh-121645: Add PyBytes_Join() function (#121646)
* Replace _PyBytes_Join() with PyBytes_Join().
* Keep _PyBytes_Join() as an alias to PyBytes_Join().
2024-08-30 12:57:33 +00:00
Wei-Hsiang (Matt) Wang 103a0470e3
gh-123492: Remove unnecessary `:func:` parentheses (#123493) 2024-08-30 14:34:09 +03:00
Wulian 9e108b8719
Fix typos in docs, error messages and comments (#123336)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-08-28 14:41:04 +03:00