1126 Commits
Author SHA1 Message Date
crypt0lith 415ebffc47 Docs: Fix built-in function __self__ attribute descriptions (GH-159653)
Since PEP 3121, functions in C modules are bound to their module, so
their __self__ is the module object. The inspect.isbuiltin docstring,
the inspect attribute table and the data model reference still say
it is None, as it was in Python 2. Describe it as the module object
the function was defined in, or None.
2026-10-19 12:48:08 -04:00
Harjoth Khara c4447105ab gh-137528: Document the co_linetable code object attribute (GH-151425) 2026-09-21 14:01:39 +02:00
Benjamin Peterson 993fd8ec59 fixes gh-157633: Update Unicode data to Unicode 18.0.0 (#157634)
There is one code change for grapheme clustering. Rule GB9c was simplified in the latest version of the specification.
2026-09-16 11:34:53 -07:00
Ned Batchelder 59c4bddb17 Docs: split builtins to their own page from library (#156682)
* Docs: split builtins to their own page from library

* review feedback

* addressed Hugo's feedback

* update the What's Next page

* one more wording tweak

* move builtins to their own directory. fix the reference name

* moved pages need to be noted in tools/removed-ids.txt

* add Python to the builtins reference title

* add sphinxext-rediraffe for the library->builtins split

* update check-html-ids to handle rediraffe redirects

* now we don't need (page missing) for the redirected pages

* update other references to moved pages

* A seealso from builtins to library

* make a nice section for rediraffe settings

* move the builtins note to the end, as a seealso

* address merwok's comments

* cache looking for ids in files

* simplify the intro paragraphs
2026-09-13 11:55:44 -04:00
9bd670cba2 gh-141984: Add "exhausted" to glossary, link existing mentions (GH-157225)
Co-authored-by: Blaise Pabon <blaise@gmail.com>
Co-authored-by: Stan Ulbrych <stan@python.org>
2026-09-10 16:16:18 +02:00
Lucas 2723799c7f gh-156837: Refer to yield expressions in generator function definitions (GH-156863) 2026-09-09 16:33:53 +02:00
7d701ebb4c gh-141984: Move generator iterator reference out of syntax docs (GH-154884)
Co-authored-by: Blaise Pabon <blaise@gmail.com>
Co-authored-by: Stan Ulbrych <stan@python.org>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2026-09-02 16:09:32 +02:00
Aradhya Gupta 852381efee gh-156614: Fix the parameter list grammar in the language reference (#156622) 2026-08-30 18:08:35 +01:00
Petr Viktorin 228b1bf745 gh-65961: Document __cached__ removal in What's New & clarify references to it (GH-156053)
- Mention the change in What's New
- Clarify references to ``__cached__`` now that the term it doesn't link to its docs.
- Move the ``.. versionchanged`` from ``__file__`` docs to the top level.
2026-08-20 17:02:56 +02:00
c843cb758e gh-61310: Document package precedence over same-named modules (#153211)
Co-authored-by: TheD0ubleC <cc@scmd.cc>
Co-authored-by: Stan Ulbrych <stan@python.org>
2026-07-08 17:28:30 +00:00
Jonathan DungandStan Ulbrych 856049a9d9 Fix minor typos in 'Compound statements' docs (#149666)
Co-authored-by: Stan Ulbrych <stan@python.org>
2026-07-05 13:23:49 +02:00
Ned Batchelder 54524ab669 Docs: link to language reference instead of PEP (#152462) 2026-06-28 15:01:36 -04:00
da-woods fd53ae1139 gh-141510 Document and test frozendict class matching behaviour (#150799)
Frozendict has `_Py_TPFLAGS_MATCH_SELF` set so works correctly
with the single-arg class matching. However it isn't documented
in the list of classes this works with and it isn't tested.

The test is some way below the other similar tests but anything
else would need a large renumbering.
2026-06-18 14:53:09 +02:00
7bbb9607a2 gh-141984: Reword the Generator expressions section (GH-150518)
Co-authored-by: Blaise Pabon <blaise@gmail.com>
Co-authored-by: Stan Ulbrych <stan@python.org>
2026-06-10 16:45:30 +02:00
Jonathan Dung e3762114e5 Mention frozendict in object.__hash__() documentation (#148867) 2026-06-08 12:39:41 +01:00
7a468a1012 gh-150032: Tidy up 3.15 pending removals (#149594)
Co-authored-by: Savannah Ostrowski <savannah@python.org>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Brett Cannon <brett@python.org>
2026-06-03 17:29:13 +03:00
Victorien deb33ecba3 gh-105812: Make use of the Sphinx deco role in documentation (#139598) 2026-06-03 13:14:47 +00:00
50fe49c879 gh-150319: Replace all documentation which says "See PEP 585" (#150325)
* Replace all documentation which says "See PEP 585"

The following classes in the stdlib get simple updates:

- array.array
- asyncio.Future
- asyncio.Task
- collections.defaultdict
- collections.deque
- contextvars.ContextVar
- contextvars.Token
- ctypes.Array
- os.DirEntry
- re.Match
- re.Pattern
- string.templatelib.Interpolation
- string.templatelib.Template
- types.MappingProxyType
- queue.SimpleQueue
- weakref.ref

The following classes are documented publicly as functions, and are
therefore updated internally (`__class_getitem__.__doc__`) but not in the
public docs:

- functools.partial
- itertools.chain

The following builtin types have updates to `__class_getitem__.__doc__`
but not to any documentation pages:

- BaseExceptionGroup
- coroutines (from generators)
- dict
- enumerate
- frozendict
- frozenset
- generators (and async generators)
- list
- memoryview
- set
- slice
- tuple

Special cases:

- union objects are now documented as "supporting class-level []",
  rather than anything to do with generics.

- Templates might be generic over a single type (union, in theory) or
  over a TypeVarTuple. As this is not currently fully settled, it is
  marked with a comment and a mild hint that it is a single type is used
  (namely, "type" is singular rather than "types", plural)

* Apply suggestions from code review

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>

* Correct several class getitem docs

And expand the text for tuples.

Co-authored-by: Jelle Zijlstra <906600+JelleZijlstra@users.noreply.github.com>

* Add notes on generic typing of builtins

* Fix typo in tuple.__class_getitem__ docstring

* Typo fix: malformed refs

Fix `generic` links which weren't marked as `:ref:`.

* Strike unnecessary docs on generic-ness

Co-authored-by: Jelle Zijlstra <906600+JelleZijlstra@users.noreply.github.com>

* Apply suggestions from code review

These are applied at both the originally indicated locations and in the
corresponding docstring definitions.

Co-authored-by: Alex Waygood <66076021+AlexWaygood@users.noreply.github.com>

* Update Doc/library/re.rst

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>

* Update Objects/enumobject.c

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>

* Remove tuple generic doc in 'stdtypes' page

This is covered in more detail in the cross-linked typing documentation.
The other copy of this documentation -- in the docstring for
`tuple.__class_getitem__` -- is left in place.

* Fix whitespace around new doc of generics

Per review, do not introduce or remove whitespace such that section
breaks are altered by the introduction of doc on various generic types.

In most cases, this is a removal of an extra line.

In one case (Arrays), it is the reintroduction of a line.

Additionally, two other minor fixes are included:
- incorrect indent on 'defaultdicts'
- make `mappingproxy.__class_getitem__.__doc__` consistent with other
  mapping type generic docs

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

* Move placement of memoryview generic note

Previous placement was at the end of the main docstring, which is
consistent with other types but places it after a section on various
methods (which makes it read somewhat inconsistently). Moving it up
helps resolve.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

* Ensure sphinxdoc does not start sentences lowercase

Lowercase class names at the start of sentences are marked out with the
`class` role. In the case of `deque`, documentation already refers to
these as `Deques`, so this form is preferred.

* Apply suggestions from code review

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

* Fix line endings and wrap more tightly

Line endings fixed by pre-commit ; also re-wrapped the MappingProxyType
text which was too long.

* Use 'ContextVars' style in sphinx doc

---------

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Jelle Zijlstra <906600+JelleZijlstra@users.noreply.github.com>
Co-authored-by: Alex Waygood <66076021+AlexWaygood@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-06-02 21:13:34 +01:00
Taeknology 9ba2a89179 gh-148672: Document namespace subpackages inside regular packages (#150056) 2026-06-01 12:22:42 -07:00
Oral Ersoy Dokumacı 779694faba gh-150403: Document frozendict in language reference Mappings section (GH-150404) 2026-05-29 22:40:22 +03:00
55f2518326 gh-141984: Reword docs on "enclosed" atom grammar (GH-148622)
Reorganize and reword the docs on atoms in parentheses, brackets and braces:
parenthesized groups, list/set/dict/tuple displays, and comprehensions.
(Generator expressions and yield atoms are left for later.)

In the spirit of better matching the underlying grammar, *comprehensions* are
covered separately from non-comprehension displays. Also, parenthesized forms
(with a single expression) and tuple displays are separated.
All sections are rewritten to start with simple cases and build up to the full
formal grammar.

Co-authored-by: Blaise Pabon <blaise@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2026-05-27 14:32:33 +02:00
Ivy Xu 99c254e2f7 gh-149861: Fix rule in match statement case_block PEG grammar (GH-149908) 2026-05-27 12:25:21 +02:00
siliconforks a38804bb98 gh-148444: Use "zero of any numeric type" instead of "numeric zero of all types" (#148455) 2026-05-24 12:52:13 +05:30
Pablo Galindo Salgado 1f3c2679f1 gh-149321: Remove lazy_imports=none startup mode (#149389) 2026-05-19 16:01:15 -07:00
Petr Viktorin c37529293d Link to existing rules in compound_stmts.rst (GH-149811)
In gh-138418, `!` was added to links to rules that don't exist in
the docs, in order to silence broken link warnings.
However, productionlist doesn't parse the `!`, which ends up in
the rendered documentation. (It's possible that gh-127835 broke
the `!` support.)

Replace the names with ones that appear in docs:

- `star_named_expression` in the grammar corresponds to
  `flexible_expression` in the docs
- `star_named_expressions` in the grammar corresponds to
  `flexible_expression_list` in the docs
- `named_expression` in the grammar corresponds to
  `assignment_expression` in the docs

Having two sets of names isn't great of course. Consolidating them
is tracked in (subissues of) gh-127833.
2026-05-14 18:47:52 +02:00
Kit Dallege b8ebd078f9 gh-137337: Clarify import statement namespace binding (GH-144607)
It is not always in the local namespace.
2026-05-04 17:45:00 +03:00
sobolevn 85d3bcd4f3 gh-134690: Removed deprecated codetype.co_lnotab (#134691) 2026-04-25 19:13:48 +03:00
Bartosz Sławecki 9dab866f9c gh-148588: Document __lazy_modules__ (#148590) 2026-04-25 15:23:40 +01:00
Bartosz Sławecki 448d7b96c1 gh-145239: Accept unary plus literal pattern (#148566)
Add '+' alternatives to signed_number and signed_real_number grammar
rules, mirroring how unary minus is already handled for pattern matching.
Unary plus is a no-op on numbers so the value is returned directly without
wrapping in a UnaryOp node.
2026-04-23 22:07:28 +03:00
Stan Ulbrych b1d2d9829c Docs: Fix a typo in the 'Non-ASCII characters in names' section (#148043) 2026-04-04 17:45:52 +01:00
Lysandros Nikolaou 847f83ef1c gh-142518: Add thread safety notes for the buffer protocol (#145911) 2026-03-18 14:18:28 +01:00
Cody MaloneyandCarol Willing cf7c67b7c6 gh-101100: Fix sphinx reference warnings around I/O (#139592)
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
2026-03-11 10:02:23 +02:00
Ali Towaiji 2114da976c gh-145591: Move slicing note to __getitem__ (GH-145606) 2026-03-10 16:48:41 +01:00
Hugo van Kemenade 6024d3c6da Python 3.15.0a7 2026-03-10 14:31:15 +02:00
indoor47andAdam 11eec7a492 gh-145305: Update ocert.org URLs in docs from http to https (#145304)
Co-authored-by: Adam (indoor47) <adamai@agentmail.to>
2026-02-27 18:24:39 +02:00
112d8ac972 gh-141984: Reword and reorganize the first part of Atoms docs (GH-144117)
Co-authored-by: Blaise Pabon <blaise@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2026-02-18 14:13:21 +01:00
Serhiy Storchaka 9e8fa2d4d1 gh-144386: Update equivalent code for "with", "async with" and "async for" (GH-144472)
They use special method lookup for special methods.
2026-02-18 13:13:32 +02:00
46d5106cfa gh-142349: Implement PEP 810 - Explicit lazy imports (#142351)
Co-authored-by: T. Wouters <twouters@meta.com >
Co-authored-by: Brittany Reynoso <breynoso@meta.com>
Co-authored-by: Dino Viehland <dinoviehland@meta.com>
2026-02-12 00:15:33 +00:00
Hugo van Kemenade 15b216f30d Python 3.15.0a6 2026-02-11 14:23:15 +02:00
Serhiy Storchaka c81e1843d4 gh-74955: Document that __all__ must contain strings in normalization form NFKC (GH-144504) 2026-02-05 20:06:33 +02:00
e423e0c2cc gh-141984: Reword and reorganize Subscription (and Slicing) docs (GH-141985)
Co-authored-by: Blaise Pabon <blaise@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2026-02-04 16:08:23 +00:00
adam j hartzandJelle Zijlstra ccbe41e27c gh-143055: Implementation of PEP 798 (#143056)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2026-01-30 20:37:52 -08:00
Victor Stinner 933540e332 gh-101888: Add function.__builtins__ to ref documentation (#144174) 2026-01-26 17:15:47 +01:00
Petr Viktorin f0a0467c17 gh-143054: Disallow non-top-level Cut for now (GH-143622)
The behaviour of Cut in nested parentheses, Repeat, Opt, and similar
is somewhat chaotic. Apparently even the academic papers on PEG aren't
as clear as they could be.

And it doesn't really matter. Python only uses top-level cuts.
When that changes, we can clarify as much as necessary (and even
change the implementation to make sense for what we'll need).

Document that this is deliberately unspecified, and add a test to
make sure any decision is deliberate, tested and documented.
2026-01-13 13:21:59 +01:00
James Hilton-BalfeandJelle Zijlstra 265381b7e8 gh-128335: Make slice generic at runtime (#128336)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2026-01-11 11:27:24 -08:00
Serhiy Storchaka 4d21297d28 gh-41779: Allow defining any __slots__ for a class derived from tuple (GH-141763) 2026-01-06 11:36:00 +02:00
Thanos 79c03ac001 gh-69686: Remove untrue part of __import__ replacement docs (#143261)
Remove untrue part of `__import__` replacement docs

The original statement effectively says that replacing `__import__` at global scope affects import statements, and not only that, but only import statements within the rest of the executing module. None of that has been true since at least Python 2.7, I think.

This was likely missed in python/cpython#69686.
2025-12-29 21:16:54 -08:00
Hugo van Kemenade f1eb0c0b0c Python 3.15.0a3 2025-12-16 14:26:12 +02:00
SYan212 39ecb17103 typo fixes in docs (#142683) 2025-12-14 13:47:22 +05:30
dr-carlos e5a48480c0 Add missing comma to tuple in except* docs (#142395) 2025-12-14 00:51:35 +02:00