Commit Graph

13618 Commits

Author SHA1 Message Date
Ollanta Cuba Gyllensten 15d6506d17
Link to correct class methods in asyncio primitives docs (#127270) 2024-11-29 16:20:40 +00:00
Илья Любавский dd3a87d2a8
gh-127303: Add docs for token.EXACT_TOKEN_TYPES (#127304)
---------

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-11-29 04:00:50 -05:00
Jun Komoda 49fee592a4
Touch up docs for ctypes.FormatError & WinError (GH-127210)
Reformat paragraphs, add backquotes, and directives.
2024-11-28 16:59:47 +01:00
Jelle Zijlstra 9328db7652
Fix indentation for contextlib.asynccontextmanager docs (#127333) 2024-11-27 06:38:55 -08:00
Sergey B Kirpichev 987311d42e
gh-69639: Add mixed-mode rules for complex arithmetic (C-like) (GH-124829)
"Generally, mixed-mode arithmetic combining real and complex variables should
be performed directly, not by first coercing the real to complex, lest the sign
of zero be rendered uninformative; the same goes for combinations of pure
imaginary quantities with complex variables." (c) Kahan, W: Branch cuts for
complex elementary functions.

This patch implements mixed-mode arithmetic rules, combining real and
complex variables as specified by C standards since C99 (in particular,
there is no special version for the true division with real lhs
operand).  Most C compilers implementing C99+ Annex G have only these
special rules (without support for imaginary type, which is going to be
deprecated in C2y).
2024-11-26 17:57:39 +02:00
Jelle Zijlstra dcf629213b
gh-119180: Add VALUE_WITH_FAKE_GLOBALS format to annotationlib (#124415) 2024-11-26 15:40:13 +00:00
Filipe Laíns 🇵🇸 2b0e2b2893
GH-126985: move pyvenv.cfg detection from site to getpath (#126987) 2024-11-26 13:46:33 +00:00
Richard Hansen ab237ff81d
Doc: Typo fix: nrace -> race (#127288) 2024-11-26 15:05:07 +02:00
Barney Gale 5bb059fe60
GH-127236: `pathname2url()`: generate RFC 1738 URL for absolute POSIX path (#127194)
When handed an absolute Windows path such as `C:\foo` or `//server/share`,
the `urllib.request.pathname2url()` function returns a URL with an
authority section, such as `///C:/foo` or `//server/share` (or before
GH-126205, `////server/share`). Only the `file:` prefix is omitted.

But when handed an absolute POSIX path such as `/etc/hosts`, or a Windows
path of the same form (rooted but lacking a drive), the function returns a
URL without an authority section, such as `/etc/hosts`.

This patch corrects the discrepancy by adding a `//` prefix before
drive-less, rooted paths when generating URLs.
2024-11-25 19:59:20 +00:00
Jun Komoda f4f075b3d5
Replace `:platform:` with `.. availability::` in `socket.ioctl` doc. (GH-127122)
In `socket.ioctl`, `:platform:` -> `.. availability::`
2024-11-25 13:53:17 +01:00
Barney Gale 307c633586
Improve `pathname2url()` and `url2pathname()` docs (#127125)
These functions have long sown confusion among Python developers. The
existing documentation says they deal with URL path components, but that
doesn't fit the evidence on Windows:

    >>> pathname2url(r'C:\foo')
    '///C:/foo'
    >>> pathname2url(r'\\server\share')
    '////server/share'  # or '//server/share' as of quite recently

If these were URL path components, they would imply complete URLs like
`file://///C:/foo` and `file://////server/share`. Clearly this isn't right.
Yet the implementation in `nturl2path` is deliberate, and the 
`url2pathname()` function correctly inverts it.

On non-Windows platforms, the behaviour until quite recently is to simply
quote/unquote the path without adding or removing any leading slashes. This
behaviour is compatible with *both* interpretations -- 1) the value is a
URL path component (existing docs), and 2) the value is everything
following `file:` (this commit)

The conclusion I draw is that these functions operate on everything after
the `file:` prefix, which may include an authority section. This is the
only explanation that fits both the  Windows and non-Windows behaviour.
It's also a better match for the function names.
2024-11-24 17:33:46 +00:00
Savannah Ostrowski 2104bde572
GH-127133: Remove ability to nest argument groups & mutually exclusive groups (#127186) 2024-11-24 15:20:37 +00:00
Barney Gale cc813e10ff
GH-125866: Preserve Windows drive letter case in file URIs (#127138)
Stop converting Windows drive letters to uppercase in
`urllib.request.pathname2url()` and `url2pathname()`. This behaviour is
unnecessary and inconsistent with pathlib's file URI implementation.
2024-11-23 10:41:39 +00:00
Savannah Ostrowski a13e94d84b
GH-127134: Add note about forward compatibility for suggest_on_error (#127137) 2024-11-22 19:18:18 -08:00
Rafael Fontenelle 39e60aeb38
Fix a few typos found in the docs (GH-127126) 2024-11-22 16:02:51 -08:00
Serhiy Storchaka a5440d4a38
gh-86463: Fix a trailing space in argparse.rst (#127162) 2024-11-22 16:34:05 +00:00
Serhiy Storchaka 8899e85de1
gh-127001: Fix PATHEXT issues in shutil.which() on Windows (GH-127035)
* Name without a PATHEXT extension is only searched if the mode does not
  include X_OK.
* Support multi-component PATHEXT extensions (e.g. ".foo.bar").
* Support files without extensions in PATHEXT contains dot-only extension
  (".", "..", etc).
* Support PATHEXT extensions that end with a dot (e.g. ".foo.").
2024-11-22 17:52:15 +02:00
Serhiy Storchaka 0cb4d6c654
gh-86463: Fix default prog in subparsers if usage is used in the main parser (GH-125891)
The usage parameter of argparse.ArgumentParser no longer
affects the default value of the prog parameter in subparsers.

Previously the full custom usage of the main parser was used as
the prog prefix in subparsers.
2024-11-22 17:29:33 +02:00
Jun Komoda 3c770e3f09
gh-127082: Replace "Windows only" with the `availability: Windows` in `ctypes` doc (#127099) 2024-11-22 08:56:34 +01:00
Savannah Ostrowski fcfdb55465
GH-122679: Add `register()` to argparse docs (#126939)
* Add register() to argparse docs

* Add newline

* Formatting

* Fix codeblock

* Move section

* Add signature

* Add newline

* Fix indent

* Fix indent take 2

* Rephrase

* Simplify language

* Address PR comments

* Add references to register in type and action

* Remove unnecessary reference

* Rephrase and add success case
2024-11-21 16:36:11 -08:00
Barney Gale fd133d4f21
GH-126601: `pathname2url()`: handle NTFS alternate data streams (#126760)
Adjust `pathname2url()` to encode embedded colon characters in Windows
paths, rather than bailing out with an `OSError`.

Co-authored-by: Steve Dower <steve.dower@microsoft.com>
2024-11-22 00:29:05 +00:00
Serhiy Storchaka 4803cd0244
gh-126727: Fix locale.nl_langinfo(locale.ERA) (GH-126730)
It now returns multiple era description segments separated by semicolons.
Previously it only returned the first segment on platforms with Glibc.
2024-11-21 13:16:08 +02:00
Mark Shannon aea0c586d1
GH-127010: Don't lazily track and untrack dicts (GH-127027) 2024-11-20 16:41:20 +00:00
Jun Komoda 5b4502560b
gh-126615: `ctypes`: Make `COMError` public (GH-126686)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-11-20 12:53:43 +00:00
Hugo van Kemenade add43c3420 Python 3.14.0a2 2024-11-19 16:52:44 +02:00
Barney Gale 4d771977b1
GH-84850: Remove `urllib.request.URLopener` and `FancyURLopener` (#125739) 2024-11-19 16:01:49 +02:00
Serhiy Storchaka f7ef0203d4
gh-123803: Support arbitrary code page encodings on Windows (GH-123804)
If the cpXXX encoding is not directly implemented in Python, fall back
to use the Windows-specific API codecs.code_page_encode() and
codecs.code_page_decode().
2024-11-18 17:45:25 +00:00
Joseph Martinot-Lagarde ce453e6c2f
Doc: Reorganize math module documentation (#126337)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2024-11-18 08:57:32 +01:00
beavailable 0c5c80928c
gh-126896: Fix docs about `asyncio.start_server()` (#126897) 2024-11-17 11:32:35 -08:00
Alex Gaynor d6bcc154e9
Added a warning to the urljoin docs, indicating that it is not safe to use with attacker controlled URLs (GH-126659)
This was flagged to me at a party today by someone who works in red-teaming as a frequently encountered footgun. Documenting the potentially unexpected behavior seemed like a good place to start.
2024-11-15 18:09:05 -05:00
Bénédikt Tran 612ac283b8
gh-122549: Add platform.invalidate_caches() (#122547)
Allow to invalidate platform's cached results.
2024-11-15 13:52:56 +00:00
Petr Viktorin d00f7b1b9d
gh-125063: marshal: Add version 5, improve documentation (GH-126829)
* Document that slices can be marshalled
* Deduplicate and organize the list of supported types
  in docs
* Organize the type code list in marshal.c, to make
  it more obvious that this is a versioned format
* Back-fill some historical info

Co-authored-by: Michael Droettboom <mdboom@gmail.com>
2024-11-15 13:48:57 +01:00
Bénédikt Tran e17486982c
gh-89083: small docs fixup for UUIDv8 (#126857) 2024-11-15 14:26:38 +02:00
Petr Viktorin ff0ef0a54b
gh-123832: Adjust `socket.getaddrinfo` docs for better POSIX compliance (GH-126182)
* gh-123832: Adjust `socket.getaddrinfo` docs for better POSIX compliance

This changes nothing changes for CPython supported platforms,
but hints how to deal with platforms that stick to the letter of
the spec.
It also marks `socket.getaddrinfo` as a wrapper around `getaddrinfo(3)`;
specifically, workarounds to make the function work consistently across
platforms are out of scope in its code.

Include wording similar to the POSIX's “by providing options and by
limiting the returned information”, which IMO suggests that the
hints limit the resulting list compared to the defaults, *but* can
be interpreted differently. Details are added in a note.

Specifically say that this wraps the underlying C function. So, the
details are in OS docs. The “full range of results” bit goes away.

Use `AF_UNSPEC` rather than zero for the *family* default, although
I don't think a system where it's nonzero would be very usable.

Suggest setting proto and/or type (with examples, as the appropriate
values aren't obvious). Say why you probably want to do that that
on all systems; mention the behavior on the “letter of the spec”
systems.

Suggest that the results should be tried in order, which is,
AFAIK best practice -- see RFC 6724 section 2, and its predecessor
from 2003 (which are specific to IP, but indicate how people use this):

> Well-behaved applications SHOULD iterate through the list of
> addresses returned from `getaddrinfo()` until they find a working address.


Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
2024-11-14 09:31:14 +01:00
Wulian 6a93a1adbb
gh-126731: Update outdated project information in `pprint.pp` doc (#126732) 2024-11-13 20:58:06 -08:00
Serhiy Storchaka 35010b8cf2
gh-126390: Support for preserving order of options and nonoption arguments in gnu_getopt() (GH-126393) 2024-11-13 22:50:46 +02:00
Taneli Hukkinen 29b5323c45
gh-126175: Add attributes to TOMLDecodeError. Deprecate free-form `__init__` args (GH-126428) 2024-11-13 13:52:16 +01:00
Serhiy Storchaka 7577307ebd
gh-116897: Deprecate generic false values in urllib.parse.parse_qsl() (GH-116903)
Accepting objects with false values (like 0 and []) except empty strings
and byte-like objects and None in urllib.parse functions parse_qsl() and
parse_qs() is now deprecated.
2024-11-12 21:10:29 +02:00
Bénédikt Tran 03924b5dee
gh-89083: add support for UUID version 8 (RFC 9562) (#123224)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-11-12 19:08:49 +01:00
Sayandip Dutta abb90ba46c
gh-125916: Allow functools.reduce() 'initial' to be a keyword argument (#125917) 2024-11-12 13:11:58 +00:00
Ned Batchelder 036930d844
Docs: re-create pages for removed modules to document their removal. (#126622)
Will also need to change the redirects that were created here:
https://github.com/python/psf-salt/pull/521/files
2024-11-11 17:49:48 -05:00
谭九鼎 6e25eb1541
Update documentation links to Microsoft's documentation pages (GH-126379) 2024-11-11 17:10:49 +00:00
Serhiy Storchaka 25aee21aa8
gh-126374: Add support of options with optional arguments in the getopt module (GH-126375) 2024-11-11 18:29:28 +02:00
Pedro Fonini 434b29767f
gh-126543: Docs: change "bound type var" to "bounded" when used in the context of the 'bound' kw argument to TypeVar (#126584) 2024-11-10 16:40:25 -08:00
RUANG (James Roy) 75ffac296e
gh-125298: Remove misleading text in os.kill documentation (GH-125749)
Windows has not accepted process handles in many releases.
2024-11-08 15:29:16 +00:00
Kamil Turek 9cba47d9f1
gh-122838: Document missing opcodes (#123073) 2024-11-06 12:16:13 +00:00
Barney Gale ff8349979c
GH-124985: Document that `pathlib.Path.copy()` uses copy-on-write. (#125861) 2024-11-05 18:43:43 +00:00
Lukas Geiger 3d4fda2165
gh-119793: Prefer `map(..., strict=True)` over starmap/zip in examples (#126407) 2024-11-05 08:53:32 +01:00
Victor Stinner 4a0d574273
gh-120057: Add os.reload_environ() function (#126268)
Replace the os.environ.refresh() method with a new
os.reload_environ() function.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2024-11-05 08:43:34 +01:00
lit d960226547
gh-125436: Doc: Add missing ``allow_unnamed_section`` parameter to ``ConfigParser`` documentation (#125437)
Add missing ``allow_unnamed_section`` parameter to ``ConfigParser`` doc, as well as to it's parent ``RawConfigParser``.
Split too long line on ``ConfigParser`` signature.
Add some sections about when some of ``RawConfigParser`` parameters were added.
2024-11-05 02:58:15 +00:00