Commit graph

14857 commits

Author SHA1 Message Date
Adorilson Bezerra
a96cba5c4a
gh-106318: Add doctest role and a 'See also' to the str.split() docs (#144367) 2026-06-04 12:39:14 +01:00
jb2170
ae507e3b14
gh-119670: Add force keyword only argument to shlex.quote (#148846)
There are propositions to add a single-quote-double-quote switch
(gh-90630), so to avoid hiccups of people passing `force` as a
positional and it being used for the single-double switch, we make
kwargs kwargs-only.

Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
2026-06-04 11:06:02 +02:00
Abduaziz π
5915a1fb9d
gh-132467: Document and test that generic aliases are not classes (#133504)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2026-06-03 13:35:25 +00:00
Victorien
deb33ecba3
gh-105812: Make use of the Sphinx deco role in documentation (#139598) 2026-06-03 13:14:47 +00:00
Robsdedude
5553e003ca
Fix a typo in SSLSocket docs (GH-150839) 2026-06-03 08:18:06 -04:00
Stephen Rosen
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
Brian Schubert
18c6d3ccc3
Fix description of the function parameter of shutil.register_archive_format() (GH-145087) 2026-06-02 22:12:36 +03:00
Mohsin Mehmood
551bc2cb5e
gh-141627: Fix BufferedRandom inheritance documentation (GH-141629)
BufferedRandom does not inherit from BufferedReader and BufferedWriter
in the C implementation.
2026-06-02 18:06:39 +00:00
Bartosz Sławecki
e3fa52d953
gh-148587: Document sys.lazy_modules (#150742) 2026-06-02 16:00:45 +01:00
Øyvind Rønningstad
86867edb84
gh-149187: Document frozendict() under 'Built-in Functions' (#149185) 2026-06-02 14:55:16 +01:00
Bernát Gábor
e37ce56977
gh-89554: Document _thread.LockType as a class (#150684)
_thread.LockType is a class (the type of lock objects), but was documented
with the ".. data::" directive, so ":class:" cross-references to it cannot
resolve against a py:class target.

Switch the entry to ".. class::", move it next to the lock methods, and
document acquire(), release() and locked() as methods of the class.  Keep
the old _thread.lock.* URL fragments working with raw HTML anchors.
2026-06-02 14:55:01 +02:00
Sepehr Rasouli
60fdb3192b
gh-149738: Fix segmentation fault bug in sqllite3 (#149754)
Deleting the `row_factory` or `text_factory` attribute is no longer allowed.
2026-06-02 11:07:08 +02:00
Bernát Gábor
35c314d2b7
gh-89554: Document typing.ParamSpecArgs and ParamSpecKwargs as classes (GH-150677)
Use the directive "class" instead of "data" for ParamSpecArgs and ParamSpecKwargs.
2026-06-02 11:07:51 +03:00
Bernát Gábor
bc055444e4
gh-89554: Document standard type objects in types as classes (GH-150676)
Use the directive and the role "class" instead of "data" for classes
exposed in the types module.
2026-06-02 11:03:36 +03:00
Bernát Gábor
10c421970b
gh-89554: Document weakref type objects as classes (#150678)
Use the "class" directive instead of "data" for ReferenceType,
ProxyType and CallableProxyType.
2026-06-02 10:59:15 +03:00
Bernát Gábor
e40190e104
gh-89554: Document NoneType, NotImplementedType and EllipsisType as classes (GH-150682)
Always use the directive and the role "class" instead of "data" for
NoneType, NotImplementedType and EllipsisType.
2026-06-02 10:55:01 +03:00
Barry Warsaw
27ebd9abce
gh-150228: Improve the PEP 829 batch processing APIs (#150542)
* gh-150228: Improve the PEP 829 batch processing APIs

As previously discussed with @ncoghlan and approved for 3.15b2 by @hugovk,
this implements the batch processing APIs for addsitedir() and friends.  We
remove the `defer_processing_start_files` flag which required some implicit
module global state, and promote StartupState to the public documented API.

This also moves the bulk of the module global functions into methods of the
`StartupState` class, so it removes the awkward APIs in 3.15b1.  Now, instances
of this class are an accumulator for startup state, using `StartupState.process()`
to process them.  Callers can now batch up startup state themselves by using
the methods on this class.  The module global functions are shims for this
which preserve the legacy APIs and semantics using the new state class.

This PR also fixes the interleaving regression identified by @ncoghlan in the
same issue.  Now, .pth file sys.path extensions are added to sys.path after
the sitedir that the .pth file is found in, restoring the legacy behavior.

Along the way, I've made a lot of improvements to function docstrings,
site.rst documentation, and comments in the code explaining what's going on.

* Add a note that if known_paths is provided to StartupState.__init__(), it
  will get mutated in place.
* Improve some conditional flows.
* Improve some comments.
* Improve the what's new entry.

* Make test_impl_exec_imports_suppressed_by_matching_start() more robust

Based on PR comment, we need to read both the .pth and .start files, and prove
that the .pth file's import line (which passes a bigger increment) is not
called, but the .start file's entry point (which uses the default increment)
is called.

* As per review, move some methods to the private API

_read_pth_file() and _read_start_file() are not intended to be part of the
public API surface outside of the site module, so even though they are used by
methods outside of the StartupState class, make them privately named.

* Resolve several review feedbacks

* Move a `versionadded`
* Better list comprehension formatting (use the output from
  `ruff format --line-length 78`)

* Add docs for site.makepath() and point the case-normalization requirement to
  this utility function.
* Note that StartupState.process() is not idempotent.

* Address another feedback comment

This time, we get rid of the legacy implementation `reset` local, which was
always difficult to understand, and just implement a return value based on the
processing mode selected.

* Changes based on gh-150228 review

The comment by @encukou that started this change:

```
I still see two red flags here though: an argument that doesn't combine with
other arguments, and (another instance of) changing the return type based on
an argument.

Did you consider adding a StartupState.addsitedir(sitedir) method, instead of
the startup_state argument?
```

As it turns out, this is an even cleaner design.  By moving the bulk of the
previous module global functions into `StartupState` methods, we can get rid
of all the awkward `startup_state` keyword-only arguments which conflict
with `known_path` (Petr's first point).  We can also get rid of the
return value dichotomy (Petr's second point) because now we can preserve
exactly the Python 3.14 API in the module global functions, and implement
the better APIs in the class methods.  We also generally don't have to
pass around `process_known_sitedirs`.

Now the following module global functions are essentially shims around
class methods:

* site.addsitedir() -> StartupState.addsitedir()
* site.addusersitepackages() -> StartupState.addusersitepackages()
* site.addsitepackages() -> StartupState.addsitepackages()
* Additional minor changes
* Remove a now unused parameter


Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2026-06-01 18:43:18 -07:00
Sergey B Kirpichev
46b5e3e941
gh-80480: Remove deprecated 'u' array type code (#149535)
Reuse array.typecodes in tests.
2026-06-01 11:57:55 +00:00
M. Greyson Christoforo
2f8f569ba9
Clarify docs for scheduler.run(blocking=False) (GH-129575) 2026-05-31 12:11:17 +00:00
Serhiy Storchaka
1de909b324
gh-150636: Clarify difference between copy.copy() and the copy() methods (GH-150637)
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: Stan Ulbrych <stan@python.org>
2026-05-31 15:08:55 +03:00
Stan Ulbrych
1837c17bc7
gh-140553: Mark *gettext parameters as positionaly only in documentation (#140598) 2026-05-31 09:08:17 +01:00
htjworld
2b94b92394
gh-131178: Fix mimetypes CLI docs, mention that errors go to stdout (#149683)
Co-authored-by: sobolevn <mail@sobolevn.me>
2026-05-31 07:45:48 +00:00
Sergey B Kirpichev
5b5ffce05c
Correct frexp() docs for zero and non-finite numbers (GH-149753)
0.5 <= abs(m) < 1 is only true for finite nonzero numbers
2026-05-31 07:29:44 +00:00
sobolevn
90c1d86f34
gh-149609: Raise deprecation warnings for abc.{abstractclassmethod,abstractstaticmethod,abstractproperty} (#149636) 2026-05-31 07:26:52 +00:00
Patrick Rauscher
73d8e9a47c
gh-117291: Explain usage of null bytes in Array(c_char).value (GH-117292) 2026-05-31 10:20:49 +03:00
Paper Moon
0f1f7c7889
gh-141444:fix broken URLs and examples in urllib.request.rst (#144863)
* Doc: fix broken URLs and examples in urllib.request.rst (gh-141444)

* Doc: update urllib.request examples to handle gzip compression

---------

Co-authored-by: Senthil Kumaran <senthil@python.org>
2026-05-30 19:08:18 -07:00
Joshix-1
af10734907
gh-150524: Remove outdated note in binascii.a2b_hex() documentation (GH-150525)
bytes.fromhex() accepts ASCII bytes and bytes-like objects as input since 3.14
2026-05-30 19:18:39 +00:00
Gustaf
2c20f9ce17
gh-123138: Updated email.headerregistry docs to include required keyword parse_tree (GH-134450) 2026-05-30 20:59:42 +03:00
Fang Li
6ecd197c03
gh-109503: Fix document for shutil.move() on usage of os.rename() since it's inaccurate (GH-109507)
Nonatomic move might be used even if the files are
on the same filesystem in some cases.
2026-05-30 14:26:03 +00:00
Jonathan Dung
678fd8452c
gh-150501: Correct inspect.getattr_static docs signature (#150504) 2026-05-30 11:18:25 +02:00
Stan Ulbrych
5535c1f9c0
Add a security warning about pydoc's HTTP server (#150409) 2026-05-29 13:29:59 +01:00
Rafael Weingartner-Ortner
baf11a4e9a
gh-139398: [Enum] Add supported sunder names to __dir__ for REPL completions (GH-139985)
* Add supported sunder names to Enum `__dir__`

This change adds the sunder names `_generate_next_value_`
and `_missing_` to the `__dir__` method of `EnumType` and `Enum`.
In Addition, The instance level sunder names
`_add_alias_` and `_add_value_alias_` are added to `Enum.__dir__`.

With the sunder names exposed in the `dir()` method,
the REPL autocomplete will also show them.

---------

Co-authored-by: SimonGPrs <107691772+SimonGPrs@users.noreply.github.com>
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
2026-05-28 12:55:38 -07:00
Chien Wong
cf2cd0be82
gh-115988: Add ARM64 and RISCV BCJ filters constants in lzma module (GH-115989)
---------

Signed-off-by: Chien Wong <m@xv97.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2026-05-28 08:05:03 -07:00
Stan Ulbrych
b53f6ca850
Add prominent crash warning to ctypes docs (GH-150410)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2026-05-28 10:13:14 +02:00
Serhiy Storchaka
8ab7b43a14
gh-62259: Add support of multi-byte encodings in the XML parser (GH-149860)
Supported encodings: "cp932", "cp949", "cp950", "Big5","EUC-JP",
"GB2312", "GBK", "johab", and "Shift_JIS".

Partially supported encodings (only BMP characters): "Big5-HKSCS",
"EUC_JIS-2004", "EUC_JISX0213", "Shift_JIS-2004", "Shift_JISX0213",
"utf-8-sig" and non-standard aliases like "UTF8" (without hyphen).

The parser now raises ValueError for known unsupported
multi-byte encodings such us "ISO-2022-JP" or "raw-unicode-escape"
instead of failing later, when encounter non-ASCII data.
2026-05-26 19:40:25 +00:00
devdanzin
832afeddce
gh-145896: Fix typos and stale docstrings in the traceback module (GH-145897) 2026-05-25 12:45:02 +03:00
Eduardo Villalpando Mello
0f32750fe2
gh-148932: Docs / profiling.sampling Windows limitations (#150272) 2026-05-24 12:54:36 +01:00
My-ABC
82191c6d2c
gh-150232: update Thread group parameter doc (#150283) 2026-05-23 13:52:44 +05:30
Omkar Kabde
9df2b6ccc7
gh-82907: Document mtime=0 for reproducible tarfile gzip output (GH-150269) 2026-05-22 21:02:56 +00:00
Hugo van Kemenade
de7c3bfd5b
gh-149189: Revert "Modern defaults for pprint (#149190)" (#150249) 2026-05-22 23:22:03 +03:00
Marin Misur
cf5c8c5698
gh-91372: Add mtime to gzip.open() (GH-32310) 2026-05-22 15:14:25 +03:00
adang1345
1daad8a163
gh-133998: Fix gzip file creation when time is out of range (GH-134278)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-22 10:20:08 +03:00
Jelle Zijlstra
f159419ae2
gh-149995: Update typing.py docstrings and documentation (#149996)
Some of these docstrings read as if they were written when typing.py was
first written, and things have evolved since then.

A few motivations:
- Call protocols protocols instead of ABCs. They are also ABCs, but the fact
  they are protocols is more relevant to typing.
- Avoid recommending direct use of .__annotations__ and steer users to
  annotationlib instead.
- For TypedDict, mention NotRequired before total=False since it is more
  general and probably more frequently useful.
- For overloads, mention runtime use first instead of stub use. I think early on
  there was talk of allowing overload only in stubs, but it is now heavily used at
  runtime too and that's more likely to be relevant to users.
2026-05-21 21:06:42 -07:00
Stan Ulbrych
87a879f4d0
Add summary table to the unicodedata doc (#149957) 2026-05-20 16:04:10 +01:00
Pablo Galindo Salgado
1f3c2679f1
gh-149321: Remove lazy_imports=none startup mode (#149389) 2026-05-19 16:01:15 -07:00
Stefanie Molin
47723af4e7
gh-134887: Add references to locale module for locale-aware number formatting references in string module docs (GH-134888) 2026-05-19 23:10:39 +02:00
Jason R. Coombs
192796cfd4
gh-143387: Update docs to reflect the behavior and note the changed version. (#150095) 2026-05-19 12:38:27 -07:00
Victor Stinner
29415c071f
gh-149473: Emit audit event on calling os.environ.clear() (#149768)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-05-19 18:38:12 +02:00
Jelle Zijlstra
08218030a5
gh-148829: Make sentinels' repr and module customizable (#149654)
Implementation of python/peps#4968; still needs SC approval.
2026-05-19 09:18:56 -07:00
Serhiy Storchaka
ba0aca3bff
gh-146581: Update docs for dangerous filenames in ZIP files (GH-149994)
Co-authored-by: Sebastian Gassner <sebastian.gassner@gmail.com>
2026-05-19 11:36:12 +03:00