Commit Graph

28833 Commits

Author SHA1 Message Date
Serhiy Storchaka da8673da36
gh-84545: Clarify the 'extend' action documentation in argparse (GH-125870) 2024-10-25 08:41:38 +00:00
Kerim Kabirov 1306f33c84
gh-125933: Add ARIA labels to select elements in the version switcher (#125934)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-10-24 23:52:21 +03:00
Shantanu 500f5338a8
gh-123930: Better error for "from imports" when script shadows module (#123929) 2024-10-24 12:11:12 -07:00
partev 5003ad5c5e
gh-125909: Avoid a redirect when linking to the devguide (#125826) 2024-10-24 17:41:01 +01:00
Wulian 9c01db40aa
gh-125665: Update turtledemo docstrings with correct file names (#125691)
Co-authored-by: Wulian <xiguawulian@gmail.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2024-10-23 16:29:32 -04:00
Eric Snow 6f26d496d3
gh-125286: Share the Main Refchain With Legacy Interpreters (gh-125709)
They used to be shared, before 3.12.  Returning to sharing them resolves a failure on Py_TRACE_REFS builds.

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2024-10-23 10:10:06 -06:00
Serhiy Storchaka 834ba5aaf2
gh-58032: Deprecate the argparse.FileType type converter (GH-124664) 2024-10-23 10:50:29 +03:00
Jacob Walls c75ff2ef8e
gh-80958: unittest: discovery support for namespace packages as start directory (#123820) 2024-10-23 13:41:33 +09:00
Adam Turner 91ddde4af0
Doc: Show object descriptions in the table of contents (#125757) 2024-10-22 14:07:09 +01:00
Serhiy Storchaka dcc4fb2c90
gh-124969: Make locale.nl_langinfo(locale.ALT_DIGITS) returning a string again (GH-125774)
This is a follow up of GH-124974. Only Glibc needed a fix.
Now the returned value is a string consisting of semicolon-separated
symbols on all Posix platforms.
2024-10-21 18:54:12 +00:00
Serhiy Storchaka 5ca4e34bc1
gh-125767: Fix pickling and copying of super objects (GH-125781)
Previously, copying a super object returned a copy of the instance
invoking super(). Pickling a super object could pickle the instance
invoking super() or fail, depending on its type and protocol.

Now deep copying returns a new super object and pickling pickles the super
object. Shallow copying returns the same super object.
2024-10-21 21:30:45 +03:00
Richard Hansen d880c83ff7
Doc: C API: Move `tp_dealloc` paragraph to `tp_dealloc` section (#125737)
It looks like commit 43cf44ddcc
(gh-31501) accidentally moved the paragraph to the `tp_finalize`
section when the intent was to move it to the `tp_dealloc` section
(according to the commit message).

Also:
  * Convert the paragraph to a warning.
  * Apply the appropriate font style to `tp_dealloc`.
  * Unlinkify the first mention of `tp_dealloc` since the paragraph is
    already in the `tp_dealloc` section.
2024-10-21 09:46:37 -07:00
partev d67bf2d89a
gh-125766: Docs: minor rewording of installation on Linux section (GH-125743) 2024-10-21 16:18:10 +00:00
Y5 7d88140d52
gh-125313: Prefer `sys.base_*` paths in `Py_Get(Exec)Prefix` deprecation notes (#125317)
Prefer `sys.base_*` paths in `Py_Get(Exec)Prefix` deprecation notes.

Signed-off-by: y5c4l3 <y5c4l3@proton.me>
2024-10-21 11:35:54 +02:00
ember91 ded105a62b
Doc: Fix typos (#125728) 2024-10-21 10:44:18 +02:00
RUANG (Roy James) 9256be7ff0
gh-99030: Added documentation links for types and exceptions (GH-123857)
* Added documentation links for types and exceptions

* Shortened description sentences

* Change content

* Change documentation

* Move seealso

* Add a spaces
2024-10-20 17:36:27 -07:00
Tom Most 14cafe1a10
Doc: Fix pluralization in os.process_cpu_count() documentation (#125678) 2024-10-20 01:48:06 +01:00
Savannah Ostrowski 84074a4fd8
GH-99749: Add What's New entry for GH-124456 (GH-125671) 2024-10-19 11:26:46 +03:00
Adam Turner 2bb7ab7ad3
GH-125277: Increase minimum supported Sphinx to 7.2.6 (#125368) 2024-10-19 04:59:22 +01:00
Sam Gross d8c8648161
gh-125541: Make Ctrl-C interrupt `threading.Lock.acquire()` on Windows (#125546) 2024-10-17 20:10:55 +02:00
chrysn b454662921
gh-118986: expose `socket.IPV6_RECVERR` (#118987) 2024-10-17 20:49:12 +03:00
Savannah Ostrowski dbcc5ac470
gh-95836: Add custom type converter examples to argparse tutorial (GH-125376) 2024-10-17 14:41:22 +03:00
Savannah Ostrowski 7b04496e5c
gh-125542: Deprecate prefix_chars in ArgumentParser.add_argument_group() (GH-125563) 2024-10-17 09:11:47 +00:00
Savannah Ostrowski 624be8699a
GH-99749: Add optional feature to suggest correct names (ArgumentParser) (GH-124456) 2024-10-17 10:07:37 +03:00
Eric Snow a5a7f5e16d
gh-124694: Add concurrent.futures.InterpreterPoolExecutor (gh-124548)
This is an implementation of InterpreterPoolExecutor that builds on ThreadPoolExecutor.

(Note that this is not tied to PEP 734, which is strictly about adding a new stdlib module.)

Possible future improvements:

* support passing a script for the initializer or to submit()
* support passing (most) arbitrary functions without pickling
* support passing closures
* optionally exec functions against __main__ instead of the their original module
2024-10-16 16:50:46 -06:00
Cornelius Roemer aab3210271
gh-125615: Fix grammar nit in tutorial's interactive interpreter appendix (GH-125617)
Replace "without ... nor" with "with neither ... nor"
2024-10-16 15:53:30 -05:00
Kirill Podoprigora bee112a94d
gh-124872: Replace enter/exit events with "switched" (#125532)
Users want to know when the current context switches to a different
context object.  Right now this happens when and only when a context
is entered or exited, so the enter and exit events are synonymous with
"switched".  However, if the changes proposed for gh-99633 are
implemented, the current context will also switch for reasons other
than context enter or exit.  Since users actually care about context
switches and not enter or exit, replace the enter and exit events with
a single switched event.

The former exit event was emitted just before exiting the context.
The new switched event is emitted after the context is exited to match
the semantics users expect of an event with a past-tense name.  If
users need the ability to clean up before the switch takes effect,
another event type can be added in the future.  It is not added here
because YAGNI.

I skipped 0 in the enum as a matter of practice.  Skipping 0 makes it
easier to troubleshoot when code forgets to set zeroed memory, and it
aligns with best practices for other tools (e.g.,
https://protobuf.dev/programming-guides/dos-donts/#unspecified-enum).

Co-authored-by: Richard Hansen <rhansen@rhansen.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
2024-10-16 13:53:21 +02:00
Hugo van Kemenade 8cdaca8b25 Python 3.14.0a1 2024-10-15 22:34:54 +03:00
Savannah Ostrowski c9826c11db
gh-89819: Add argument_default and conflict_handler to add_argument_group() docs (GH-125379) 2024-10-15 15:48:28 +00:00
Kirill Podoprigora d3c82b9cce
gh-125512: Revert "gh-124872: Replace enter/exit events with "switched" (#124776)" (#125513) 2024-10-15 17:42:16 +03:00
sobolevn c8a1818fb0
gh-125517: Fix unreachable code warnings in `_testembed.c` (#125518) 2024-10-15 13:12:32 +00:00
RUANG (Roy James) 546dddca43
gh-125234: Make PyInitConfig_Free(NULL) a no-op (#125266) 2024-10-15 09:21:16 +00:00
Hugo van Kemenade 66064c342c
gh-123299: Copyedit "What's New in Python 3.14" (#125438) 2024-10-15 10:39:15 +03:00
Mariusz Felisiak a2fe9ff11d
Doc: Update CVE URL (#125489) 2024-10-15 10:29:08 +03:00
edson duarte 2a5cdb2516
gh-85453: Improve variable mark up for datetime.rst (#120702)
Variables and literals are marked up using backticks.
2024-10-15 00:02:58 +02:00
Richard Hansen 843d28f59d
gh-124872: Replace enter/exit events with "switched" (#124776)
Users want to know when the current context switches to a different
context object.  Right now this happens when and only when a context
is entered or exited, so the enter and exit events are synonymous with
"switched".  However, if the changes proposed for gh-99633 are
implemented, the current context will also switch for reasons other
than context enter or exit.  Since users actually care about context
switches and not enter or exit, replace the enter and exit events with
a single switched event.

The former exit event was emitted just before exiting the context.
The new switched event is emitted after the context is exited to match
the semantics users expect of an event with a past-tense name.  If
users need the ability to clean up before the switch takes effect,
another event type can be added in the future.  It is not added here
because YAGNI.

I skipped 0 in the enum as a matter of practice.  Skipping 0 makes it
easier to troubleshoot when code forgets to set zeroed memory, and it
aligns with best practices for other tools (e.g.,
https://protobuf.dev/programming-guides/dos-donts/#unspecified-enum).
2024-10-14 12:28:41 -07:00
Paul Hoffman 5dac0dceda
gh-125461: Remove Python 2 from identifiers in doc (GH-125462)
Remove Python 2 from identifiers in doc
2024-10-14 15:26:57 +00:00
Mikhail Efimov 45df264f3f
gh-112088: aclocal version is updated to 1.16.5 in docs (#125457) 2024-10-14 16:53:08 +02:00
Serhiy Storchaka 5217328f93
gh-121798: Add class method Decimal.from_number() (GH-121801)
It is an alternate constructor which only accepts a single numeric argument.
Unlike to Decimal.from_float() it accepts also Decimal.
Unlike to the standard constructor, it does not accept strings and tuples.
2024-10-14 08:24:01 +00:00
Serhiy Storchaka b52c7306ea
gh-121797: Add class method Fraction.from_number() (GH-121800)
It is an alternative constructor which only accepts a single numeric argument.
Unlike to Fraction.from_float() and Fraction.from_decimal() it accepts any
real numbers supported by the standard constructor (int, float, Decimal,
Rational numbers, objects with as_integer_ratio()).
Unlike to the standard constructor, it does not accept strings.
2024-10-14 07:54:59 +00:00
Sergey B Kirpichev cfc27bc50f
gh-123133: clarify p=0 case for "f" and "e" formatting types (GH-125426)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-10-13 21:44:48 -07:00
Sergey B Kirpichev c6d7b644c2
gh-101291: Add versionadded directives for PyUnstable_Long_* (#125384) 2024-10-13 19:38:42 +02:00
partev 6c386b703d
gh-125403: fix console formatting in Chapter 12 of the tutorial (#125404) 2024-10-13 22:16:15 +05:30
Wulian 283ea5f3b2
gh-125383: Update `fib` function comment for accuracy (#125386)
`Doc/tutorial/controlflow.rst`: fix comment for `fib` function
2024-10-13 14:10:59 +03:00
Ruoyu Zhong a8fa4ad9e9
Doc: Fix suggested usage of `-X gil=0` in the glossary (#125366)
Currently, the "global interpreter lock" entry in the glossary mentions
that `-X gil 0` can be used to disable the GIL [1]. However, this is
invalid; the correct usage should be `-X gil=0`.

    $ python -X gil 0 -c 'print("Hello, world")'
    Fatal Python error: config_read_gil: PYTHON_GIL / -X gil must be "0" or "1"
    Python runtime state: preinitialized

    $ python -X gil=0 -c 'print("Hello, world")'
    Hello, world

[1]: https://docs.python.org/3/using/cmdline.html#cmdoption-X

Signed-off-by: Ruoyu Zhong <zhongruoyu@outlook.com>
2024-10-13 01:53:28 +01:00
Richard Hansen 330c527299
gh-124872: Change PyContext_WatchCallback to take PyObject (#124737)
The PyContext struct is not intended to be public, and users of the
API don't need anything more specific than PyObject.  Also see
gh-78943.
2024-10-12 13:57:27 -07:00
Ghorban M. Tavakoly fa52b82c91
gh-125289: Update sample code in asyncio-task.rst (GH-125292)
* Update sample code in asyncio-task.rst

This will change **coroutines** sample code in the **Awaitables** section and make the example clearer.

* Update Doc/library/asyncio-task.rst

Revert the added print

Co-authored-by: Carol Willing <carolcode@willingconsulting.com>

* Update Doc/library/asyncio-task.rst

Co-authored-by: Carol Willing <carolcode@willingconsulting.com>

---------

Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
2024-10-12 13:38:13 -07:00
Stephen Rosen 4a2282b067
Prefer "similar" over "equivalent" in tutorial (#125343)
In the datastructures tutorial doc, some operations are described as
"equivalent to" others. This has led to some user-confusion -- at
least in the Discourse forums -- about cases in which the operations
differ.

This change doesn't systematically eliminate the word "equivalent"
from the tutorial. It just substitutes "similar to" in several cases
in which "equivalent to" could mislead users into expecting exact
equivalence.
2024-10-12 16:21:55 -04:00
Bernhard M. Wiedemann dcd58c5084
gh-125260: Change the default ``gzip.compress()`` mtime to 0 (#125261)
This follows GNU gzip, which defaults to using 0 as the mtime
for compressing stdin, where no file mtime is involved.

This makes the output of gzip.compress() deterministic by default,
greatly helping reproducible builds.

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2024-10-12 18:18:48 +01:00
Serhiy Storchaka 07c2d15977
gh-85935: Explicitly document the case nargs=0 in argparse (GH-125302) 2024-10-12 11:53:00 +00:00
Serhiy Storchaka a6c0c64de0
gh-59330: Improve error message for dest= for positionals (GH-125215)
Also improve the documentation. Specify how dest and metavar are derived
from add_argument() positional arguments.

Co-authored-by: Simon Law <sfllaw@sfllaw.ca>
2024-10-12 14:46:28 +03:00
Rafael Fontenelle 5a074aab84
Doc: Fix a typo in "Function Examples" in the control-flow tutorial (#125338) 2024-10-12 01:40:33 +01:00
Victorien 21ac0a7f4c
gh-116938: Clarify documentation of `dict` and `dict.update` regarding the positional argument they accept (#125213)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-10-11 23:05:13 +00:00
Rafael Fontenelle 76b29d271b
Fix typo in ``Doclibrary/functions.rst`` (#125327) 2024-10-11 23:00:31 +03:00
Jan Kaliszewski 0135848059
gh-125058: update `_thread` docs regarding interruptibility of `lock.acquire()` (#125141) 2024-10-11 13:45:46 +05:30
Savannah Ostrowski c1913effee
gh-125296: Fix strange fragment identifier for `name or flags` in argparse docs (#125297) 2024-10-11 09:30:27 +03:00
Alex Waygood a726ce73ca
Add some doctest cleanups for `turtle` and `configparser` (#125288)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2024-10-10 23:53:45 +00:00
Adam Turner dd0ee201da
Doc: Upgrade Sphinx to 8.1 (#125276) 2024-10-10 21:26:01 +01:00
Justin Kunimune 3b87fb74c9
Note argparse exit code in documentation (GH-119568)
Co-authored-by: Savannah Ostrowski <savannahostrowski@gmail.com>
2024-10-10 20:56:05 +03:00
Irit Katriel f9ae5d1cee
gh-71784: [doc] add usage examples for traceback.TracebackException (#125189)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-10-10 11:21:12 +01:00
Richard Hansen 99400930ac
gh-124872: Refine contextvars documentation (#124773)
* Add definitions for "context", "current context", and "context
    management protocol".
  * Update related definitions to be consistent with the new
    definitions.
  * Restructure the documentation for the `contextvars.Context` class
    to prepare for adding context manager support, and for consistency
    with the definitions.
  * Use `testcode` and `testoutput` to test the `Context.run` example.
  * Expand the documentation for the `Py_CONTEXT_EVENT_ENTER` and
    `Py_CONTEXT_EVENT_EXIT` events to clarify and to prepare for
    planned changes.
2024-10-09 16:44:03 -07:00
Victor Stinner 1b2a5485f9
gh-125196: PyUnicodeWriter_Discard(NULL) does nothing (#125222) 2024-10-09 23:32:02 +00:00
Adam Turner cbfd392479
GH-121970: Extract ``availability`` into a new extension (#125082) 2024-10-09 21:50:03 +01:00
Victor Stinner b9a8ca0a6a
gh-115754: Use Py_GetConstant(Py_CONSTANT_EMPTY_STR) (#125194)
Replace PyUnicode_New(0, 0), PyUnicode_FromString("")
and PyUnicode_FromStringAndSize("", 0)
with Py_GetConstant(Py_CONSTANT_EMPTY_STR).
2024-10-09 17:15:23 +02:00
Hugo van Kemenade a5716a3091
gh-101100: Fix Sphinx warnings in `library/unittest.mock.rst` (#124106) 2024-10-09 17:02:18 +03:00
JamesMcCarthy21 e0835aff2e
gh-125168: Fix typo in `__future__.rst` (#125183)
* Update `__future__.rst`

Fixed typo in the sentence :pep:`649`: *Deferred evaluation of annotations using descriptors* - James McCarthy

* Update `__future__.rst`

Fixed sphinx formatting
2024-10-09 16:17:18 +03:00
Alex Waygood 3024b16d51
gh-101100: Consolidate documentation on `ModuleType` attributes (#124709)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Barry Warsaw <barry@python.org>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-10-09 10:53:57 +00:00
Alyssa Coghlan 7a303fc78a
Fix importlib.resources issue reference in 3.13 What's New (#125175)
Previous link was to the PR that removed the
mentioned importlib.resources APIs, rather than
the issue that added back their improved forms.
2024-10-09 20:40:50 +10:00
Serhiy Storchaka 21c04e1a97
gh-124969: Fix locale.nl_langinfo(locale.ALT_DIGITS) (GH-124974)
Now it returns a tuple of up to 100 strings (an empty tuple on most locales).
Previously it returned the first item of that tuple or an empty string.
2024-10-09 11:42:08 +03:00
musvaage 7f93dbf6fe
docs: in venv table use executable name (GH-124315)
Co-authored-by: musvaage <musvaage@users.noreply.github.com>
2024-10-09 09:04:35 +01:00
Jelle Zijlstra 78406382c9
gh-101552: Allow pydoc to display signatures in source format (#124669)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-10-09 05:03:53 +00:00
Savannah Ostrowski 37228bd16e
GH-124478: Cleanup argparse documentation (#124877)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Tomas R <tomas.roun8@gmail.com>
2024-10-08 15:07:29 -07:00
Raymond Hettinger b2a7272408
Misc improvements to the itertools docs (gh-125147) 2024-10-08 14:02:58 -05:00
spacemanspiff2007 760b1e103a
gh-124832: Add a note to indicate that `datetime.now` may return the same instant (#124834)
* Update datetime.rst

* Update datetime.rst

replace warning with note

* Update Doc/library/datetime.rst

Co-authored-by: Victor Stinner <vstinner@python.org>

* Update Doc/library/datetime.rst

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

---------

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-10-08 11:17:53 -07:00
monkeyman192 5967dd8a4d
gh-112433 add versionadded for `ctypes.Structure._align_` (#125087)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2024-10-08 12:41:46 +00:00
Kirill Podoprigora e8773e59a8
Doc: Improve description of ``GET_LEN`` opcode (#114583) 2024-10-08 17:55:40 +05:30
Jan Kaliszewski 9047146e54
gh-75898: make use of thread more explicit in the "Socket Programming HOWTO" document (#125023) 2024-10-08 17:43:37 +05:30
Alyssa Coghlan 7c4b6a68f2
bpo-34206: Improve docs and test coverage for pre-init functions (#8023)
- move the Py_Main documentation from the very high level API section
  to the initialization and finalization section
- make it clear that it encapsulates a full Py_Initialize/Finalize
  cycle of its own
- point out that exactly which settings will be read and applied
  correctly when Py_Main is called after a separate runtime
  initialization call is version dependent
- be explicit that Py_IsInitialized can be called prior to
  initialization
- actually test that Py_IsInitialized can be called prior to
  initialization
- flush stdout in the embedding tests that run code so it appears
  in the expected order when running with "-vv"
- make "-vv" on the subinterpreter embedding tests less spammy

---------

Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
2024-10-08 08:34:11 +00:00
Serhiy Storchaka 93b9e6bd7d
gh-69998: Fix decoding error in locale.nl_langinfo() (GH-124963)
The function now sets temporarily the LC_CTYPE locale to the locale
of the category that determines the requested value if the locales are
different and the resulting string is non-ASCII.
This temporary change affects other threads.
2024-10-08 11:27:49 +03:00
Alyssa Coghlan 27390990fa
gh-70870: Clarify dual usage of 'free variable' (#122545)
The term "free variable" has unfortunately become genuinely
ambiguous over the years (presumably due to the names of
some relevant code object instance attributes).

While we can't eliminate that ambiguity at this late date, we can
at least alert people to the potential ambiguity by describing
both the formal meaning of the term and the common
alternative use as a direct synonym for "closure variable".

---------

Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
2024-10-08 07:52:12 +00:00
Ned Batchelder 6e3c70c61b
Docs: make a tutorial example more precise (#125066)
Based on discussion here:

https://discuss.python.org/t/omission-in-the-documentation/66816
2024-10-07 19:41:13 -04:00
Emily Morehouse 447a15190d
gh-125072: Add label for assignment expressions; update tracked section for assignment expression topic (#125074) 2024-10-07 22:51:14 +00:00
Victor Stinner a7f0727ca5
gh-124502: Add PyUnicode_Equal() function (#124504) 2024-10-07 21:24:53 +00:00
Bénédikt Tran 7ffe94fb24
gh-124653: Relax (again) detection of queue API for logging handlers (GH-124897) 2024-10-07 19:42:19 +01:00
ffelixg 3287c834e5
gh-124182: Explain naming rules for struct sequence types (#124335) 2024-10-07 19:52:34 +02:00
Adam Turner 10094a533a
gh-125018: Fix role syntax (#125050) 2024-10-07 17:51:53 +01:00
Alyssa Coghlan cda3b5a576
gh-125018: Add importlib.metadata semantic link targets (#125027)
This allows direct intersphinx references to APIs via references
like `` :func:`importlib.metadata.version` ``.

---------

Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2024-10-07 23:44:18 +10:00
Sergey B Kirpichev 7487db4c7a
gh-121249: Support _Complex types in the struct module (#121613)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2024-10-07 13:53:02 +02:00
Adam Turner 31516c98dd
GH-109975: Announce final release in What's New in Python 3.13 (#125007)
Prepare What's New in Python 3.13 for final release
2024-10-06 21:43:03 -07:00
Jan Kaliszewski 1e098dc766
gh-125025: `_thread` docs: fix/update the *caveats* list (GH-125026) 2024-10-06 15:57:03 -07:00
Andrés Delfino feca4cf64e
Doc: Simplify the definition of 'soft deprecated' (#124988)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
2024-10-06 22:22:19 +00:00
Nice Zombies bd393aedb8
Fix console prompt syntax in What's New in Python 3.8 (#124968) 2024-10-04 12:33:54 +01:00
Christian Clauss ac9648243d
gh-109975: Suggest ``pynntp`` instead of ``nntplib`` (#124830)
The ``nntplib`` library has been deleted from PyPI by its author.
2024-10-04 11:21:03 +01:00
Adam Turner c8db0e817e
GH-109975: Copyedit 3.13 What's New: Remove references to the incremental GC (#124947) 2024-10-03 21:06:29 +01:00
Raymond Hettinger 7ecaf21946
Simplify partial() rough equivalent code (gh-124941) 2024-10-03 19:54:53 +00:00
Donghee Na 9eeb21bf76
gh-115145: Update documentation about ``PyThreadState_DeleteCurrent`` (gh-124920) 2024-10-03 19:34:47 +09:00
Jeremy Maitin-Shepard 8cc5aa47ee
gh-87135: Hang non-main threads that attempt to acquire the GIL during finalization (GH-105805)
Instead of surprise crashes and memory corruption, we now hang threads that attempt to re-enter the Python interpreter after Python runtime finalization has started. These are typically daemon threads (our long standing mis-feature) but could also be threads spawned by extension modules that then try to call into Python. This marks the `PyThread_exit_thread` public C API as deprecated as there is no plausible safe way to accomplish that on any supported platform in the face of things like C++ code with finalizers anywhere on a thread's stack. Doing this was the least bad option.

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2024-10-02 09:17:49 -07:00
Serhiy Storchaka 04bfea2d26
gh-66436: Improved prog default value for argparse.ArgumentParser (GH-124799)
It can now have one of three forms:

* basename(argv0) -- for simple scripts
* python arv0 -- for directories, ZIP files, etc
* python -m module -- for imported modules

Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
2024-10-01 22:51:40 +03:00
Gregory P. Smith d150e4abcf
Highlight `datetime.timedelta.seconds` vs `.total_seconds()` in docs. (GH-124811)
Thanks to the reviewers for suggesting the use of a "caution" section instead of "warning" or "note".
2024-10-01 18:10:13 +00:00
Tian Gao 5e0abb4788
gh-116750: Add clear_tool_id function to unregister events and callbacks (#124568) 2024-10-01 13:32:55 -04:00
Wulian da1e5526ae
gh-124487: Updated installer messages and internal docs regarding minimum Windows version (GH-124822) 2024-10-01 15:44:18 +01:00
Victorien 3e3a4d2315
gh-118974: Add `decorator` argument to `make_dataclass` (gh-122723)
This is to allow the `dataclasses.make_dataclass` infrastructure to be used with another decorator that's compliant with `typing.dataclass_transform`. The new `decorator` argument to `dataclasses.make_dataclass` is `dataclasses.dataclass`, which used to be hard coded.
2024-10-01 09:51:51 -04:00
Adam Turner 91e64be731
Doc: Fix archive filenames for standard builds (#124826) 2024-10-01 10:43:55 +01:00
Adam Turner 4129a74a37
GH-109975: Copyedit 3.13 What's New: Link to installing free-threaded binaries on macOS (#124831) 2024-10-01 08:27:59 +00:00
Adam Turner 8823690264
GH-109975: Copyedit 3.13 What's New: Note delayed expected release date for Python 3.13.0 (GH-124827)
Note delayed expected release date of 3.13.0
2024-10-01 07:18:59 +00:00
Adam Turner cce1125574
Doc: Run HTML and non-HTML daily builds separately (#124493) 2024-09-30 17:48:12 +01:00
Tian Gao b5774603a0
gh-124400: Use the normal command path for breakpoint commands (#124401)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2024-09-29 19:46:16 -04:00
Ned Deily 4b83c03ce9
gh-124720: Update "Using Python on a Mac" document (#124721)
Update "Using Python on a Mac" section of the "Python Setup and Usage"
document and include information on installing free-threading support.
2024-09-30 07:39:46 +08:00
CBerJun 76fbee642e
Docs: improve generic `typing.NamedTuple` example (#124739) 2024-09-29 12:07:05 +01:00
Serhiy Storchaka f1a2417b9e
gh-61181: Fix support of choices with string value in argparse (GH-124578)
Substrings of the specified string no longer considered valid values.
2024-09-29 10:57:21 +03:00
Serhiy Storchaka 69a4063ca5
gh-123339: Fix cases of inconsistency of __module__ and __firstlineno__ in classes (GH-123613)
* Setting the __module__ attribute for a class now removes the
  __firstlineno__ item from the type's dict.
* The _collections_abc and _pydecimal modules now completely replace the
  collections.abc and decimal modules after importing them. This
  allows to get the source of classes and functions defined in these
  modules.
* inspect.findsource() now checks whether the first line number for a
  class is out of bound.
2024-09-28 20:51:49 +03:00
Jelle Zijlstra c976d789a9
docs: improve venv docs (#124540)
- Move "versionchanged" notes that apply to the whole class to the
  end of the class docs
- Remove or move notes next to the method list that apply to individual
  methods.
- Mark up parameters using the appropriate syntax
- Do not capitalize "boolean"
- Shorten some text
2024-09-28 05:50:09 -07:00
Jean-François B. fae5058ec1
Doc: Fix default ``latex_elements['papersize']`` (#124525)
https://www.sphinx-doc.org/en/master/latex.html#the-latex-elements-configuration-setting

It should be 'letterpaper' or 'a4paper' not 'letter' or 'a4'
(not to be confused with PAPER env variable).
2024-09-28 11:30:28 +01:00
Raymond Hettinger 165ed68c26
Sorting techniques edits (#124701) 2024-09-27 17:19:44 -07:00
Pablo Galindo Salgado 02b49c5150
gh-107954: Fix configuration type for the perf profiler (#124636) 2024-09-28 01:50:16 +02:00
Petr Viktorin 425587a110
gh-124385: Document and soft-deprecate PyLong_AS_LONG (GH-124386) 2024-09-27 23:40:50 +00:00
Jelle Zijlstra 1ba35ea385
gh-123299: Copy-edit the 3.14 What's New (#124670)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-09-28 01:25:33 +03:00
Matt Delengowski 2357d5ba48
gh-90190: Add doc for using `singledispatch` with precise collection type hints (#116544) 2024-09-27 21:10:29 +00:00
Emily Morehouse 626668912f
gh-81263: Add assignment expressions to `help` (#124641)
* Add assignment expression (:=) to `help`

* Update index for Assignment Expressions to include pair of `assignment; expression`
2024-09-27 13:59:26 -07:00
Petr Viktorin 3387f76b8f
gh-124520: What's New entry for ctypes metaclass __new__/__init__ change (GH-124546) 2024-09-27 22:13:53 +02:00
Victor Stinner d8cf587dc7
doc: PyUnicode_AsUTF8String() fails if string contains surrogates (#124605) 2024-09-27 20:13:29 +00:00
Raymond Hettinger 2e155536ca
Itertool docs: Minor clarifications, wording tweaks, spacing, and active voice. (gh-124690)
Minor clarifications, wording tweaks, spacing, and active voice.
2024-09-27 18:43:46 +00:00
Petr Viktorin e349f73a5a
gh-121277: Raise nice error on `next` as second argument to deprecated-removed (GH-124623) 2024-09-27 19:38:40 +02:00
Alex Waygood 6716dd1c33
Fixup indentation for docs on `ModuleSpec` attributes (#124681)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-09-27 17:35:09 +00:00
sobolevn 9c7657f099
gh-113878: Add `doc` parameter to `dataclasses.field` (gh-114051)
If using `slots=True`, the `doc` parameter ends up in the `__slots__` dict. The `doc` parameter is also in the corresponding `Field` object.
2024-09-27 12:20:49 -04:00
Max Bachmann b79a21ea42
GH-95079: document error behaviour for some unicode C APIs (#95080) 2024-09-27 12:35:55 +02:00
Ned Batchelder 5329d1b74a
Docs: for for/else clarify that return or raise also skip the else (#124591)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-09-27 06:17:25 -04:00
Hugo van Kemenade 23e812b84a
Docs: Update and proofread `library/venv.rst` (#124121)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-09-27 02:57:38 +03:00
Gregory P. Smith b65f2cdfa7
gh-84559: Change the multiprocessing start method default to `forkserver` (GH-101556)
Change the default multiprocessing start method away from fork to forkserver or spawn on the remaining platforms where it was fork.  See the issue for context.  This makes the default far more thread safe (other than for people spawning threads at import time... - don't do that!).

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-09-26 16:57:19 -07:00
Jelle Zijlstra 2c10832887
gh-119180: Rename SOURCE format to STRING (#124620) 2024-09-26 13:49:48 -07:00
Matthew Rahtz 7d3497f617
gh-115528: Update language reference for PEP 646 (#121181)
To recap: the objective is to make starred expressions valid in `subscription`,
which is used for generics: `Generic[...]`, `list[...]`, etc.

What _is_ gramatically valid in such contexts? Seemingly any of the following.
(At least, none of the following throw `SyntaxError` in a 3.12.3 REPL.)

    Generic[x]
    Generic[*x]
    Generic[*x, y]
    Generic[y, *x]
    Generic[x := 1]
    Generic[x := 1, y := 2]

So introducting

    flexible_expression: expression | assignment_expression | starred_item

end then switching `subscription` to use `flexible_expression` sorts that.

But then we need to field `yield` - for which any of the following are
apparently valid:

    yield x
    yield x,
    yield x, y
    yield *x,
    yield *x, *y

Introducing a separate `yield_list` is the simplest way I've been figure out to
do this - separating out the special case of `starred_item ,`.



Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-09-26 12:35:17 -07:00
Jelle Zijlstra 43979fad90
Programming FAQ: Mention object.__setattr__ as a technique for delegation (#124617)
This is used for example by threading.local in the stdlib.
2024-09-26 11:50:31 -07:00
Adam Turner 2c472d36b7
Doc: Use the short version for daily downloads (#124602) 2024-09-26 16:44:25 +01:00
Jelle Zijlstra cf2418076d
gh-119127: functools: Improve docs for partial and Placeholder (#124575) 2024-09-26 07:12:56 -07:00
Tomas R 09aebb1fbc
gh-118181: Fix parameter markup in AST docs (#124473) 2024-09-26 06:38:25 -07:00
Sergey B Kirpichev 274d9ab619
gh-123560: Correct docs for "empty" format type for floats (#123561) 2024-09-26 14:40:18 +02:00
sobolevn 19fed6cf6e
gh-124234: Improve docs for `Mock.reset_mock` (#124237) 2024-09-26 15:06:52 +03:00
Jelle Zijlstra 08a467b537
gh-101100: Make __subclasses__ doctest stable (#124577)
Using a standard library class makes this test difficult to maintain
as other tests and other parts of the stdlib may create subclasses,
which may still be alive when this test runs depending on GC timing.
2024-09-26 06:26:03 +00:00
Ron Frederick 1229cb8c14
gh-120284: Enhance `asyncio.run` to accept awaitable objects (#120566)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2024-09-26 11:45:08 +05:30
dgpb d9296529eb
gh-119127: functools.partial placeholders (gh-119827) 2024-09-26 01:04:38 +00:00
Jelle Zijlstra 4e829c0e6f
gh-124412: Add helpers for converting annotations to source format (#124551) 2024-09-26 00:01:09 +00:00
Ned Batchelder ffdc80e93d
For-else deserves its own section in the tutorial (#123946)
* For-else deserves its own section in the tutorial

* remove mention of unrolling the loop

* Update Doc/tutorial/controlflow.rst

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>

---------

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-09-25 19:18:18 -04:00
Jelle Zijlstra 99b23c64de
gh-123242: Note that type.__annotations__ may not exist (#124557)
Closes #123242. The real criterion is that the attribute does not
exist on heap types, but I don't think we should discuss heap vs.
static types in the language reference.
2024-09-25 16:08:14 -07:00
Savannah Ostrowski 4e2fb7bdf5
GH-58058: Add quick reference for `ArgumentParser` to argparse docs (gh-124227) 2024-09-25 15:22:17 -07:00
Nice Zombies 9968caa0cc
gh-41431: Add `datetime.time.strptime()` and `datetime.date.strptime()` (#120752)
* Python implementation

* C implementation

* Test `date.strptime`

* Test `time.strptime`

* 📜🤖 Added by blurb_it.

* Update whatsnew

* Update documentation

* Add leap year note

* Update 2024-06-19-19-53-42.gh-issue-41431.gnkUc5.rst

* Apply suggestions from code review

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

* Remove parentheses

* Use helper function

* Remove bad return

* Link to github issue

* Fix directive

* Apply suggestions from code review

Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>

* Fix test cases

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>
2024-09-25 14:43:58 -07:00
Sam Gross 68e384c217
gh-124370: Add "howto" for free-threaded Python (#124371)
* gh-124370: Add "howto" for free-threaded Python

This is a guide aimed at people writing Python code, as oppposed to the
existing guide for C API extension authors.

* Add missing new line

* Update Doc/howto/free-threading-python.rst

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>

* interned -> immortalized

* Apply suggestions from code review

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>

* Update Doc/howto/free-threading-python.rst

Co-authored-by: mpage <mpage@cs.stanford.edu>

* Update docs

* Apply suggestions from code review

Co-authored-by: Carol Willing <carolcode@willingconsulting.com>

* A few more updates

* Additional comment on immortal objects

* Mention specializing adaptive interpreter

* Remove trailing whitespace

* Remove mention of C macro

---------

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: mpage <mpage@cs.stanford.edu>
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
2024-09-25 17:31:53 -04:00
Petr Viktorin 7d24ea9db3
gh-121277: Allow `.. versionadded:: next` in docs (GH-121278)
Make `versionchanged:: next`` expand to current (unreleased) version.

When a new CPython release is cut, the release manager will replace
all such occurences of "next" with the just-released version.
(See the issue for release-tools and devguide PRs.)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-09-25 23:30:40 +02:00
Raymond Hettinger 909c6f7189
gh-123884 Tee of tee was not producing n independent iterators (gh-124490) 2024-09-25 13:38:05 -07:00
Alex Waygood 0d9d56c4e4
gh-101100: Add a table of class attributes to the "Custom classes" section of the data model docs (#124480) 2024-09-25 19:29:58 +00:00
Adam Turner 6318ffcba2
Doc: Use ``major.minor`` for documentation distribution archive filenames (#124489) 2024-09-25 20:06:54 +01:00