Commit Graph

28603 Commits

Author SHA1 Message Date
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
Tian Gao 28efeefab7
gh-123756: Disable restart command if pdb is in inline mode (#123757) 2024-09-25 11:18:01 -07:00
Thomas Grainger 162d152146
import: permit __name__ for use in __name__ = "__main__": (#124381)
permit __name__ for use in __name__ = "__main__":
2024-09-25 10:39:14 -07:00
Damien 828583a785
gh-123223: Adding hyperlink of argument in warnings.catch_warnings: (#123231)
* Adding hyperlink of argument

* Modify as reviewer suggested
2024-09-25 10:30:34 -07:00
Robert Wolff f8651a2988
gh-123968: fix -f/--float command line option description (#124517)
* fix -f/--float command line option description

See gh-123968 gh-124009

* Update Doc/library/random.rst

---------

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2024-09-25 09:47:45 -07:00
Irit Katriel 78aeb38f7d
gh-124285: Fix bug where bool() is called multiple times for the same part of a boolean expression (#124394) 2024-09-25 15:51:25 +01:00
Malcolm Smith c58c572a65
gh-123014: Disable pidfd API on older Android versions (#124458) 2024-09-25 16:23:30 +02:00
Mat S 8447c933da
gh-123445: calendar: Improve descriptions for day and month attributes (#123483)
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-09-25 10:24:47 +01:00
Tom Most 0d38409f42
Doc: Improve documentation for the ``path`` argument in ``shutil.which()`` (#124494) 2024-09-25 08:54:13 +01:00
Eric V. Smith 5c6e3b7150
gh-90562: Support zero argument super with dataclasses when slots=True (gh-124455)
Co-authored-by: @wookie184
Co-authored-by: Carl Meyer <carl@oddbird.net>
2024-09-24 21:26:26 -04:00
Tian Gao af8403a58d
gh-120254: Add a `commands` argument to `pdb.set_trace` (#120255) 2024-09-24 12:52:15 -07:00
Savannah Ostrowski 20ccda000b
GH-87358: Add clarification about nargs and default argparse behaviour (#124094) 2024-09-24 19:30:01 +03:00
Stanley e69ff34e81
gh-65169: Clarify prog default in argparse (GH-31602) 2024-09-24 10:57:37 +00:00
sobolevn faef3fa653
gh-124120: Document `Annotated.__origin__` (#124125)
Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-09-24 09:53:04 +03:00
Victor Stinner 9d344fafc4
gh-124127: Make Py_REFCNT() opaque in limited C API 3.14 (#124128) 2024-09-24 08:42:58 +02:00
Jelle Zijlstra d56faf28e6
gh-119180: Add discussion of annotations to the 3.14 What's New (#124393)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-09-23 22:50:13 -07:00
Jason Fried d87482bc4e
gh-119333: Add C api to have contextvar enter/exit callbacks (#119335)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2024-09-23 20:40:17 -07:00
Donghee Na ad7c778546
gh-123990: Good bye WITH_FREELISTS macro (gh-124358) 2024-09-24 01:28:59 +00:00
Petr Viktorin be76e3f26e
gh-100980: ctypes: Test, document, and fix finalizing _fields_ (GH-124292)
- If setting `_fields_` fails, e.g. with AttributeError, don't set the attribute in `__dict__`
- Document the “finalization” behaviour
- Beef up tests: add `getattr`, test Union as well as Structure
- Put common functionality in a common function

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2024-09-24 02:40:53 +02:00
Bénédikt Tran 38a887dc3e
gh-119004: fix a crash in equality testing between `OrderedDict` (#121329) 2024-09-23 18:44:36 -05:00
Malcolm Smith e80dd3035f
gh-116622: Complete Android documentation (#124259)
Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
Co-authored-by: T. Wouters <thomas@python.org>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2024-09-23 23:09:53 +00:00
Alex Waygood 8a2baedc4b
Bump Ruff to 0.6.7 (#124384) 2024-09-23 22:19:35 +00:00
Adam Turner 0060486862
Doc: Add ``make dist-no-html`` (#124383)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-09-23 23:11:34 +01:00
Brett Cannon 67201ad53f
GH-65961: Document the deprecation of `__package__` and `__cached__` (GH-124377)
The code changes for warning related to `__package__` landed in Python 3.12. `__cached__` doesn't have any changes as it isn't used but only set by the import system.
2024-09-23 14:14:33 -07:00
Adam Turner 9e55a02fab
GH-109975: Copyedit 3.13 What's New: Trivia (#124348) 2024-09-23 19:32:23 +00:00
Adam Turner e7d465a607
GH-109975: Copyedit 3.13 What's New: Copyedit C API deprecations pending removal (#124336) 2024-09-23 19:40:20 +01:00
Adam Turner f3b2c36deb
GH-109975: Copyedit 3.13 What's New: Build Changes (#124343)
Co-authored-by: Malcolm Smith <smith@chaquo.com>
2024-09-23 11:30:45 -07:00
Adam Turner 2f6d4109b8
GH-109975: Copyedit 3.13 What's New: Porting to Python 3.13 (#124341)
Copyedit Porting to Python 3.13
2024-09-23 11:14:37 -07:00
decorator-factory 6203ef35dd
Replace the term `Immutable` with a `Hashable` in the `sequence` entry of the Glossary (#124350)
The term `Immutable` in the `sequence` entry of the glossary is used incorrectly, in fact dicts accepts hashable keys, which is not the same as immutable.
2024-09-23 16:34:08 +00:00
Adam Turner 9d0a75269c
GH-109975: Copyedit 3.13 What's New: C API (#124313) 2024-09-23 14:28:17 +01:00
Savannah Ostrowski 5f5c0b9c23
GH-79714: Add mention of stderr for clarity to ArgumentParser.exit() (GH-123932) 2024-09-23 12:08:03 +03:00