gh-121333: Clarify what is the default executor for asyncio.run_in_executor (GH-121335)
(cherry picked from commit facf9862da)
Co-authored-by: AN Long <aisk@users.noreply.github.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Update example of str.split, bytes.split (GH-121287)
In `{str,bytes}.strip(chars)`, multiple characters are not treated as a
prefix/suffix, but as individual characters. This may make users confuse
whether `split` has similar behavior.
Users may incorrectly expect that
`'Good morning, John.'.split(', .') == ['Good', 'morning', 'John']`
Adding a bit of clarification in the doc.
(cherry picked from commit 892e3a1b70)
Co-authored-by: Yuxin Wu <ppwwyyxxc@gmail.com>
Co-authored-by: Yuxin Wu <ppwwyyxx@users.noreply.github.com>
docs: Fix "Py_TPFLAGS_MANAGED_WEAKREF is set in tp_flags" (GH-112237)
(cherry picked from commit 4232976b02)
Co-authored-by: da-woods <dw-git@d-woods.co.uk>
gh-114104: clarify asynchronous comprehension docs to match runtime behavior (GH-121175)
(cherry picked from commit 91313afdb3)
Co-authored-by: Danny Yang <yangdanny97@users.noreply.github.com>
gh-120522: Add a `--with-app-store-compliance` configure option to patch out problematic code (GH-120984)
* Add --app-store-compliance configuration option.
* Added blurb.
* Correct tab-vs-spaces formatting issue.
* Correct source file name in docs.
* Correct source code reference in Mac docs
* Only apply the patch forward, and ensure the working directory is correct.
* Make patching reslient to multiple builds.
* Documentation fixes found during review
* Documentation and configure.ac syntax improvements
* Regenerate configure script.
* Silence the patch echo output.
---------
(cherry picked from commit 48cd104b0c)
Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
GH-119054: Add alt text to pathlib inheritance diagram (GH-121158)
(cherry picked from commit 6b280a8498)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
GH-119054: Add "Expanding and resolving paths" section to pathlib docs. (GH-120970)
Add dedicated subsection for `home()`, `expanduser()`, `cwd()`,
`absolute()`, `resolve()` and `readlink()`. The position of this section
keeps all the `Path` constructors (`Path()`, `Path.from_uri()`,
`Path.home()` and `Path.cwd()`) near the top. Within the section, closely
related methods are kept adjacent. Specifically:
- `home()` and `expanduser()` (the former calls the latter)
- `cwd()` and `absolute()` (the former calls the latter)
- `absolute()` and `resolve()` (both make paths absolute)
- `resolve()` and `readlink()` (both read symlink targets)
- Ditto `cwd()` and `absolute()`
- Ditto `absolute()` and `resolve()`
The "Other methods" section is removed.
(cherry picked from commit d6d8707ff2)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
doc: Mention the missing reflected special methods for all binary operations (GH-119931)
(cherry picked from commit bf5e1065f4)
Co-authored-by: Paulo Freitas <me@paulofreitas.me>
* Move pprinter parameter descriptions to a table
* Make pprint doc with params markup
* Remove duplication of the parameters' description
---------
(cherry picked from commit 0890ad7c02)
Co-authored-by: Kerim Kabirov <the.privat33r+gh@pm.me>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
gh-120937: Reference weakref from the `__del__` documentation (GH-120940)
(cherry picked from commit 1c13b29d54)
Co-authored-by: chaen <christophe.haen@cern.ch>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
gh-120661: improve example for basic type hints (GH-120934)
(cherry picked from commit bb057ea107)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
PyDict_Next no longer locks the dictionary in the free-threaded build. Locking
around individual PyDict_Next calls is not sufficient because the function
returns borrowed references and because it allows concurrent modifications
during the iteraiton loop.
The internal locking also interferes with correct external synchronization
because it may suspend outer critical sections created by the caller.
(cherry picked from commit 375b723d58)
Co-authored-by: Sam Gross <colesbury@gmail.com>
- gh-119521: Rename IncompleteInputError to _IncompleteInputError and remove from public API/ABI (GH-119680)
(cherry picked from commit ce1064e4c9)
- gh-119521: Use `PyAPI_DATA`, not `extern`, for `_PyExc_IncompleteInputError` (GH-120955)
(cherry picked from commit ac61d58db0)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
docs: puremagic.what() as replacement for imghdr.what() (GH-120871)
(cherry picked from commit 22b8a35d6e)
Co-authored-by: Christian Clauss <cclauss@me.com>
gh-120896: Fix typo in version changed note of `urllib.parse.urlparse()` (GH-120898)
(cherry picked from commit b6fa8fe86a)
Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
This makes the following macros public as part of the non-limited C-API for
locking a single object or two objects at once.
* `Py_BEGIN_CRITICAL_SECTION(op)` / `Py_END_CRITICAL_SECTION()`
* `Py_BEGIN_CRITICAL_SECTION2(a, b)` / `Py_END_CRITICAL_SECTION2()`
The supporting functions and structs used by the macros are also exposed for
cases where C macros are not available.
(cherry picked from commit 8f17d69b7b)
gh-120773: document introspective attributes of an async generator object in the inspect module (GH-120778)
(cherry picked from commit 83d3d7aace)
Co-authored-by: blhsing <blhsing@gmail.com>
Update the documentation howto index page and group docs into 3 logical sections (GH-119366)
(cherry picked from commit a26d27e7ee)
Includes a follow-up fix to properly merge GH-119877:
* Add a link to free-threading HOWTO to the index (GH-120703)
(cherry picked from commit 45d5cab533)
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>
gh-118820: Zero-valued flag enum has no name (GH-118848)
(cherry picked from commit ed5ae6c4d7)
Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
gh-119960: Add information about regex flags in re module functions (GH-119978)
(cherry picked from commit a86e6255c3)
Co-authored-by: Awbert <119314310+SweetyAngel@users.noreply.github.com>
The `inspect.ismethoddescriptor()` function did not check for the lack of
`__delete__()` and, consequently, erroneously returned True when applied
to *data* descriptors with only `__get__()` and `__delete__()` defined.
(cherry picked from commit dacc5ac71a)
Co-authored-by: Jan Kaliszewski <zuo@kaliszewski.net>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
This exposes `PyUnstable_Object_ClearWeakRefsNoCallbacks` as an unstable
C-API function to provide a thread-safe mechanism for clearing weakrefs
without executing callbacks.
Some C-API extensions need to clear weakrefs without calling callbacks,
such as after running finalizers like we do in subtype_dealloc.
Previously they could use `_PyWeakref_ClearRef` on each weakref, but
that's not thread-safe in the free-threaded build.
(cherry picked from commit e8752d7b80)
Co-authored-by: Sam Gross <colesbury@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
gh-112346: Document the OS byte in `gzip.compress` output change in 3.11 (GH-120480)
(cherry picked from commit bac4edad69)
gh-112346: Describe the "os" byte in gzip output change.
Co-authored-by: Gregory P. Smith <greg@krypto.org>
gh-118596: Add thread-safety clarifications to the SSLContext documentation (GH-118597)
Add thread-safety clarifications to the SSLContext documentation. Per the issue:
This issue has also come up [here](https://github.com/psf/requests/pull/6667) where the matter was clarified by @tiran in [this comment](https://github.com/psf/requests/pull/6667):
> `SSLContext` is designed to be shared and used for multiple connections. It is thread safe as long as you don't reconfigure it once it is used by a connection. Adding new certs to the internal trust store is fine, but changing ciphers, verification settings, or mTLS certs can lead to surprising behavior. The problem is unrelated to threads and can even occur in a single-threaded program.
(cherry picked from commit 4f59f86382)
Co-authored-by: mm-matthias <43849132+mm-matthias@users.noreply.github.com>
gh-112346: Always set OS byte to 255, simpler gzip.compress function. (GH-120486)
This matches the output behavior in 3.10 and earlier; the optimization in 3.11 allowed the zlib library's "os" value to be filled in instead in the circumstance when mtime was 0. this keeps things consistent.
(cherry picked from commit 08d09cf5ba)
Co-authored-by: Ruben Vorderman <r.h.p.vorderman@lumc.nl>
This behavior is rather surprising and it was not clearly specified.
(cherry picked from commit 9e0b11eb21)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
gh-120361: Add `nonmember` test with enum flags inside to `test_enum` (GH-120364)
* gh-120361: Add `nonmember` test with enum flags inside to `test_enum`
(cherry picked from commit 7fadfd82eb)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
GH-119054: Add "Renaming and deleting" section to pathlib docs. (GH-120465)
Add dedicated subsection for `pathlib.Path.rename()`, `replace()`,
`unlink()` and `rmdir()`.
(cherry picked from commit d88a1f2e15)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
GH-119054: Add "Creating files and directories" section to pathlib docs. (GH-120186)
Add dedicated subsection for `pathlib.Path.touch()`, `mkdir()`,
`symlink_to()` and `hardlink_to()`. Also note that `open()`, `write_text()`
and `write_bytes()` are often used to create files.
(cherry picked from commit c2d810b6d4)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
* Remove "()" when refer to a class as a type.
* Use :func: when refer to a callable.
* Fix reference to the datetime.astimezone() method.
(cherry picked from commit 92c9c6ae14)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
gh-120128: fix description of argument to ipaddress.collapse_addresses() (GH-120131)
The argument to collapse_addresses() is now described as an *iterable*
(rather than *iterator*).
(cherry picked from commit f878d46e56)
Co-authored-by: Jan Kaliszewski <zuo@kaliszewski.net>
gh-119577: Adjust DeprecationWarning when testing element truth values in ElementTree (GH-119762)
Adjust DeprecationWarning when testing element truth values in ElementTree, we're planning to go with the more natural True return rather than a disruptive harder to code around exception raise, and are deferring the behavior change for a few more releases.
(cherry picked from commit 6b606522ca)
Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
gh-119287: clarify doc on BaseExceptionGroup.derive and link to it from contextlib.suppress (GH-119657)
(cherry picked from commit 5c02ea8bae)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
gh-119588: Update docs to reflect decision to include the change with Python 3.13 and not 3.12. (GH-120043)
(cherry picked from commit 4dcd91ceaf)
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
Add a dedicated subsection for `open()`, `read_text()`, `read_bytes()`,
`write_text()` and `write_bytes()`.
(cherry picked from commit bd6d4ed645)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
Add a dedicated subsection for `Path.stat()`-related methods, specifically
`stat()`, `lstat()`, `exists()`, `is_*()`, and `samefile()`.
(cherry picked from commit 81d6336230)
- Explicit list of what it does that is different from
"just return __annotations__"
- Remove reference to PEP 563; adding the future import doesn't
do anything to type aliases, and in general it will never make
get_type_hints() less likely to fail.
- Remove example, as the Annotated docs already have a similar
example, and it's unbalanced to have one example about this
one edge case but not about other behaviors of the function.
(cherry picked from commit aa9fe98e06)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
PEP 667's description of the planned changes to PyEval_GetLocals
was internally inconsistent when accepted, so the docs added for
gh-74929 didn't match either the current behaviour or the intended
behaviour once gh-118934 is fixed.
This PR updates the documentation and 3.13 What's New to match the
intended behaviour (once gh-118934 is fixed).
It also tidies up lingering references to `f_locals` always being a
dictionary (this hasn't been true since at least when custom
namespace support for class statement execution was added)
(cherry picked from commit fd6cd621e0)
Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
* Add docs for new APIs
* Add soft-deprecation notices
* Add What's New porting entries
* Update comments referencing `PyFrame_LocalsToFast()` to mention the proxy instead
* Other related cleanups found when looking for refs to the deprecated APIs
(cherry picked from commit 3859e09e3d)
Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
gh-100117: Fix inaccuracy in documentation of the CodeObject's co_positions field. (GH-119364)
(cherry picked from commit 015b1fdd0a)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
* Remove the equivalence with real+imag*1j which can be incorrect in corner
cases (non-finite numbers, the sign of zeroes).
* Separately document the three roles of the constructor: parsing a string,
converting a number, and constructing a complex from components.
* Document positional-only parameters of complex(), float(), int() and bool()
as positional-only.
* Add examples for complex() and int().
* Specify the grammar of the string for complex().
* Improve the grammar of the string for float().
* Describe more explicitly the behavior when real and/or imag arguments are
complex numbers. (This will be deprecated in future.)
(cherry picked from commit ec1ba26460)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
For example, the free-threaded build now generates
`lib/pkgconfig/python-3.13t.pc` and the debug build generates
`lib/pkgconfig/python-3.13d.pc`.
(cherry picked from commit 1c04c63ced)
Co-authored-by: Sam Gross <colesbury@gmail.com>
gh-118055: Update the finder glossary entry (GH-118278)
(cherry picked from commit db009348b4)
Co-authored-by: Lincoln <71312724+Lincoln-developer@users.noreply.github.com>