Commit graph

116409 commits

Author SHA1 Message Date
Irit Katriel 848bdbe166
gh-102192: use PyErr_SetHandledException instead of the legacy PyErr_SetExcInfo (#103157) 2023-04-01 10:31:48 +05:30
Brett Cannon d97aef8ebf
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.
2023-03-31 14:23:55 -07:00
Alex Waygood 361a3eaf1b
gh-74690: Micro-optimise typing._get_protocol_attrs (#103152)
Improve performance of `isinstance()` checks against runtime-checkable protocols
2023-03-31 21:54:50 +01:00
Ethan Furman 2a4d8c0a9e
gh-102549: [Enum] fail enum creation when data type raises in __init__ (GH-103149) 2023-03-31 13:52:31 -07:00
Eric Snow dfc4c95762
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.
2023-03-31 12:18:33 -06:00
Eric Snow dde028480e
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.
2023-03-31 12:09:10 -06:00
Alex Waygood 9048d73f7a
gh-74690: typing: Don't unnecessarily call _get_protocol_attrs twice in _ProtocolMeta.__instancecheck__ (#103141)
Speed up `isinstance()` calls against runtime-checkable protocols
2023-03-31 18:37:24 +01:00
Irit Katriel 80163e17d3
gh-87092: move CFG related code from compile.c to flowgraph.c (#103021) 2023-03-31 18:17:59 +01:00
James De Bias b0422e140d
gh-102871: Remove obsolete browsers from webbrowser (#102872) 2023-03-31 11:02:47 -04:00
Furkan Onder 048d6243d4
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>
2023-03-31 09:54:17 -04:00
Petr Viktorin f6405a4662
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/
2023-03-31 14:40:38 +02:00
Hugo van Kemenade 20c0f196ff
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
2023-03-31 03:48:46 -07:00
Irit Katriel 44bd3fe570
gh-102799: use exception instance instead of sys.exc_info() (#102885) 2023-03-31 11:23:02 +01:00
gaogaotiantian c1e71ce56f
Minor docs improvements fix for codeop (#103123) 2023-03-30 15:51:36 -07:00
Missoupro 01a49d1745
gh-102110: Add all tools description missed (GH-102625)
Added missing descriptions of some tools.

Automerge-Triggered-By: GH:hugovk
2023-03-30 13:49:07 -07:00
Brian Haley ecc5441505
Add IPv6 into to the docstring for socket.getsockname (#102961)
Signed-off-by: Brian Haley <haleyb.dev@gmail.com>
2023-03-30 11:40:58 -07:00
Hugo van Kemenade f192a558f5
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>
2023-03-30 21:03:50 +03:00
Jeong, YunWon 21e9de3bf0
gh-103085: Fix python locale.getencoding not to emit deprecation warning (gh-103086) 2023-03-31 01:23:43 +09:00
Shantanu fda95aa194
gh-103099: Link mypy docs from typing.rst (#103100) 2023-03-30 01:32:09 -07:00
Eric Snow dcd6f226d6
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
2023-03-29 17:15:43 -06:00
Brandt Bucher 121057aa36
GH-89987: Shrink the BINARY_SUBSCR caches (GH-103022) 2023-03-29 15:53:30 -07:00
Eric Snow e647dbaded
gh-90110: Bring the whitelists up to date. (gh-103114)
https://github.com/python/cpython/issues/90110
2023-03-29 16:08:40 -06:00
Brett Cannon 0b1d9c44f1
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>
2023-03-29 13:28:08 -07:00
Bernhard Wagner d052a383f1
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>
2023-03-29 15:21:56 -04:00
gaogaotiantian e375bff037
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>
2023-03-29 12:09:12 +02:00
Matěj Cepl d835b3f05d
gh-102582: Fix invalid JSON in Doc/howto/logging-cookbook.rst (GH-102635) 2023-03-29 09:52:53 +01:00
Nikita Sobolev 60bdc16b45
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>
2023-03-28 20:04:26 -07:00
Steve Dower 24ba507b1d
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.
2023-03-29 00:47:13 +01:00
Eric Snow ba65a065cf
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
2023-03-28 12:52:28 -06:00
Chenxi Mao 7703def37e
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>
2023-03-28 10:52:22 +02:00
Ethan Furman f4ed2c6ae5
gh-102558: [Enum] better handling of non-Enum EnumType classes (GH-103060) 2023-03-27 16:26:16 -07:00
Ethan Furman b838d80085
gh-103056: [Enum] ensure final _generate_next_value_ is a staticmethod (GH-103062) 2023-03-27 16:25:19 -07:00
Oleg Iarygin 56d055a0d8
gh-74468: [tarfile] Fix incorrect name attribute of ExFileObject (GH-102424)
Co-authored-by: Simeon Visser <svisser@users.noreply.github.com>
2023-03-27 16:21:07 -07:00
Eric Snow 89e67ada69
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.
2023-03-27 16:53:05 -06:00
gaogaotiantian 34eb6f7276
gh-103046: Display current line correctly for dis.disco() with CACHE entries (#103047) 2023-03-27 23:22:06 +01:00
gaogaotiantian 3606753246
gh-103023: Add SyntaxError check in pdb's display command (#103024)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2023-03-27 22:37:22 +02:00
Nikita Sobolev 2cdc5189a6
gh-102941: Fix "‘subobj’ may be used uninitialized in this function" warning in bytes_methods.c (#102942) 2023-03-26 17:05:06 -07:00
Matthias Görgens 30a306c2ad
Fix typo in _swappedbytes_ in ctypes comment (#102773)
It's a minor typo, but it makes for a misleading comment.  Let's fix it.
2023-03-25 16:38:24 -07:00
Shantanu 718e86671f
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
2023-03-25 14:40:11 -07:00
gaogaotiantian 027223db96
Update pdb docs for arguments (#102965) 2023-03-25 14:31:45 -07:00
Liyang Zhang 11ed70b1dc
Fix typos in faulthandler, testcapi error messages (#103020) 2023-03-25 14:27:02 -07:00
Nikita Sobolev 8ec6486462
gh-103027: Update dataclass.make_dataclass docstring (gh-103028)
* gh-103027: Update `dataclass.make_dataclass` docstring
2023-03-25 15:36:38 -04:00
Peter Jiping Xie 0708437ad0
gh-103025: fix two ctypes doc issues (#103026) 2023-03-25 09:12:00 +00:00
Raymond Hettinger 1fd603fad2
GH-102833: Mention the key function in the docstrings (GH-103009) 2023-03-25 02:19:20 -05:00
Hugo van Kemenade 87adc63d66
gh-101100: Test only Doc/ files in nit-picky mode (#103019)
gh-101100: Filter only Doc/ files
2023-03-25 09:15:02 +02:00
JakobDev 64cb1a4f0f
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>
2023-03-24 14:52:06 -07:00
gaogaotiantian ded9a7fc19
gh-102980: Add tests for pdf's display, alias and where commands (#102981) 2023-03-24 20:50:06 +00:00
Amin Alaee f2e5a6ee62
gh-102873: logging.LogRecord docs: improve description of msg parameter (#102875)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-03-24 15:00:32 +00:00
David Benjamin acfe02f3b0
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
2023-03-24 06:04:30 -07:00
Hugo van Kemenade 6a1c49a717
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>
2023-03-24 13:23:35 +02:00