]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
2 years agoGH-102456: Fix docstring and getopt options for base64 (gh-102457) 103190/head
Partha P. Mukherjee [Sun, 2 Apr 2023 05:05:50 +0000 (01:05 -0400)] 
GH-102456: Fix docstring and getopt options for base64 (gh-102457)

2 years agogh-102192: deprecate _PyErr_ChainExceptions (#102935)
Irit Katriel [Sat, 1 Apr 2023 20:30:23 +0000 (21:30 +0100)] 
gh-102192: deprecate _PyErr_ChainExceptions (#102935)

2 years agogh-102192: use PyErr_SetHandledException instead of the legacy PyErr_SetExcInfo ...
Irit Katriel [Sat, 1 Apr 2023 05:01:48 +0000 (06:01 +0100)] 
gh-102192: use PyErr_SetHandledException instead of the legacy PyErr_SetExcInfo (#103157)

2 years agoAdd missing variables to `bytecodes.c` (GH-103153)
Brett Cannon [Fri, 31 Mar 2023 21:23:55 +0000 (14:23 -0700)] 
Add missing variables to `bytecodes.c` (GH-103153)

The code works without this change, but it does cause C tooling to complain less about undeclared variables.

2 years agogh-74690: Micro-optimise `typing._get_protocol_attrs` (#103152)
Alex Waygood [Fri, 31 Mar 2023 20:54:50 +0000 (21:54 +0100)] 
gh-74690: Micro-optimise `typing._get_protocol_attrs` (#103152)

Improve performance of `isinstance()` checks against runtime-checkable protocols

2 years agogh-102549: [Enum] fail enum creation when data type raises in __init__ (GH-103149)
Ethan Furman [Fri, 31 Mar 2023 20:52:31 +0000 (13:52 -0700)] 
gh-102549: [Enum] fail enum creation when data type raises in __init__ (GH-103149)

2 years agogh-101659: Clean Up the General Import Tests for Subinterpreters (gh-103151)
Eric Snow [Fri, 31 Mar 2023 18:18:33 +0000 (12:18 -0600)] 
gh-101659: Clean Up the General Import Tests for Subinterpreters (gh-103151)

This involves 3 changes: some general cleanup, checks to match the kind of module, and switch from testing against sys to _imp.

This is a precursor to gh-103150, though the changes are meant to stand on their own.

2 years agogh-100227: Fix Cleanup of the Extensions Cache (gh-103150)
Eric Snow [Fri, 31 Mar 2023 18:09:10 +0000 (12:09 -0600)] 
gh-100227: Fix Cleanup of the Extensions Cache (gh-103150)

Decref the key in the right interpreter in _extensions_cache_set().

This is a follow-up to gh-103084. I found the bug while working on gh-101660.

2 years agogh-74690: typing: Don't unnecessarily call `_get_protocol_attrs` twice in `_ProtocolM...
Alex Waygood [Fri, 31 Mar 2023 17:37:24 +0000 (18:37 +0100)] 
gh-74690: typing: Don't unnecessarily call `_get_protocol_attrs` twice in `_ProtocolMeta.__instancecheck__` (#103141)

Speed up `isinstance()` calls against runtime-checkable protocols

2 years agogh-87092: move CFG related code from compile.c to flowgraph.c (#103021)
Irit Katriel [Fri, 31 Mar 2023 17:17:59 +0000 (18:17 +0100)] 
gh-87092: move CFG related code from compile.c to flowgraph.c (#103021)

2 years agogh-102871: Remove obsolete browsers from webbrowser (#102872)
James De Bias [Fri, 31 Mar 2023 15:02:47 +0000 (02:02 +1100)] 
gh-102871: Remove obsolete browsers from webbrowser (#102872)

2 years agoGH-84783: Mention Author for GH-101264 (make slices hashable) (#103146)
Furkan Onder [Fri, 31 Mar 2023 13:54:17 +0000 (16:54 +0300)] 
GH-84783: Mention Author for GH-101264 (make slices hashable) (#103146)

Will Bradshaw contributed original patch on bpo-40603.
---------

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2 years agoQuote literal tokens in standard format specifier grammar (GH-102902)
Petr Viktorin [Fri, 31 Mar 2023 12:40:38 +0000 (14:40 +0200)] 
Quote literal tokens in standard format specifier grammar (GH-102902)

Reported by Damian Dureck: https://mail.python.org/archives/list/docs@python.org/thread/UZTWBJIXC3MBKTHXVTIBPGDPKBNWZ5LN/

2 years agogh-101100: Expand list of clean docs (GH-103135)
Hugo van Kemenade [Fri, 31 Mar 2023 10:48:46 +0000 (13:48 +0300)] 
gh-101100:  Expand list of clean docs (GH-103135)

Follow on from https://github.com/python/cpython/pull/103116.

Expand list of clean docs files from 3 to 181. These files have no Sphinx warnings, and their presence in this list means that any new warnings introduced will fail the build.

The list was created by subtracting the list of files with warnings from a list of all files.

I tested with all of those, but found that `touch`ing two clean files (https://github.com/python/cpython/blob/main/Doc/includes/wasm-notavail.rst and https://github.com/python/cpython/blob/main/Doc/whatsnew/changelog.rst) caused a cascade effect and resulted in a number of dirty files being rebuilt too, and failing the build. So those two have been omitted.

Automerge-Triggered-By: GH:hugovk
2 years agogh-102799: use exception instance instead of sys.exc_info() (#102885)
Irit Katriel [Fri, 31 Mar 2023 10:23:02 +0000 (11:23 +0100)] 
gh-102799: use exception instance instead of sys.exc_info() (#102885)

2 years agoMinor docs improvements fix for `codeop` (#103123)
gaogaotiantian [Thu, 30 Mar 2023 22:51:36 +0000 (15:51 -0700)] 
Minor docs improvements fix for `codeop` (#103123)

2 years agogh-102110: Add all tools description missed (GH-102625)
Missoupro [Thu, 30 Mar 2023 20:49:07 +0000 (21:49 +0100)] 
gh-102110: Add all tools description missed (GH-102625)

Added missing descriptions of some tools.

Automerge-Triggered-By: GH:hugovk
2 years agoAdd IPv6 into to the docstring for socket.getsockname (#102961)
Brian Haley [Thu, 30 Mar 2023 18:40:58 +0000 (14:40 -0400)] 
Add IPv6 into to the docstring for socket.getsockname (#102961)

Signed-off-by: Brian Haley <haleyb.dev@gmail.com>
2 years agogh-101100: Fix Sphinx warning in gc.rst and refactor docs clean list (#103116)
Hugo van Kemenade [Thu, 30 Mar 2023 18:03:50 +0000 (21:03 +0300)] 
gh-101100: Fix Sphinx warning in gc.rst and refactor docs clean list (#103116)

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
2 years agogh-103085: Fix python locale.getencoding not to emit deprecation warning (gh-103086)
Jeong, YunWon [Thu, 30 Mar 2023 16:23:43 +0000 (01:23 +0900)] 
gh-103085: Fix python locale.getencoding not to emit deprecation warning (gh-103086)

2 years agogh-103099: Link mypy docs from typing.rst (#103100)
Shantanu [Thu, 30 Mar 2023 08:32:09 +0000 (01:32 -0700)] 
gh-103099: Link mypy docs from typing.rst (#103100)

2 years agogh-100227: Make the Global PyModuleDef Cache Safe for Isolated Interpreters (gh-103084)
Eric Snow [Wed, 29 Mar 2023 23:15:43 +0000 (17:15 -0600)] 
gh-100227: Make the Global PyModuleDef Cache Safe for Isolated Interpreters (gh-103084)

Sharing mutable (or non-immortal) objects between interpreters is generally not safe.  We can work around that but not easily.
 There are two restrictions that are critical for objects that break interpreter isolation.

The first is that the object's state be guarded by a global lock.  For now the GIL meets this requirement, but a granular global lock is needed once we have a per-interpreter GIL.

The second restriction is that the object (and, for a container, its items) be deallocated/resized only when the interpreter in which it was allocated is the current one.  This is because every interpreter has (or will have, see gh-101660) its own object allocator.  Deallocating an object with a different allocator can cause crashes.

The dict for the cache of module defs is completely internal, which simplifies what we have to do to meet those requirements.  To do so, we do the following:

* add a mechanism for re-using a temporary thread state tied to the main interpreter in an arbitrary thread
   * add _PyRuntime.imports.extensions.main_tstate`
   * add _PyThreadState_InitDetached() and _PyThreadState_ClearDetached() (pystate.c)
   * add _PyThreadState_BindDetached() and _PyThreadState_UnbindDetached() (pystate.c)
* make sure the cache dict (_PyRuntime.imports.extensions.dict) and its items are all owned by the main interpreter)
* add a placeholder using for a granular global lock

Note that the cache is only used for legacy extension modules and not for multi-phase init modules.

https://github.com/python/cpython/issues/100227

2 years agoGH-89987: Shrink the BINARY_SUBSCR caches (GH-103022)
Brandt Bucher [Wed, 29 Mar 2023 22:53:30 +0000 (15:53 -0700)] 
GH-89987: Shrink the BINARY_SUBSCR caches (GH-103022)

2 years agogh-90110: Bring the whitelists up to date. (gh-103114)
Eric Snow [Wed, 29 Mar 2023 22:08:40 +0000 (16:08 -0600)] 
gh-90110: Bring the whitelists up to date. (gh-103114)

https://github.com/python/cpython/issues/90110

2 years agoGH-102973: add a dev container (GH-102975)
Brett Cannon [Wed, 29 Mar 2023 20:28:08 +0000 (13:28 -0700)] 
GH-102973: add a dev container (GH-102975)

On content update, builds `python` and the docs. Also adds a Dockerfile that should include everything but autoconf 2.69 that's necessary to build CPython and the entire stdlib on Fedora.

Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
Co-authored-by: Dusty Phillips <dusty@phillips.codes>
2 years agogh-103112: Add http.client.HTTPResponse.read docstring and fix pydoc output (#103113)
Bernhard Wagner [Wed, 29 Mar 2023 19:21:56 +0000 (21:21 +0200)] 
gh-103112: Add http.client.HTTPResponse.read docstring and fix pydoc output (#103113)

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Éric <merwok@netwok.org>
2 years agogh-103068: Check condition expression of breakpoints for pdb (#103069)
gaogaotiantian [Wed, 29 Mar 2023 10:09:12 +0000 (03:09 -0700)] 
gh-103068: Check condition expression of breakpoints for pdb (#103069)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Artem Mukhin <ortem00@gmail.com>
2 years agogh-102582: Fix invalid JSON in Doc/howto/logging-cookbook.rst (GH-102635)
Matěj Cepl [Wed, 29 Mar 2023 08:52:53 +0000 (10:52 +0200)] 
gh-102582: Fix invalid JSON in Doc/howto/logging-cookbook.rst (GH-102635)

2 years agogh-103054: typing: Improve `Callable` type substitution tests (#103055)
Nikita Sobolev [Wed, 29 Mar 2023 03:04:26 +0000 (06:04 +0300)] 
gh-103054: typing: Improve `Callable` type substitution tests (#103055)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Eclips4 <80244920+Eclips4@users.noreply.github.com>
2 years agogh-103097: Add workaround for Windows ARM64 compiler bug (GH-103098)
Steve Dower [Tue, 28 Mar 2023 23:47:13 +0000 (00:47 +0100)] 
gh-103097: Add workaround for Windows ARM64 compiler bug (GH-103098)

See https://developercommunity.visualstudio.com/t/Regression-in-MSVC-1433-1434-ARM64-co/10224361 for details of the issue. It only applies to version 14.34.

2 years agogh-100227: Move the Dict of Interned Strings to PyInterpreterState (gh-102339)
Eric Snow [Tue, 28 Mar 2023 18:52:28 +0000 (12:52 -0600)] 
gh-100227: Move the Dict of Interned Strings to PyInterpreterState (gh-102339)

We can revisit the options for keeping it global later, if desired.  For now the approach seems quite complex, so we've gone with the simpler isolation solution in the meantime.

https://github.com/python/cpython/issues/100227

2 years agoGH-102711: Fix warnings found by clang (#102712)
Chenxi Mao [Tue, 28 Mar 2023 08:52:22 +0000 (16:52 +0800)] 
GH-102711: Fix warnings found by clang (#102712)

There are some warnings if build python via clang:

Parser/pegen.c:812:31: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
_PyPegen_clear_memo_statistics()
                              ^
                               void

Parser/pegen.c:820:29: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
_PyPegen_get_memo_statistics()
                            ^
                             void

Fix it to make clang happy.

Signed-off-by: Chenxi Mao <chenxi.mao@suse.com>
2 years agogh-102558: [Enum] better handling of non-Enum EnumType classes (GH-103060)
Ethan Furman [Mon, 27 Mar 2023 23:26:16 +0000 (16:26 -0700)] 
gh-102558: [Enum] better handling of non-Enum EnumType classes (GH-103060)

2 years agogh-103056: [Enum] ensure final _generate_next_value_ is a staticmethod (GH-103062)
Ethan Furman [Mon, 27 Mar 2023 23:25:19 +0000 (16:25 -0700)] 
gh-103056: [Enum] ensure final _generate_next_value_ is a staticmethod (GH-103062)

2 years agogh-74468: [tarfile] Fix incorrect name attribute of ExFileObject (GH-102424)
Oleg Iarygin [Mon, 27 Mar 2023 23:21:07 +0000 (03:21 +0400)] 
gh-74468: [tarfile] Fix incorrect name attribute of ExFileObject (GH-102424)

Co-authored-by: Simeon Visser <svisser@users.noreply.github.com>
2 years agogh-100227: Revert gh-102925 "gh-100227: Make the Global Interned Dict Safe for Isolat...
Eric Snow [Mon, 27 Mar 2023 22:53:05 +0000 (16:53 -0600)] 
gh-100227: Revert gh-102925 "gh-100227: Make the Global Interned Dict Safe for Isolated Interpreters" (gh-103063)

This reverts commit 87be8d9.

This approach to keeping the interned strings safe is turning out to be too complex for my taste (due to obmalloc isolation). For now I'm going with the simpler solution, making the dict per-interpreter. We can revisit that later if we want a sharing solution.

2 years agogh-103046: Display current line correctly for `dis.disco()` with CACHE entries (...
gaogaotiantian [Mon, 27 Mar 2023 22:22:06 +0000 (15:22 -0700)] 
gh-103046: Display current line correctly for `dis.disco()` with CACHE entries (#103047)

2 years agogh-103023: Add SyntaxError check in pdb's `display` command (#103024)
gaogaotiantian [Mon, 27 Mar 2023 20:37:22 +0000 (13:37 -0700)] 
gh-103023: Add SyntaxError check in pdb's `display` command (#103024)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2 years agogh-102941: Fix "‘subobj’ may be used uninitialized in this function" warning in ...
Nikita Sobolev [Mon, 27 Mar 2023 00:05:06 +0000 (03:05 +0300)] 
gh-102941: Fix "‘subobj’ may be used uninitialized in this function" warning in `bytes_methods.c` (#102942)

2 years agoFix typo in _swappedbytes_ in ctypes comment (#102773)
Matthias Görgens [Sat, 25 Mar 2023 23:38:24 +0000 (07:38 +0800)] 
Fix typo in _swappedbytes_ in ctypes comment (#102773)

It's a minor typo, but it makes for a misleading comment.  Let's fix it.

2 years agogh-98886: Fix issues with dataclass fields with special underscore names (#102032)
Shantanu [Sat, 25 Mar 2023 21:40:11 +0000 (14:40 -0700)] 
gh-98886: Fix issues with dataclass fields with special underscore names (#102032)

This commit prefixes `__dataclass` to several things in the locals dict:
- Names like `_dflt_` (which cause trouble, see first test)
- Names like `_type_` (not known to be able to cause trouble)
- `_return_type` (not known to able to cause trouble)
- `_HAS_DEFAULT_FACTORY` (which causes trouble, see second test)

In addition, this removes `MISSING` from the locals dict. As far as I can tell, this wasn't needed even in the initial implementation of dataclasses.py (and tests on that version passed with it removed). This makes me wary :-)

This is basically a continuation of #96151, where fixing this was welcomed in https://github.com/python/cpython/pull/98143#issuecomment-1280306360

2 years agoUpdate pdb docs for arguments (#102965)
gaogaotiantian [Sat, 25 Mar 2023 21:31:45 +0000 (14:31 -0700)] 
Update pdb docs for arguments (#102965)

2 years agoFix typos in faulthandler, testcapi error messages (#103020)
Liyang Zhang [Sat, 25 Mar 2023 21:27:02 +0000 (16:27 -0500)] 
Fix typos in faulthandler, testcapi error messages (#103020)

2 years agogh-103027: Update `dataclass.make_dataclass` docstring (gh-103028)
Nikita Sobolev [Sat, 25 Mar 2023 19:36:38 +0000 (22:36 +0300)] 
gh-103027: Update `dataclass.make_dataclass` docstring (gh-103028)

* gh-103027: Update `dataclass.make_dataclass` docstring

2 years agogh-103025: fix two ctypes doc issues (#103026)
Peter Jiping Xie [Sat, 25 Mar 2023 09:12:00 +0000 (17:12 +0800)] 
gh-103025: fix two ctypes doc issues  (#103026)

2 years agoGH-102833: Mention the key function in the docstrings (GH-103009)
Raymond Hettinger [Sat, 25 Mar 2023 07:19:20 +0000 (02:19 -0500)] 
GH-102833: Mention the key function in the docstrings (GH-103009)

2 years agogh-101100: Test only Doc/ files in nit-picky mode (#103019)
Hugo van Kemenade [Sat, 25 Mar 2023 07:15:02 +0000 (09:15 +0200)] 
gh-101100: Test only Doc/ files in nit-picky mode (#103019)

gh-101100: Filter only Doc/ files

2 years agogh-100131: Add optional delete parameter to tempfile.TemporaryDirectory() (#100132)
JakobDev [Fri, 24 Mar 2023 21:52:06 +0000 (22:52 +0100)] 
gh-100131: Add optional delete parameter to tempfile.TemporaryDirectory() (#100132)

Add optional delete parameter to tempfile.TemporaryDirectory().

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2 years agogh-102980: Add tests for pdf's display, alias and where commands (#102981)
gaogaotiantian [Fri, 24 Mar 2023 20:50:06 +0000 (13:50 -0700)] 
gh-102980: Add tests for pdf's display, alias and where commands (#102981)

2 years agogh-102873: logging.LogRecord docs: improve description of `msg` parameter (#102875)
Amin Alaee [Fri, 24 Mar 2023 15:00:32 +0000 (16:00 +0100)] 
gh-102873: logging.LogRecord docs: improve description of `msg` parameter (#102875)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2 years agogh-100372: Use BIO_eof to detect EOF for SSL_FILETYPE_ASN1 (GH-100373)
David Benjamin [Fri, 24 Mar 2023 13:04:30 +0000 (09:04 -0400)] 
gh-100372: Use BIO_eof to detect EOF for SSL_FILETYPE_ASN1 (GH-100373)

In PEM, we need to parse until error and then suppress `PEM_R_NO_START_LINE`, because PEM allows arbitrary leading and trailing data. DER, however, does not. Parsing until error and suppressing `ASN1_R_HEADER_TOO_LONG` doesn't quite work because that error also covers some cases that should be rejected.

Instead, check `BIO_eof` early and stop the loop that way.

Automerge-Triggered-By: GH:Yhg1s
2 years agogh-101100: Test docs in nit-picky mode (#102513)
Hugo van Kemenade [Fri, 24 Mar 2023 11:23:35 +0000 (13:23 +0200)] 
gh-101100: Test docs in nit-picky mode (#102513)

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2 years agoGH-100989: remove annotation from docstring (GH-102991)
Raymond Hettinger [Fri, 24 Mar 2023 05:39:12 +0000 (00:39 -0500)] 
GH-100989: remove annotation from docstring (GH-102991)

2 years agoGH-100989: Revert Improve the accuracy of collections.deque docstrings (GH-102979)
Raymond Hettinger [Fri, 24 Mar 2023 00:50:17 +0000 (19:50 -0500)] 
GH-100989: Revert Improve the accuracy of collections.deque docstrings (GH-102979)

2 years agogh-94684: uuid: support bytes in the name argument to uuid3/5 (#94709)
MonadChains [Thu, 23 Mar 2023 23:42:43 +0000 (00:42 +0100)] 
gh-94684: uuid: support bytes in the name argument to uuid3/5 (#94709)

RFC 4122 does not specify that name should be a string, so for completness the functions should also support a name given as a raw byte sequence.

2 years agogh-99726: Fix order of recently added fields for FILE_STAT_BASIC_INFORMATION (GH...
Steve Dower [Thu, 23 Mar 2023 23:27:46 +0000 (23:27 +0000)] 
gh-99726: Fix order of recently added fields for FILE_STAT_BASIC_INFORMATION (GH-102976)

2 years agoGH-100982: Break up COMPARE_AND_BRANCH (GH-102801)
Brandt Bucher [Thu, 23 Mar 2023 22:25:09 +0000 (15:25 -0700)] 
GH-100982: Break up COMPARE_AND_BRANCH (GH-102801)

2 years agogh-102558: [Enum] fix AttributeError during member repr() (GH-102601)
Dong-hee Na [Thu, 23 Mar 2023 20:30:18 +0000 (05:30 +0900)] 
gh-102558: [Enum] fix AttributeError during member repr() (GH-102601)

2 years agoMinor readability improvement to the factor() recipe (GH-102971)
Raymond Hettinger [Thu, 23 Mar 2023 19:46:15 +0000 (14:46 -0500)] 
Minor readability improvement to the factor() recipe (GH-102971)

2 years agogh-98239: Document that `inspect.getsource()` can raise `TypeError` (#101689)
Nikita Sobolev [Thu, 23 Mar 2023 19:35:02 +0000 (22:35 +0300)] 
gh-98239: Document that `inspect.getsource()` can raise `TypeError` (#101689)

2 years agogh-102936: typing: document performance pitfalls of protocols decorated with `@runtim...
Alex Waygood [Thu, 23 Mar 2023 18:18:53 +0000 (18:18 +0000)] 
gh-102936: typing: document performance pitfalls of protocols decorated with `@runtime_checkable` (#102937)

2 years agoMove binomialvariate() to a section for discrete distributions (GH-102955)
Raymond Hettinger [Thu, 23 Mar 2023 17:10:12 +0000 (12:10 -0500)] 
Move binomialvariate() to a section for discrete distributions (GH-102955)

2 years agogh-102810 Improve the sphinx docs for `asyncio.Timeout` (#102934)
JosephSBoyle [Thu, 23 Mar 2023 16:43:13 +0000 (16:43 +0000)] 
gh-102810 Improve the sphinx docs for `asyncio.Timeout` (#102934)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2 years agogh-102943: Stop checking localized error text in socket tests on Windows (GH-102944)
AN Long [Thu, 23 Mar 2023 16:34:48 +0000 (00:34 +0800)] 
gh-102943: Stop checking localized error text in socket tests on Windows (GH-102944)

2 years agogh-88965: typing: fix type substitution of a list of types after initial `ParamSpec...
Nikita Sobolev [Thu, 23 Mar 2023 16:26:11 +0000 (19:26 +0300)] 
gh-88965: typing: fix type substitution of a list of types  after initial `ParamSpec` substitution (#102808)

Previously, this used to fail:

```py
from typing import *
T = TypeVar("T")
P = ParamSpec("P")

class X(Generic[P]):
    f: Callable[P, int]

Y = X[[int, T]]
Z = Y[str]
```

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2 years agogh-102947: Improve traceback when calling `fields()` on a non-dataclass (#102948)
Alex Waygood [Thu, 23 Mar 2023 14:17:54 +0000 (14:17 +0000)] 
gh-102947: Improve traceback when calling `fields()` on a non-dataclass (#102948)

2 years agoDocs: fixup incorrect escape char in sqlite3 docs (#102945)
Erlend E. Aasland [Thu, 23 Mar 2023 13:21:32 +0000 (14:21 +0100)] 
Docs: fixup incorrect escape char in sqlite3 docs (#102945)

2 years agogh-102939: Fix "conversion from Py_ssize_t to long" warning in builtins (GH-102940)
Nikita Sobolev [Thu, 23 Mar 2023 10:37:04 +0000 (13:37 +0300)] 
gh-102939: Fix "conversion from Py_ssize_t to long" warning in builtins (GH-102940)

2 years agogh-100227: Make the Global Interned Dict Safe for Isolated Interpreters (gh-102925)
Eric Snow [Thu, 23 Mar 2023 00:30:04 +0000 (18:30 -0600)] 
gh-100227: Make the Global Interned Dict Safe for Isolated Interpreters (gh-102925)

This is effectively two changes.  The first (the bulk of the change) is where we add _Py_AddToGlobalDict() (and _PyRuntime.cached_objects.main_tstate, etc.).  The second (much smaller) change is where we update PyUnicode_InternInPlace() to use _Py_AddToGlobalDict() instead of calling PyDict_SetDefault() directly.

Basically, _Py_AddToGlobalDict() is a wrapper around PyDict_SetDefault() that should be used whenever we need to add a value to a runtime-global dict object (in the few cases where we are leaving the container global rather than moving it to PyInterpreterState, e.g. the interned strings dict).  _Py_AddToGlobalDict() does all the necessary work to make sure the target global dict is shared safely between isolated interpreters.  This is especially important as we move the obmalloc state to each interpreter (gh-101660), as well as, potentially, the GIL (PEP 684).

https://github.com/python/cpython/issues/100227

2 years ago[doc] Fix error in tutorial example: type(exc) is the type rather than the instance...
Jens-Hilmar Bradt [Wed, 22 Mar 2023 18:43:41 +0000 (19:43 +0100)] 
[doc] Fix error in tutorial example: type(exc) is the type rather than the instance (#102751)

2 years agogh-102921: [doc] Clarify `exc` argument name in `BaseExceptionGroup` is plural (...
Kevin Kirsche [Wed, 22 Mar 2023 18:14:05 +0000 (14:14 -0400)] 
gh-102921: [doc] Clarify `exc` argument name in `BaseExceptionGroup` is plural (#102922)

2 years agogh-102859: Remove JUMP_IF_FALSE_OR_POP and JUMP_IF_TRUE_OR_POP (#102870)
Irit Katriel [Wed, 22 Mar 2023 18:10:48 +0000 (18:10 +0000)] 
gh-102859: Remove JUMP_IF_FALSE_OR_POP and JUMP_IF_TRUE_OR_POP (#102870)

2 years agogh-102780: Fix uncancel() call in asyncio timeouts (#102815)
Kristján Valur Jónsson [Wed, 22 Mar 2023 17:52:10 +0000 (17:52 +0000)] 
gh-102780: Fix uncancel() call in asyncio timeouts (#102815)

Also use `raise TimeOut from <CancelledError instance>` so that the CancelledError is set
in the `__cause__` field rather than in the `__context__` field.

Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2 years agogh-102033: Fix syntax error in `Tools/c-analyzer` (GH-102066)
Nikita Sobolev [Wed, 22 Mar 2023 14:59:32 +0000 (17:59 +0300)] 
gh-102033: Fix syntax error in `Tools/c-analyzer` (GH-102066)

The easiest way to format strings with `{}` meaningful chars is via `%`.

2 years agoGH-101291: Rearrange the size bits in PyLongObject (GH-102464)
Mark Shannon [Wed, 22 Mar 2023 14:49:51 +0000 (14:49 +0000)] 
GH-101291: Rearrange the size bits in PyLongObject (GH-102464)

* Eliminate all remaining uses of Py_SIZE and Py_SET_SIZE on PyLongObject, adding asserts.

* Change layout of size/sign bits in longobject to support future addition of immortal ints and tagged medium ints.

* Add functions to hide some internals of long object, and for setting sign and digit count.

* Replace uses of IS_MEDIUM_VALUE macro with _PyLong_IsCompact().

2 years agoGH-89727: Fix pathlib.Path.walk RecursionError on deep trees (GH-100282)
Stanislav Zmiev [Wed, 22 Mar 2023 14:45:25 +0000 (18:45 +0400)] 
GH-89727: Fix pathlib.Path.walk RecursionError on deep trees (GH-100282)

Use a stack to implement `pathlib.Path.walk()` iteratively instead of recursively to avoid hitting recursion limits on deeply nested trees.

Co-authored-by: Barney Gale <barney.gale@gmail.com>
Co-authored-by: Brett Cannon <brett@python.org>
2 years agogh-96931: Fix incorrect results in ssl.SSLSocket.shared_ciphers (#96932)
Benjamin Fogle [Wed, 22 Mar 2023 14:08:41 +0000 (10:08 -0400)] 
gh-96931: Fix incorrect results in ssl.SSLSocket.shared_ciphers (#96932)

2 years agogh-102027: Fix macro name (#102124)
Max Bachmann [Wed, 22 Mar 2023 13:44:28 +0000 (14:44 +0100)] 
gh-102027: Fix macro name (#102124)

This fixes the ssse3 / sse2 detection when sse4 is available.

Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
2 years agogh-101947: Remove size check from sqlite3 serialize test (#102914)
Erlend E. Aasland [Wed, 22 Mar 2023 13:05:08 +0000 (14:05 +0100)] 
gh-101947: Remove size check from sqlite3 serialize test (#102914)

The size of the returned data is too implementation specific.

2 years agogh-101313: Add -h and --help arguments to the webbrowser module (gh-101374)
Icelain [Wed, 22 Mar 2023 12:19:52 +0000 (17:49 +0530)] 
gh-101313: Add -h and --help arguments to the webbrowser module (gh-101374)

2 years agoGH-95494: Fix transport EOF handling in OpenSSL 3.0 (GH-95495)
David Benjamin [Wed, 22 Mar 2023 12:16:26 +0000 (08:16 -0400)] 
GH-95494: Fix transport EOF handling in OpenSSL 3.0 (GH-95495)

GH-25309 enabled SSL_OP_IGNORE_UNEXPECTED_EOF by default, with a comment
that it restores OpenSSL 1.1.1 behavior, but this wasn't quite right.
That option causes OpenSSL to treat transport EOF as the same as
close_notify (i.e. SSL_ERROR_ZERO_RETURN), whereas Python actually has
distinct SSLEOFError and SSLZeroReturnError exceptions. (The latter is
usually mapped to a zero return from read.) In OpenSSL 1.1.1, the ssl
module would raise them for transport EOF and close_notify,
respectively. In OpenSSL 3.0, both act like close_notify.

Fix this by, instead, just detecting SSL_R_UNEXPECTED_EOF_WHILE_READING
and mapping that to the other exception type.

There doesn't seem to have been any unit test of this error, so fill in
the missing one. This had to be done with the BIO path because it's
actually slightly tricky to simulate a transport EOF with Python's fd
based APIs. (If you instruct the server to close the socket, it gets
confused, probably because the server's SSL object is still referencing
the now dead fd?)

2 years agoDocs: improve accuracy of sqlite3.Connection.interrupt() (#102904)
Erlend E. Aasland [Wed, 22 Mar 2023 11:50:00 +0000 (12:50 +0100)] 
Docs: improve accuracy of sqlite3.Connection.interrupt() (#102904)

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
2 years agogh-100989: Improve the accuracy of collections.deque docstrings (#100990)
Timo Ludwig [Wed, 22 Mar 2023 11:46:58 +0000 (12:46 +0100)] 
gh-100989: Improve the accuracy of collections.deque docstrings (#100990)

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
2 years agoDocs: improve the accuracy of the sqlite3.connect() timeout param (#102900)
Erlend E. Aasland [Wed, 22 Mar 2023 11:37:13 +0000 (12:37 +0100)] 
Docs: improve the accuracy of the sqlite3.connect() timeout param (#102900)

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
2 years agoGH-94808: Cover `PyOS_mystrnicmp` and `PyOS_mystricmp` (gh-102469)
Artem Mukhin [Wed, 22 Mar 2023 11:35:27 +0000 (12:35 +0100)] 
GH-94808: Cover `PyOS_mystrnicmp` and `PyOS_mystricmp` (gh-102469)

2 years agoDocs: improve accuracy of pdb alias example (#102892)
gaogaotiantian [Wed, 22 Mar 2023 11:34:52 +0000 (04:34 -0700)] 
Docs: improve accuracy of pdb alias example (#102892)

2 years agogh-102839: remove AC for math.log (GH-102863) 102894/head
Sergey B Kirpichev [Tue, 21 Mar 2023 23:48:19 +0000 (02:48 +0300)] 
gh-102839: remove AC for math.log (GH-102863)

2 years agoAdd link to `sys.exit` function documentation (#102805)
David Poirier [Tue, 21 Mar 2023 21:58:31 +0000 (08:58 +1100)] 
Add link to `sys.exit` function documentation (#102805)

* Add link to `sys.exit` function documentation

* Update Doc/library/os.rst

Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
* Update Doc/library/os.rst

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
---------

Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
2 years agogh-102406: replace exception chaining by PEP-678 notes in codecs (#102407)
Irit Katriel [Tue, 21 Mar 2023 21:36:31 +0000 (21:36 +0000)] 
gh-102406: replace exception chaining by PEP-678 notes in codecs (#102407)

2 years agogh-94673: Isolate the _io module to Each Interpreter (gh-102663)
Eric Snow [Tue, 21 Mar 2023 20:01:38 +0000 (14:01 -0600)] 
gh-94673: Isolate the _io module to Each Interpreter (gh-102663)

Aside from sys and builtins, _io is the only core builtin module that hasn't been ported to multi-phase init.  We may do so later (e.g. gh-101948), but in the meantime we must at least take care of the module's static types properly.  (This came up while working on gh-101660.)

https://github.com/python/cpython/issues/94673

2 years agogh-102860: improve performance of compiler's instr_sequence_to_cfg (#102861)
Irit Katriel [Tue, 21 Mar 2023 19:13:49 +0000 (19:13 +0000)] 
gh-102860: improve performance of compiler's instr_sequence_to_cfg (#102861)

2 years agogh-98608: Fix Failure-handling in new_interpreter() (gh-102658)
Eric Snow [Tue, 21 Mar 2023 18:47:55 +0000 (12:47 -0600)] 
gh-98608: Fix Failure-handling in new_interpreter() (gh-102658)

The error-handling code in new_interpreter() has been broken for a while.  We hadn't noticed because those code mostly doesn't fail.  (I noticed while working on gh-101660.)  The problem is that we try to clear/delete the newly-created thread/interpreter using itself, which just failed.  The solution is to switch back to the calling thread state first.

https://github.com/python/cpython/issues/98608

2 years agoTweak polynomial itertool recipes (GH-102880)
Raymond Hettinger [Tue, 21 Mar 2023 18:21:57 +0000 (13:21 -0500)] 
Tweak polynomial itertool recipes (GH-102880)

2 years agogh-102304: Move the Total Refcount to PyInterpreterState (gh-102545)
Eric Snow [Tue, 21 Mar 2023 17:46:09 +0000 (11:46 -0600)] 
gh-102304: Move the Total Refcount to PyInterpreterState (gh-102545)

Moving it valuable with a per-interpreter GIL.  However, it is also useful without one, since it allows us to identify refleaks within a single interpreter or where references are escaping an interpreter.  This becomes more important as we move the obmalloc state to PyInterpreterState.

https://github.com/python/cpython/issues/102304

2 years agogh-102876: remove superfluous parens from itertools.batched recipe (GH-102877)
wim glenn [Tue, 21 Mar 2023 17:06:18 +0000 (12:06 -0500)] 
gh-102876: remove superfluous parens from itertools.batched recipe (GH-102877)

remove superfluous parens from itertools.batched recipe

2 years agogh-98608: Stop Treating All Errors from _Py_NewInterpreterFromConfig() as Fatal ...
Eric Snow [Tue, 21 Mar 2023 16:49:12 +0000 (10:49 -0600)] 
gh-98608: Stop Treating All Errors from _Py_NewInterpreterFromConfig() as Fatal (gh-102657)

Prior to this change, errors in _Py_NewInterpreterFromConfig() were always fatal.  Instead, callers should be able to handle such errors and keep going.  That's what this change supports.  (This was an oversight in the original implementation of _Py_NewInterpreterFromConfig().)  Note that the existing [fatal] behavior of the public Py_NewInterpreter() is preserved.

https://github.com/python/cpython/issues/98608

2 years agogh-102595: Document `PyObject_Format` c-api function (GH-102596)
Nikita Sobolev [Tue, 21 Mar 2023 16:46:24 +0000 (19:46 +0300)] 
gh-102595: Document `PyObject_Format` c-api function (GH-102596)

Def: https://github.com/python/cpython/blame/5ffdaf748d98da6065158534720f1996a45a0072/Include/abstract.h#L389

2 years agogh-102828: emit deprecation warning for onerror arg to shutil.rmtree (#102850)
Irit Katriel [Tue, 21 Mar 2023 11:08:46 +0000 (11:08 +0000)] 
gh-102828: emit deprecation warning for onerror arg to shutil.rmtree (#102850)

2 years agogh-102799: Let pydoc use the exception instead of sys.exc_info (#102830)
Irit Katriel [Tue, 21 Mar 2023 11:07:03 +0000 (11:07 +0000)] 
gh-102799: Let pydoc use the exception instead of sys.exc_info (#102830)

2 years agogh-102755: PyErr_DisplayException only in ABI >= 3.12. Tests cover PyErr_Display...
Irit Katriel [Tue, 21 Mar 2023 09:36:18 +0000 (09:36 +0000)] 
gh-102755: PyErr_DisplayException only in ABI >= 3.12. Tests cover PyErr_Display as well (GH-102849)