Commit graph

1555 commits

Author SHA1 Message Date
Miss Islington (bot)
caa73883f9
[3.12] Docs: Fix documentation for "PyTypeObject Definition" (GH-130936) (GH-131459)
The structure definition for `PyTypeObject` is in `Include/cpython/object.h`,
not in `Include/object.h`.
(cherry picked from commit a0478c9f0c)

Co-authored-by: Yuki Kobayashi <drsuaimqjgar@gmail.com>
2025-03-20 13:41:22 +01:00
Miss Islington (bot)
040583387b
[3.12] gh-129675: Update documentation for tp_basicsize & tp_itemsize (GH-129850) (GH-131078)
- Add alignment requirement
- Mention that ob_size is unreliable if you don't control it
- Add some links for context
- basicsize should include the base type in generaly not just PyObject
- suggest Py_SIZE & Py_SET_SIZE

This adds a “by-the-way” link to `PyObject_New`, which shouldn't be
used for GC types. In order to be comfortable linking to it, I also
add a link to `PyObject_GC_New` from its docs. And the same for
`*Var` variants, while I'm here.

(cherry picked from commit ad0f618ab3)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-03-17 16:18:14 +01:00
Hugo van Kemenade
4c1d52934d
[3.12] gh-124385: Document and soft-deprecate PyLong_AS_LONG (GH-124386) (#130549)
(cherry picked from commit 425587a110)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-03-17 14:59:12 +02:00
Miss Islington (bot)
77ece5aed8
[3.12] gh-130814: Enhance documentation for Python C API type objects (GH-130817) (#131224)
gh-130814: Enhance documentation for Python C API type objects (GH-130817)

The "Type Objects" title in `c-api/typeobj.rst`, duplicating the title of `c-api/type.rst`,
has been changed to "Type Objects Structures", thereby slightly improving Sphinx
search.
(cherry picked from commit 6b932edc52)

Co-authored-by: sharktide <meherrihaan@gmail.com>
2025-03-14 10:01:05 +00:00
Miss Islington (bot)
c82795a0bb
[3.12] gh-130711: Document PyBaseObject_Type (GH-130712) (GH-130793)
(cherry picked from commit b3c18bfd82)

Co-authored-by: Yuki Kobayashi <drsuaimqjgar@gmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-03-10 15:05:45 +01:00
Miss Islington (bot)
96e6932bef
[3.12] Fix grammar typo in Doc/c-api/arg.rst (GH-130741) (#130758)
Fix grammar typo in `Doc/c-api/arg.rst` (GH-130741)
(cherry picked from commit 37145cb89f)

Co-authored-by: Arijit Kumar Das <arijitkrdas2004@outlook.com>
2025-03-02 11:21:57 +00:00
Petr Viktorin
a678d8e511
[3.12] gh-129405: Fix doc for Py_mod_multiple_interpreters default, and add test (GH-129406) (GH-130510) 2025-02-27 16:30:46 +01:00
Miss Islington (bot)
e38cded312
[3.12] gh-46236: Add docs for PyUnicode_GetDefaultEncoding() doc (GH-130335) (GH-130512)
* Clarify sys.getdefaultencoding() documentation

* Add missing documentation for PyUnicode_GetDefaultEncoding,
  the C equivalent of sys.getdefaultencoding
(cherry picked from commit 9f25c1f012)

Co-authored-by: RUANG (James Roy) <longjinyii@outlook.com>
2025-02-24 17:10:27 +01:00
Miss Islington (bot)
5c0aba0b81
[3.12] gh-46236: Document PyUnicode_RSplit, PyUnicode_Partition and PyUnicode_RPartition (GH-130191) (#130361)
gh-46236: Document PyUnicode_RSplit, PyUnicode_Partition and PyUnicode_RPartition (GH-130191)
(cherry picked from commit 0f5b82169e)

Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-02-20 15:50:37 +00:00
Miss Islington (bot)
0274115585
[3.12] gh-130214: Document PyEllipsis_Type (GH-130215) (#130224)
gh-130214: Document `PyEllipsis_Type` (GH-130215)
(cherry picked from commit fc8c99a8ce)

Co-authored-by: Yuki Kobayashi <drsuaimqjgar@gmail.com>
2025-02-17 19:24:30 +03:00
Stan Ulbrych
8a598fb623
[3.12] gh-82045: Correct and deduplicate "isprintable" docs; add test. (GH-130125)
We had the definition of what makes a character "printable" documented in three places, giving two different definitions.
The definition in the comment on `_PyUnicode_IsPrintable` was inverted; correct that.

With that correction, the two definitions turn out to be equivalent -- but to confirm that, you have to go look up, or happen to know, that those are the only five "Other" categories and only three "Separator" categories in the Unicode character database.  That makes it hard for the reader to tell whether they really are the same, or if there's some subtle difference in the intended semantics.

Fix that by cutting the C API docs' and the C comment's copies of the subtle details, in favor of referring to the Python-level docs. That ensures it's explicit that these are all meant to agree, and also lets us concentrate improvements to the wording in one place.

Speaking of which, borrow some ideas from the C comment, along with other tweaks, to hopefully add a bit more clarity to that one newly-centralized copy in the docs.

Also add a thorough test that the implementation agrees with this definition.

Co-authored-by: Greg Price <gnprice@gmail.com>
(cherry picked from commit 3402e133ef)
2025-02-17 14:07:59 +01:00
Miss Islington (bot)
4acf03ce65
[3.12] gh-130169: Fix broken list markup in Doc/c-api/function.rst (GH-130174) (#130176)
gh-130169: Fix broken list markup in `Doc/c-api/function.rst` (GH-130174)
(cherry picked from commit 9837c2a214)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-02-16 11:04:07 +00:00
Miss Islington (bot)
719d08cccf
[3.12] gh-129912: Fix references to Py_TPFLAGS_MANAGED_DICT (gh-130044) (gh-130060)
(cherry picked from commit 791cdfe141)

Co-authored-by: Satyam Kumar <isatyamks@gmail.com>
2025-02-12 22:55:30 +00:00
Hugo van Kemenade
c62d573a89
[3.12] gh-101100: Docs: Fix some typos in the document (GH-129988) (#129998)
Co-authored-by: Yuki Kobayashi <drsuaimqjgar@gmail.com>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2025-02-11 23:31:48 +02:00
Miss Islington (bot)
181e924332
[3.12] gh-46236: Document PyUnicode_DecodeCodePageStateful (GH-127934) (GH-129962)
gh-46236: Document `PyUnicode_DecodeCodePageStateful` (GH-127934)

(cherry picked from commit 8d9d3e4ecb)

Co-authored-by: Yuki Kobayashi <drsuaimqjgar@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-02-10 17:36:10 +01:00
Miss Islington (bot)
a7645468c2
[3.12] gh-101944: Clarify PyModule_AddObjectRef() documentation (GH-129433) (#129613)
gh-101944: Clarify PyModule_AddObjectRef() documentation (GH-129433)
(cherry picked from commit 04264a286e)

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-02-03 12:02:31 +00:00
Miss Islington (bot)
e6cb31a098
[3.12] Docs C API: Clarify what happens when null bytes are passed to PyUnicode_AsUTF8 (GH-127458) (#129081)
Docs C API: Clarify what happens when null bytes are passed to `PyUnicode_AsUTF8` (GH-127458)
(cherry picked from commit e792f4bc2e)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Stan U. <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-01-20 16:06:18 +00:00
Miss Islington (bot)
8788a9570f
[3.12] gh-90241: Clarify documentation for PyUnicode_FSConverter and PyUnicode_FSDecoder (GH-128451) (GH-128543)
(cherry picked from commit 657d7b77e5)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2025-01-06 23:20:55 +02:00
Miss Islington (bot)
498da39b0d
[3.12] gh-77214: Update outdated documentation for numeric PyArg_Parse formats (GH-128454) (GH-128539)
(cherry picked from commit 8d15058d61)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-01-06 10:57:26 +00:00
Miss Islington (bot)
e1a20910dc
[3.12] gh-127954: Document PyObject_DelItemString (GH-127986) (#128497)
(cherry picked from commit 8ade15343d)

Co-authored-by: RUANG (James Roy) <rruuaanng@outlook.com>
2025-01-04 20:54:56 +00:00
Miss Islington (bot)
d9e199b491
[3.12] gh-125674: Doc: Fix type of newfunc first parameter (GH-125675) (#128448)
(cherry picked from commit 616468b87b)

Co-authored-by: Richard Hansen <rhansen@rhansen.org>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2025-01-03 14:13:18 +00:00
Miss Islington (bot)
2d317332c0
[3.12] Document PyObject_SelfIter (GH-127861) (#127899)
Document PyObject_SelfIter (GH-127861)
(cherry picked from commit 58942a07df)

Co-authored-by: Miro Hrončok <miro@hroncok.cz>
2024-12-13 15:08:19 +05:30
Miss Islington (bot)
c40656eeff
[3.12] gh-127253: Note that Stable ABI is about ABI stability (GH-127254) (GH-127558)
(cherry picked from commit 35d37d6592)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2024-12-03 13:57:58 +01:00
Yuki Kobayashi
4000cbd46a
[3.12] Docs: Fix incorrect indents in c-api/type.rst (GH-127449) (#127461)
(cherry picked from commit 33ce8dcf79)
2024-12-01 10:51:46 +02:00
Miss Islington (bot)
6d2821c833
[3.12] Doc: C API: Fix Py_NewInterpreterFromConfig example code (GH-126667) (#127202)
Doc: C API: Fix `Py_NewInterpreterFromConfig` example code (GH-126667)
(cherry picked from commit e3038e976b)

Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2024-11-23 19:55:55 +00:00
Miss Islington (bot)
a0866f4c81
[3.12] Doc: C API: Demote sections to subsections for consistency (GH-126535) (#126545)
Doc: C API: Demote sections to subsections for consistency (GH-126535)

The entire file should be a single section; the headings below the
first heading should be subsections.
(cherry picked from commit e3510bd3dd)

Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2024-11-07 15:38:57 +00:00
Miss Islington (bot)
aa5498d466
[3.12] Doc: C API: Delete claim that PyObject_Init is GC-aware (GH-126418) (#126432)
Doc: C API: Delete claim that `PyObject_Init` is GC-aware (GH-126418)
(cherry picked from commit 407c0366d9)

Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2024-11-05 15:31:37 +05:30
Miss Islington (bot)
ce5bb3ca85
[3.12] gh-123609: Clarify usage of standalone PyBUF_FORMAT (GH-123778) (GH-123904)
gh-123609: Clarify usage of standalone `PyBUF_FORMAT` (GH-123778)
(cherry picked from commit 962304a54c)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2024-11-01 12:38:23 -07:00
Miss Islington (bot)
c3e705fbe5
[3.12] Doc: C API: Move tp_dealloc paragraph to tp_dealloc section (GH-125737) (#125799)
Doc: C API: Move `tp_dealloc` paragraph to `tp_dealloc` section (GH-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).

(cherry picked from commit d880c83ff7)

Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2024-10-21 09:55:11 -07:00
Miss Islington (bot)
243a8a9d68
[3.12] gh-101291: Add versionadded directives for PyUnstable_Long_* (GH-125384) (#125408)
gh-101291: Add versionadded directives for PyUnstable_Long_* (GH-125384)
(cherry picked from commit c6d7b644c2)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2024-10-13 17:45:59 +00:00
Alex Waygood
cba37762ac
[3.12] gh-101100: Consolidate documentation on ModuleType attributes (#124709) (#125211)
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 19:18:38 +00:00
Miss Islington (bot)
a62d2d3318
[3.12] gh-124182: Explain naming rules for struct sequence types (GH-124335) (#125056)
gh-124182: Explain naming rules for struct sequence types (GH-124335)
(cherry picked from commit 3287c834e5)

Co-authored-by: ffelixg <142172984+ffelixg@users.noreply.github.com>
2024-10-07 17:59:31 +00:00
Miss Islington (bot)
58f7763b88
[3.12] gh-115145: Update documentation about `PyThreadState_DeleteCurrent` (gh-124920) (gh-124931)
gh-115145: Update documentation about ``PyThreadState_DeleteCurrent`` (gh-124920)
(cherry picked from commit 9eeb21bf76)

Co-authored-by: Donghee Na <donghee.na@python.org>
2024-10-03 10:45:25 +00:00
sobolevn
f9cce95750
[3.12] Fix c-api/file.rst indexes (GH-114608) (#124786)
(cherry picked from commit 23fb9f0777)
2024-09-30 13:50:33 +00:00
Petr Viktorin
49f6beb56a
[3.12] gh-113993: Make interned strings mortal (GH-120520, GH-121364, GH-121903, GH-122303) (#123065)
This backports several PRs for gh-113993, making interned strings mortal so they can be garbage-collected when no longer needed.

* Allow interned strings to be mortal, and fix related issues (GH-120520)

  * Add an InternalDocs file describing how interning should work and how to use it.

  * Add internal functions to *explicitly* request what kind of interning is done:
    - `_PyUnicode_InternMortal`
    - `_PyUnicode_InternImmortal`
    - `_PyUnicode_InternStatic`

  * Switch uses of `PyUnicode_InternInPlace` to those.

  * Disallow using `_Py_SetImmortal` on strings directly.
    You should use `_PyUnicode_InternImmortal` instead:
    - Strings should be interned before immortalization, otherwise you're possibly
      interning a immortalizing copy.
    - `_Py_SetImmortal` doesn't handle the `SSTATE_INTERNED_MORTAL` to
      `SSTATE_INTERNED_IMMORTAL` update, and those flags can't be changed in
      backports, as they are now part of public API and version-specific ABI.

  * Add private `_only_immortal` argument for `sys.getunicodeinternedsize`, used in refleak test machinery.

   Make sure the statically allocated string singletons are unique. This means these sets are now disjoint:
    - `_Py_ID`
    - `_Py_STR` (including the empty string)
    - one-character latin-1 singletons

    Now, when you intern a singleton, that exact singleton will be interned.

  * Add a `_Py_LATIN1_CHR` macro, use it instead of `_Py_ID`/`_Py_STR` for one-character latin-1 singletons everywhere (including Clinic).

  * Intern `_Py_STR` singletons at startup.

  * Beef up the tests. Cover internal details (marked with `@cpython_only`).

  * Add lots of assertions

* Don't immortalize in PyUnicode_InternInPlace; keep immortalizing in other API (GH-121364)

  * Switch PyUnicode_InternInPlace to _PyUnicode_InternMortal, clarify docs

  * Document immortality in some functions that take `const char *`

  This is PyUnicode_InternFromString;
  PyDict_SetItemString, PyObject_SetAttrString;
  PyObject_DelAttrString; PyUnicode_InternFromString;
  and the PyModule_Add convenience functions.

  Always point out a non-immortalizing alternative.

  * Don't immortalize user-provided attr names in _ctypes

* Immortalize names in code objects to avoid crash (GH-121903)

* Intern latin-1 one-byte strings at startup (GH-122303)

There are some 3.12-specific changes, mainly to allow statically allocated strings in deepfreeze. (In 3.13, deepfreeze switched to the general `_Py_ID`/`_Py_STR`.)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2024-09-27 13:28:48 -07:00
Miss Islington (bot)
fb8d604d55
[3.12] GH-95079: document error behaviour for some unicode C APIs (GH-95080) (#124662)
(cherry picked from commit b79a21ea42)

Co-authored-by: Max Bachmann <kontakt@maxbachmann.de>
2024-09-27 10:42:23 +00:00
Alex Waygood
d2068c65a6
[3.12] gh-101100: Add a table of class attributes to the "Custom classes" section of the data model docs (#124480) (#124558) 2024-09-25 23:01:19 +00:00
Miss Islington (bot)
a032a96a92
[3.12] Use pep role instead of url (GH-121611) (#124173)
Co-authored-by: Rafael Fontenelle <rffontenelle@users.noreply.github.com>
2024-09-17 13:08:38 +00:00
Miss Islington (bot)
b01063dbca
[3.12] Swap the and from in sentence in init_config.rst (GH-120086) (#123743)
Co-authored-by: Rafael Fontenelle <rffontenelle@users.noreply.github.com>
2024-09-05 20:11:25 +00:00
Wei-Hsiang (Matt) Wang
d47d7e1124
[3.12] gh-123517: Remove unnecessary :meth: parentheses (gh-123518) (GH-123576) 2024-09-02 16:02:39 +02:00
Wei-Hsiang (Matt) Wang
d5abd02f36
[3.12] gh-123492: Remove unnecessary :func: parentheses (gh-123493) (#123512) 2024-08-30 20:09:55 +03:00
Miss Islington (bot)
248af25fb4
[3.12] gh-123254: Improve tuple C API docs with more info about errors (GH-123255) (#123415)
gh-123254: Improve `tuple` C API docs with more info about errors (GH-123255)
(cherry picked from commit 6f563e364d)

Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2024-08-28 07:37:06 +00:00
Sergey B Kirpichev
2ff41583fd
[3.12] gh-122613: Document PyLong_GetInfo() (part of Limited API) (GH-122280) (#122644)
[3.12] gh-122613: Document PyLong_GetInfo() (part of Limited API) (GH-GH-122280)
(cherry picked from commit d91ac525ef)
2024-08-05 20:11:42 +02:00
Miss Islington (bot)
62f224a9ad
[3.12] gh-122623: Improve c-api/bytearray.rst with error handling info (GH-122624) (#122659)
gh-122623: Improve `c-api/bytearray.rst` with error handling info (GH-122624)
(cherry picked from commit 151934a324)

Co-authored-by: sobolevn <mail@sobolevn.me>
2024-08-03 22:02:24 +00:00
Russell Keith-Magee
71970d602f
[3.12] Docs: spelling and grammar fixes (GH-122084) (#122107)
(cherry picked from commit bc264eac3a)

Co-authored-by: Ville Skyttä <ville.skytta@iki.fi>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-07-21 18:39:48 -07:00
Adam Turner
ff98d9021a
[3.12] GH-121970: Rewrite the C-API annotations extension (GH-121985) (#122025)
(cherry picked from commit 22c9d9c1fc)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2024-07-19 12:48:50 +00:00
Serhiy Storchaka
39dea212f4
[3.12] gh-121905: Consistently use "floating-point" instead of "floating point" (GH-121907) (GH-122013)
(cherry picked from commit 1a0c7b9ba4)
2024-07-19 09:08:33 +00:00
sobolevn
6a19d22a19
[3.12] gh-121834: Improve complex C-API docs (GH-121835) (#121897)
* [3.12] gh-121834: Improve `complex` C-API docs (GH-121835)
(cherry picked from commit 72dccd6073)

Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2024-07-17 07:30:18 +00:00
Miss Islington (bot)
004758e3a4
[3.12] gh-121749: Fix discrepancy in docs for PyModule_AddObjectRef (GH-121750) (GH-121753)
(cherry picked from commit 26dfb27712)

Co-authored-by: Dominic H <dom@dominic.sk>
2024-07-14 12:31:58 +02:00
sobolevn
5492f84c14
[3.12] gh-121615: Improve module.rst C-API docs with better error descriptions (GH-121616) (#121619)
(cherry picked from commit e6264b44dc)
2024-07-11 09:12:06 +00:00