Commit Graph

28289 Commits

Author SHA1 Message Date
chaen 1c13b29d54
gh-120937: Reference weakref from the `__del__` documentation (#120940)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-06-26 23:07:09 +03:00
Hugo van Kemenade ead676516d
Doc/README: Document 'make htmllive' (#120692)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2024-06-25 12:08:55 +03:00
Bénédikt Tran bb057ea107
gh-120661: improve example for basic type hints (#120934) 2024-06-25 07:59:56 +00:00
Barney Gale e4a97a7fb1
GH-119054: Add "Permissions and ownership" section to pathlib docs. (#120505)
Add dedicated subsection for `pathlib.owner()`, `group()`, `chmod()` and
`lchmod()`.

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-06-24 19:05:24 +00:00
Sam Gross 375b723d58
gh-120858: PyDict_Next should not lock the dict (#120859)
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.
2024-06-24 14:15:15 -04:00
Victor Stinner 2e157851e3
gh-119182: Add PyUnicodeWriter_WriteUCS4() function (#120849) 2024-06-24 17:40:39 +02:00
Christian Clauss 22b8a35d6e
docs: puremagic.what() as replacement for imghdr.what() (#120871) 2024-06-24 15:32:13 +02:00
Pablo Galindo Salgado ac61d58db0
gh-119521: Rename IncompleteInputError to _IncompleteInputError and remove from public API/ABI (GH-119680)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2024-06-24 14:08:12 +02:00
Alek Kowalczyk fc297b4ba4
gh-112169: Documented getaddrinfo/getnameinfo default loop executor usage and implications. (#112191)
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
2024-06-24 08:35:02 +00:00
Barney Gale 35e998f560
GH-73991: Add `pathlib.Path.copytree()` (#120718)
Add `pathlib.Path.copytree()` method, which recursively copies one
directory to another.

This differs from `shutil.copytree()` in the following respects:

1. Our method has a *follow_symlinks* argument, whereas shutil's has a
   *symlinks* argument with an inverted meaning.
2. Our method lacks something like a *copy_function* argument. It always
   uses `Path.copy()` to copy files.
3. Our method lacks something like a *ignore_dangling_symlinks* argument.
   Instead, users can filter out danging symlinks with *ignore*, or
   ignore exceptions with *on_error*
4. Our *ignore* argument is a callable that accepts a single path object,
   whereas shutil's accepts a path and a list of child filenames.
5. We add an *on_error* argument, which is a callable that accepts
   an `OSError` instance. (`Path.walk()` also accepts such a callable).

Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
2024-06-23 22:01:12 +01:00
Hugo van Kemenade bc37ac7b44
Docs makefile/RTD: Use uv if installed (#120711) 2024-06-23 13:23:27 -06:00
Nyakku Shigure 0b918e81c1
Typing docs: normalize some indents in code examples (#120912) 2024-06-23 16:15:12 +00:00
Kumar Aditya 18b6ca9660
GH-120804: add docs for removal for asyncio child watchers (#120895)
Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
2024-06-23 13:14:12 +00:00
Nice Zombies b6fa8fe86a
gh-120896: Fix typo in version changed note of `urllib.parse.urlparse()` (#120898) 2024-06-23 18:00:23 +05:30
Sam Gross 8f17d69b7b
gh-119344: Make critical section API public (#119353)
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.
2024-06-21 15:50:18 -04:00
Eric Snow 03fa2df927
gh-120838: Add a Note in the Docs About Expectations for Py_Finalize() (gh-120839) 2024-06-21 13:05:53 -06:00
Nice Zombies 462832041e
gh-119003: Clarify slice assignments (#119935) 2024-06-21 11:30:50 -07:00
Victor Stinner 4123226bbd
gh-119182: Add PyUnicodeWriter_DecodeUTF8Stateful() (#120639)
Add PyUnicodeWriter_WriteWideChar() and
PyUnicodeWriter_DecodeUTF8Stateful() functions.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-06-21 19:33:15 +02:00
blhsing 83d3d7aace
gh-120773: document introspective attributes of an async generator object in the inspect module (#120778) 2024-06-21 10:55:36 +00:00
Serhiy Storchaka a2f6f7dd26
gh-111259: Document idiomatic RE pattern (?s:.) that matches any character (GH-120745) 2024-06-21 00:03:49 +03:00
Sam Gross 3af7263037
gh-117511: Make PyMutex public in the non-limited API (#117731) 2024-06-20 11:29:08 -04:00
Bénédikt Tran b8a8e04fec
gh-119698: fix `symtable.Class.get_methods` and document its behaviour correctly (#120151)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-06-19 20:49:30 -07:00
Nice Zombies ed5ae6c4d7
gh-118820: Zero-valued flag enum has no name (GH-118848)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-06-19 13:09:53 -07:00
Kirill Podoprigora 753ef8db97
Regen ``Doc/requirements-oldest-sphinx.txt`` (#120753) 2024-06-19 19:21:12 +00:00
Danny Yang 58b3f11176
gh-120521: clarify except* documentation to allow tuples (#120523)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2024-06-19 18:49:00 +00:00
Mark Shannon 00257c746c
GH-119462: Enforce invariants of type versioning (GH-120731)
* Remove uses of Py_TPFLAGS_VALID_VERSION_TAG
2024-06-19 17:38:45 +01:00
Awbert a86e6255c3
gh-119960: Add information about regex flags in re module functions (#119978) 2024-06-19 09:42:01 +00:00
Petr Viktorin 45d5cab533
Add a link to free-threading HOWTO to the index (follow-up to GH-119366) (GH-120703) 2024-06-19 09:17:26 +02:00
Barney Gale 20d5b84f57
GH-73991: Add follow_symlinks argument to `pathlib.Path.copy()` (#120519)
Add support for not following symlinks in `pathlib.Path.copy()`.

On Windows we add the `COPY_FILE_COPY_SYMLINK` flag is following symlinks is disabled. If the source is symlink to a directory, this call will fail with `ERROR_ACCESS_DENIED`. In this case we add `COPY_FILE_DIRECTORY` to the flags and retry. This can fail on old Windowses, which we note in the docs.

No news as `copy()` was only just added.
2024-06-19 00:59:54 +00:00
Donghee Na 7e189aed64
gh-120496: Add a note about iterator thread-safe (gh-120685) 2024-06-18 15:37:34 +00:00
Victor Stinner 16f8e22e7c
gh-120600: Make Py_TYPE() opaque in limited C API 3.14 (#120601)
In the limited C API 3.14 and newer, Py_TYPE() is now implemented as
an opaque function call to hide implementation details.
2024-06-18 14:28:48 +00:00
Sam Gross e8752d7b80
gh-118789: Add `PyUnstable_Object_ClearWeakRefsNoCallbacks` (#118807)
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.

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2024-06-18 09:57:23 -04:00
Sam Gross 02b272b702
gh-119241: Add HOWTO for free-threaded C API extensions (#119877)
Some sections adapted from https://github.com/Quansight-Labs/free-threaded-compatibility/
written by Nathan Goldbaum.

Co-authored-by: Nathan Goldbaum <nathan.goldbaum@gmail.com>
2024-06-18 09:49:51 -04:00
Jan Kaliszewski dacc5ac71a
gh-120381: Fix inspect.ismethoddescriptor() (#120383)
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.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
2024-06-18 12:19:43 +00:00
Bénédikt Tran 4bc27abdbe
gh-120662: Improve `smtplib` example (#120668)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-06-18 13:56:58 +02:00
Mark Shannon 9cefcc0ee7
GH-120507: Lower the `BEFORE_WITH` and `BEFORE_ASYNC_WITH` instructions. (#120640)
* Remove BEFORE_WITH and BEFORE_ASYNC_WITH instructions.

* Add LOAD_SPECIAL instruction

* Reimplement `with` and `async with` statements using LOAD_SPECIAL
2024-06-18 12:17:46 +01:00
Saul Pwanson 0506f75c53
fix enum doc typo (#120091) 2024-06-17 21:31:15 +05:30
Victor Stinner 5c4235cd8c
gh-119182: Add PyUnicodeWriter C API (#119184) 2024-06-17 17:10:52 +02:00
Carol Willing a26d27e7ee
Update the documentation howto index page and group docs into 3 logical sections (GH-119366)
Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>
2024-06-17 16:37:33 +02:00
Bénédikt Tran 4bf17c381f
gh-119933: Improve ``SyntaxError`` message for invalid type parameters expressions (#119976)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-06-17 06:51:03 -07:00
Frank Dana 79e09e60d8
itertools doc: examples for groupby() and tee() (#120618) 2024-06-17 08:19:14 -05:00
Gregory P. Smith bac4edad69
gh-112346: Document the OS byte in `gzip.compress` output change in 3.11 (#120480)
gh-112346: Describe the "os" byte in gzip output change.
2024-06-16 22:47:10 -07:00
mm-matthias 4f59f86382
gh-118596: Add thread-safety clarifications to the SSLContext documentation (#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.
2024-06-16 13:27:44 -07:00
Hugo van Kemenade b8484c6ad7
Docs: remove temporary hardcoded links (#120348) 2024-06-16 06:51:17 -06:00
Nyuan Zhang 1fa595963e
gh-120572: add missing parentheses in TypeIs documentation (#120573) 2024-06-15 22:36:10 -07:00
Ruben Vorderman 08d09cf5ba
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.
2024-06-15 18:46:39 +00:00
Jelle Zijlstra 9e0b11eb21
annotations: expand documentation on "simple" assignment targets (#120535)
This behavior is rather surprising and it was not clearly specified.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-06-15 15:18:16 +00:00
Tian Gao ed60ab5fab
gh-119824: Print stack entry when user input is needed (#119882)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2024-06-14 11:25:23 -07:00
Nikita Sobolev 7fadfd82eb
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`
2024-06-14 10:25:35 -07:00
Barney Gale 7c38097add
GH-73991: Add `pathlib.Path.copy()` (#119058)
Add a `Path.copy()` method that copies the content of one file to another.

This method is similar to `shutil.copyfile()` but differs in the following ways:

- Uses `fcntl.FICLONE` where available (see GH-81338)
- Uses `os.copy_file_range` where available (see GH-81340)
- Uses `_winapi.CopyFile2` where available, even though this copies more metadata than the other implementations. This makes `WindowsPath.copy()` more similar to `shutil.copy2()`.

The method is presently _less_ specified than the `shutil` functions to allow OS-specific optimizations that might copy more or less metadata.

Incorporates code from GH-81338 and GH-93152.

Co-authored-by: Eryk Sun <eryksun@gmail.com>
2024-06-14 17:15:49 +01:00