Commit graph

131661 commits

Author SHA1 Message Date
Bernát Gábor
e833f57383
gh-150818: Speed up logging.getLogger() for existing loggers (GH-150825) 2026-06-04 17:15:12 +01:00
Mark Shannon
038495db33
GH-148960: Ensure that asserts are ignored if NDEBUG is set (#150916) 2026-06-04 15:11:33 +01:00
Ivan Marton
ac3694b008
gh-84649: Make TimedRotatingFileHandler use CTIME instead of MTIME (GH-24660)
The TimedRotatingFileHandler previously only used st_mtime attribute of the
log file to detect whether it has to be rotate yet or not. In cases when the
file is changed within the rotatation period the st_mtime is also updated
to the current time and the rotation never happens.

It's more appropriate to check the file creation time (st_ctime) instead.
Whenever available, the more appropriate st_birthtime will be in use. (This
feature is available on FreeBSD, MacOS and Windows at the moment.) If
the st_mtime would be newer than st_ctime (e.g.: because the inode
related to the file has been changed without any file content
modification), then the earliest attribute will be used.
2026-06-04 13:50:33 +00:00
Jiseok CHOI
fc9c4db130
gh-150913: Fix sqlite3.Blob validation for empty slice assignment (GH-150915)
ass_subscript_slice() returned early when the computed slice length
was zero, bypassing validation performed for non-empty slices.
2026-06-04 16:41:47 +03:00
sobolevn
d83d50b5b7
gh-150750: Fix a race condition in deque.index with free-threading (#150779) 2026-06-04 13:31:31 +00:00
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
Batuhan Taskaya
3ff2117ea3
bpo-38131: Improve messages when generating AST nodes from objects with wrong field values (GH-17715) 2026-06-04 10:58:51 +00:00
Miro Hrončok
cb064e746d
Fix 2 broken links in documentation (#150892)
Co-authored-by: Stan Ulbrych <stan@python.org>
2026-06-04 10:42:06 +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
Stefano Rivera
6b24376fed
Manpage formatting tweaks & lint (GH-132338)
Following on from GH-132291 this is the second part of the patch from https://bugs.debian.org/1101406

This tweaks the formatting of a few bits of the manpage.
2026-06-04 09:35:04 +02:00
Hood Chatham
57d444612d
gh-145177: Fix Emscripten help text (#150874)
Removes some stray commas in help text.
2026-06-04 08:00:51 +08:00
Stan Ulbrych
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
Hugo van Kemenade
b643826c11
Docs: Replace hardcoded SOURCE_URI with patchlevel check (#150850) 2026-06-03 16:37:09 +03: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
da-woods
58beae7319
Correct Stable ABI documentation for METH_FASTCALL (GH-149593)
* Correct Stable ABI documentation for METH_FASTCALL

The current documentation says:

> 
> METH_FASTCALL
>    Part of the Stable ABI since version 3.7.
>
> [...]
>
>   Added in version 3.7.
>
>    Changed in version 3.10: METH_FASTCALL is now part of the stable ABI.

so is contradictory about when it was added to the Stable ABI.  Looking at the header it seems like 3.10 is right.
2026-06-03 15:20:35 +02:00
Victorien
deb33ecba3
gh-105812: Make use of the Sphinx deco role in documentation (#139598) 2026-06-03 13:14:47 +00:00
Yashraj
6453065db9
gh-141004: Document unstable perf map functions in ceval.h (GH-143492) 2026-06-03 12:36:25 +00:00
Robsdedude
5553e003ca
Fix a typo in SSLSocket docs (GH-150839) 2026-06-03 08:18:06 -04:00
Petr Viktorin
c720e18c94
gh-146636: Add Free-threaded Stable ABI migration guide (GH-150580)
Co-authored-by: Charlie Lin <tuug@gmx.us>
Co-authored-by: da-woods <dw-git@d-woods.co.uk>
Co-authored-by: Stan Ulbrych <stan@python.org>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2026-06-03 14:02:36 +02:00
Edward Xu
41eb8ee2bb
gh-148613: Fix race in gc_set_threshold and gc_get_threshold (#150356) 2026-06-03 16:58:26 +05:30
Nazım Can Altınova
494f2e3c92
gh-150723: Fix perf jitdump files on macOS (#150728)
The perf jitdump format defines the thread id field of the JR_CODE_LOAD
record as a 32-bit value, but on macOS it was declared as a uint64_t
(since pthread_threadid_np() returns a uint64_t). Those extra 8 bytes
plus alignment padding shifted every following field, so parsers reading
the file by the spec misread code_size as the code address and failed to
resolve any Python frames.

Declare thread_id as uint32_t on all platforms and truncate the macOS
thread id when writing the record. The value is only informational.
Symbols are resolved by address, and not thread ids so truncation is
safe here.

* Use mach_absolute_time for macOS jitdump timestamps

On macOS the jitdump file is consumed by profilers such as samply, which
timestamp their samples using mach_absolute_time(). The jitdump events were
stamped with clock_gettime(CLOCK_MONOTONIC), a different clock domain that
keeps advancing while the system is asleep, so the JIT code mappings could be
off by days relative to the samples and no Python frame would resolve. Stamp
jitdump events with mach_absolute_time() on macOS so they share the sampler's
clock domain. Linux continues to use CLOCK_MONOTONIC to stay aligned with perf.

Exercise the -Xperf_jit (jitdump) backend through samply and assert that
Python frames resolve, exercising the binary jitdump path end to end.
Skipped when samply is not installed.
2026-06-03 01:15:34 +01:00
Florian Best
29805f00a1
gh-91099: fix[imaplib]: call Exception with string instance (#31823)
* bpo-46943: fix[imaplib]: call Exception with string instance

Adjust the behavior of 'login' to be similar to `authenticate()`, 
where self.error is called with a str() instance.

Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
2026-06-02 16:42:04 -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
Seth Larson
60ac9b56fe
Add link to new security policy (#150800) 2026-06-02 14:20:36 -04: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
Gustaf
f7e0fb60cf
gh-101913: changed wording of docstring for _parsedate_tz (#134446)
Fixed incorrect word.

Co-authored-by: Gustaf <79180496+GGyll@users.noreply.github.com>
2026-06-02 11:02:19 -04:00
Bartosz Sławecki
e3fa52d953
gh-148587: Document sys.lazy_modules (#150742) 2026-06-02 16:00:45 +01:00
Hugo van Kemenade
7241db1169
Silence experimental coroutine deprecation warnings (#150788)
Co-authored-by: Zachary Ware <zach@python.org>
2026-06-02 14:55:28 +00:00
Øyvind Rønningstad
86867edb84
gh-149187: Document frozendict() under 'Built-in Functions' (#149185) 2026-06-02 14:55:16 +01:00
Kumar Aditya
df34a2f712
gh-150766: export _PyGC_VisitFrameStack and _PyGC_VisitStackRef functions (#150767) 2026-06-02 18:38:21 +05:30
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
stratakis
025cc26b40
gh-115119: Fix libmpdec detection when pkg-config files are missing (#150502)
The fallback for systems with no mpdecimal .pc files used AC_LINK_IFELSE
directly, which relied on LIBMPDEC_LIBS being set. On failure this was empty
so the link test ran without -lmpdec.

Use AC_CHECK_HEADER and AC_CHECK_LIB instead.
2026-06-02 11:43:30 +02:00
Seth Larson
991224b1e8
gh-149079: Fix O(n^2) canonical ordering in unicodedata.normalize() (GH-149080)
Replace the insertion sort used for canonical ordering of combining
characters with a hybrid approach: insertion sort for short runs (< 20)
and counting sort for longer runs, reducing worst-case complexity from
O(n^2) to O(n). This prevents denial of service via crafted Unicode
strings with many combining characters in alternating CCC order.

Co-authored-by: ch4n3-yoon <ch4n3.yoon@gmail.com>
Co-authored-by: Seokchan Yoon <13852925+ch4n3-yoon@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <stan@python.org>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Maurycy Pawłowski-Wieroński <maurycy@maurycy.com>
2026-06-02 11:39:50 +02:00
Stan Ulbrych
c52d2b16dd
gh-149805: Fix SystemError when compiling __classdict__ class annotation (#149806) 2026-06-02 10:17:03 +01:00
Manoj K M
cee3327b92
Fix two typos in 'Exception Handling' C-API documentation (#150674) 2026-06-02 10:14:13 +01: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
Bartosz Sławecki
5a2d2736a6
gh-150052: Resolve un-loaded lazily loaded submodules via module.__getattr__ instead of publishing lazy values (#150055) (#150744) 2026-06-02 09:58:51 +01: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
Bernát Gábor
c79e18a8e5
gh-150717: Avoid mark-array allocation for groupless regex patterns (GH-150719)
state_init() always did PyMem_New(state->mark, groups*2), which for a
pattern with no capturing groups is PyMem_Malloc(0) -- a real allocation
(plus matching free) on every match/search/fullmatch call, for an array
that is never read: groupless patterns emit no MARK opcodes and group 0's
span is taken from state->start/ptr.

Guard the allocation with `if (pattern->groups)`. state->mark stays NULL
(set by the preceding memset), and both the error path and state_fini
already PyMem_Free(NULL) safely.
2026-06-02 10:45:30 +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
László Kiss Kollár
f4426654fd
gh-150720: Remove '-d 1' in test_script_error_treatment (#150736) 2026-06-02 00:51:51 +00:00
Russell Keith-Magee
71fc4c66d3
gh-150644: Tag Apple system log messages as public. (#150645)
macOS 26 changed the default visibility of "dynamic" system messages. This
changes the logging strategy to tag all messages as "public" so they are
visible in the system log without special configuration.
2026-06-02 06:25:46 +08:00
Pablo Galindo Salgado
ce073ec4cc
gh-150429: Fix sampling profiler generator stack test (#150433) 2026-06-01 21:27:39 +01:00
Serhiy Storchaka
b23646adf1
gh-93417: Improve test_mimetypes (GH-150725)
* Separate tests for module-level API and for the MimeTypes class.
* Add tests for mimetypes.init() and MimeTypes() with knownfiles and with
  explicitly passed files.
2026-06-01 23:02:40 +03:00
Taeknology
9ba2a89179
gh-148672: Document namespace subpackages inside regular packages (#150056) 2026-06-01 12:22:42 -07:00
Sergey B Kirpichev
59abdf8207
gh-115119: Remove superfluous TEST_COVERAGE private macro from _decimal module (GH-149756)
It was previously shared with `libmpdec`, which is no longer vendored.
2026-06-01 13:41:21 -05:00