Commit Graph

7180 Commits

Author SHA1 Message Date
Mark Shannon 411b169281
GH-103082: Implementation of PEP 669: Low Impact Monitoring for CPython (GH-103083)
* The majority of the monitoring code is in instrumentation.c

* The new instrumentation bytecodes are in bytecodes.c

* legacy_tracing.c adapts the new API to the old sys.setrace and sys.setprofile APIs
2023-04-12 12:04:55 +01:00
AN Long dce2d38cb0
gh-103092: Isolate msvcrt (#103248) 2023-04-12 12:41:21 +02:00
Bar Harel 8f54302ab4
gh-103357: Add logging.Formatter defaults support to logging.config fileConfig and dictConfig (GH-103359) 2023-04-12 08:35:56 +01:00
Tian Gao 2f41a009b7
gh-103143: Polish pdb help messages and doc strings (GH-103144)
* Made all the command part of the docstring match the official documentation
* Always have a space between the command and the description in docstring
* Added a helper function to format the help message

Before:

```
(Pdb) h a
a(rgs)
        Print the argument list of the current function.
(Pdb) h commands
commands [bpnumber]
        (com) ...
        (com) end
        (Pdb)
        ...
(Pdb) h interact
interact

        Start an interactive interpreter whose global namespace
        contains all the (global and local) names found in the current scope.
```

After
```
(Pdb) h a
      Usage: a(rgs)
      
      Print the argument list of the current function.
(Pdb) h commands
      Usage: (Pdb) commands [bpnumber]
             (com) ...
             (com) end
             (Pdb)
             ...
(Pdb) h interact
      Usage: interact
      
      Start an interactive interpreter whose global namespace
      contains all the (global and local) names found in the current scope.
```

Automerge-Triggered-By: GH:brandtbucher
2023-04-11 15:40:30 -07:00
Stanislav Syekirin ebc8103427
gh-103088: Sanitize venv paths when using MSYS or Cygwin Bash (GH-103325) 2023-04-11 20:20:46 +01:00
Barney Gale b57105ae33
GH-103220: Fix `ntpath.join()` of partial UNC drive with trailing slash (GH-103221) 2023-04-11 17:26:45 +01:00
Irit Katriel 55c99d97e1
gh-77757: replace exception wrapping by PEP-678 notes in typeobject's __set_name__ (#103402) 2023-04-11 11:53:06 +01:00
Irit Katriel 78b763f630
gh-103176: sys._current_exceptions() returns mapping to exception instances instead of exc_info tuples (#103177) 2023-04-11 09:38:37 +01:00
David Ellis d034590294
gh-103000: Optimise dataclasses asdict/astuple for common types (#103005)
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-04-10 22:50:58 +01:00
AN Long f80014a9b0
gh-103092: Isolate winsound (#103249) 2023-04-10 23:01:05 +02:00
Barney Gale 2c673d5e93
GH-101362: Omit path anchor from `pathlib.PurePath()._parts` (GH-102476)
Improve performance of path construction by skipping the addition of the path anchor (`drive + root`) to the internal `_parts` list. Rename this attribute to `_tail` for clarity.
2023-04-09 18:40:03 +01:00
Erlend E. Aasland f329a8bc1e
gh-103092: Isolate `socket` module (#103094) 2023-04-09 06:33:52 +05:30
Dong-hee Na 35167043e3
gh-103242: Migrate SSLContext.set_ecdh_curve not to use deprecated APIs (#103378)
Migrate `SSLContext.set_ecdh_curve()` not to use deprecated OpenSSL APIs.
2023-04-08 10:56:42 -07:00
C.A.M. Gerlach a34c796238
gh-75729: Fix os.spawn tests not handling spaces on Windows (#99150)
* Quote paths in os.spawn tests on Windows so they work with spaces

* Add NEWS entry for os spawn test fix

* Fix code style to avoid double negative in os.spawn tests

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

---------

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-04-08 10:37:23 +03:00
Russell Keith-Magee 26c65980dc
gh-103329: Add regression test for PropertyMock with side effect (#103358) 2023-04-07 20:09:00 -06:00
Alex Waygood 644136563d
gh-74690: Document changes made to runtime-checkable protocols in 3.12 (#103348)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-04-07 22:06:37 +01:00
Michał Górny a90863c993
gh-100220: Fix error handling in make rules (GH-100328)
Set `SHELL = /bin/sh -e` to ensure that complex recipes fail on the first error rather than incorrectly reporting success.

Co-authored-by: Zachary Ware <zach@python.org>
2023-04-07 13:23:59 -05:00
Tian Gao 2667452945
gh-103225: Fixed zero lineno issue for pdb (#103265)
Co-authored-by: Artem Mukhin <ortem00@gmail.com>
2023-04-07 18:57:46 +01:00
AN Long 4dc339b4d6
GH-88013: Fix TypeError raised by ntpath.realpath in some cases (GH-102813) 2023-04-07 12:56:00 +01:00
Dong-hee Na efb0a2cf3a
gh-103256: Fix hmac algorithm to support fallback implementation (gh-103286)
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-04-07 10:51:29 +09:00
Brett Cannon 5d08c3ff7d
GH-102700: allow built-in modules to be submodules (GH-103162) 2023-04-06 14:19:54 -07:00
Jeffrey Newman 23cf1e20a6
gh-99202: Fix extension type from documentation for compiling in C++20 mode (#102518) 2023-04-06 17:59:36 +02:00
Ethan Furman 4ec8dd10bd
gh-93910: [Enum] remove member.member deprecation (GH-103236)
i.e. Color.RED.BLUE is now officially supported.
2023-04-05 17:33:52 -07:00
Brandt Bucher b4978ff872
GH-88691: Shrink the CALL caches (GH-103230) 2023-04-05 14:15:49 -07:00
Joshua Root 96e1901a59
gh-99069: Consolidate checks for static_assert (#94766)
Several platforms don't define the static_assert macro despite having
compiler support for the _Static_assert keyword. The macro needs to be
defined since it is used unconditionally in the Python code. So it
should always be safe to define it if undefined and not in C++11 (or
later) mode.

Hence, remove the checks for particular platforms or libc versions,
and just define static_assert anytime it needs to be defined but isn't.
That way, all platforms that need the fix will get it, regardless of
whether someone specifically thought of them.

Also document that certain macOS versions are among the platforms that
need this.

The C2x draft (currently expected to become C23) makes static_assert
a keyword to match C++. So only define the macro for up to C17.

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-04-05 17:09:19 +02:00
Yeojin Kim 8f70b16e33
gh-86094: Add support for Unicode Path Extra Field in ZipFile (gh-102566) 2023-04-05 20:54:48 +09:00
Alex Waygood 264c00a1c5
gh-103193: Micro-optimise helper functions for `inspect.getattr_static` (#103195) 2023-04-05 08:27:01 +01:00
Michael Handler 1a8f862e32
gh-66897: Upgrade HTTP CONNECT to protocol HTTP/1.1 (#8305)
* bpo-22708: Upgrade HTTP CONNECT to protocol HTTP/1.1 (GH-NNNN)

Use protocol HTTP/1.1 when sending HTTP CONNECT tunnelling requests;
generate Host: headers if one is not already provided (required by
HTTP/1.1), convert IDN domains to punycode in HTTP CONNECT requests.

* Refactor tests to pass under -bb (fix ByteWarnings); missed some lines >80.

* Use consistent 'tunnelling' spelling in Lib/http/client.py

* Lib/test/test_httplib: Remove remnant of obsoleted test.

* Use dict.copy() not copy.copy()

* fix version changed

* Update Lib/http/client.py

Co-authored-by: bgehman <bgehman@users.noreply.github.com>

* Switch to for/else: syntax, as suggested

* Don't use for: else:

* Sure, fine, w/e

* Oops

* 1nm to the left

---------

Co-authored-by: Éric <merwok@netwok.org>
Co-authored-by: bgehman <bgehman@users.noreply.github.com>
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
2023-04-04 21:55:24 -07:00
Charles Machalow 935aa45235
GH-75586: Make shutil.which() on Windows more consistent with the OS (GH-103179) 2023-04-04 23:24:13 +01:00
Ned Deily f184abbdc9
gh-103207: Add instructions to the macOS installer welcome display on how to workaround the macOS 13 Ventura “The installer encountered an error” failure. (GH-103251) 2023-04-04 17:06:00 -04:00
Thomas Wouters 30f82cf6c9 Merge branch 'main' of https://github.com/python/cpython into main 2023-04-04 22:01:07 +02:00
Steve Dower fd1947ecfb
bpo-44844: Enable detection of Microsoft Edge browser in webbrowser module (GH-29908) 2023-04-04 17:00:03 +01:00
Thomas Wouters b861ba4a82 Python 3.12.0a7 2023-04-04 17:52:42 +02:00
Erlend E. Aasland c00dcf0e38
gh-103092: Isolate `_pickle` module (#102982)
Co-authored-by: Mohamed Koubaa <koubaa.m@gmail.com>
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2023-04-04 15:38:54 +05:30
Barney Gale 11c302055a
GH-76846, GH-85281: Call `__new__()` and `__init__()` on pathlib subclasses (GH-102789)
Fix an issue where `__new__()` and `__init__()` were not called on subclasses of `pathlib.PurePath` and `Path` in some circumstances.

Paths are now normalized on-demand. This speeds up path construction, `p.joinpath(q)`, and `p / q`.

Co-authored-by: Steve Dower <steve.dower@microsoft.com>
2023-04-03 19:57:11 +01:00
Nikita Sobolev 2a721258a1
gh-101865: Deprecate `co_lnotab` from code objects as per PEP 626 (#101866)
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
2023-04-03 17:35:04 +02:00
Shantanu 385b5d6e09
gh-102038: Skip a sometimes unnecessary stat in site.py (#102039) 2023-04-02 15:47:31 -07:00
Giampaolo Rodola 6883007a86
bpo-4080: unittest durations (#12271) 2023-04-03 00:12:51 +02:00
Alex Waygood 6d59c9e32e
gh-102433: Use `inspect.getattr_static` in `typing._ProtocolMeta.__instancecheck__` (#103034) 2023-04-02 14:22:19 +01:00
Irit Katriel 06249ec89f
gh-102192: deprecate _PyErr_ChainExceptions (#102935) 2023-04-01 21:30:23 +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
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
Jeong, YunWon 21e9de3bf0
gh-103085: Fix python locale.getencoding not to emit deprecation warning (gh-103086) 2023-03-31 01:23:43 +09:00
Brandt Bucher 121057aa36
GH-89987: Shrink the BINARY_SUBSCR caches (GH-103022) 2023-03-29 15:53:30 -07: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
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 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
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
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
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
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
MonadChains 413b7db8a4
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.
2023-03-23 17:42:43 -06:00
Brandt Bucher 0444ae2487
GH-100982: Break up COMPARE_AND_BRANCH (GH-102801) 2023-03-23 15:25:09 -07:00
Nikita Sobolev adb0621652
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>
2023-03-23 16:26:11 +00:00
Alex Waygood baf4eb083c
gh-102947: Improve traceback when calling `fields()` on a non-dataclass (#102948) 2023-03-23 14:17:54 +00:00
Irit Katriel 3468c768ce
gh-102859: Remove JUMP_IF_FALSE_OR_POP and JUMP_IF_TRUE_OR_POP (#102870) 2023-03-22 18:10:48 +00:00
Kristján Valur Jónsson 04adf2df39
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>
2023-03-22 10:52:10 -07:00
Mark Shannon 7559f5fda9
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().
2023-03-22 14:49:51 +00:00
Stanislav Zmiev 713df2c534
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>
2023-03-22 14:45:25 +00:00
Benjamin Fogle af9c34f6ef
gh-96931: Fix incorrect results in ssl.SSLSocket.shared_ciphers (#96932) 2023-03-22 15:08:41 +01:00
Max Bachmann ea93bde4ec
gh-102027: Fix macro name (#102124)
This fixes the ssse3 / sse2 detection when sse4 is available.

Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
2023-03-22 14:44:28 +01:00
Icelain 3d7eb66c96
gh-101313: Add -h and --help arguments to the webbrowser module (gh-101374) 2023-03-22 21:19:52 +09:00
David Benjamin 420bbb783b
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?)
2023-03-22 13:16:26 +01:00
Sergey B Kirpichev d1a89ce515
gh-102839: remove AC for math.log (GH-102863) 2023-03-21 18:48:19 -05:00
Irit Katriel 76350e85eb
gh-102406: replace exception chaining by PEP-678 notes in codecs (#102407) 2023-03-21 21:36:31 +00:00
Nikita Sobolev ef000eb3e2
gh-102809: Remove `Misc/gdbinit` (#102854)
Looks like the consensus is that we don't need this file anymore.
Old version can be always found here: 094cf392f4/Misc/gdbinit
2023-03-20 16:30:46 -07:00
Alan Williams 5e6661bce9
gh-72346: Added isdst deprecation warning to email.utils.localtime (GH-91450) 2023-03-19 19:20:20 -05:00
Pieter Eendebak 382ee2f0f2
gh-102491: Remove IronPython version check in sys_version (#102492) 2023-03-19 15:52:47 -07:00
Irit Katriel d51a6dc28e
gh-102828: add onexc arg to shutil.rmtree. Deprecate onerror. (#102829) 2023-03-19 18:33:51 +00:00
Irit Katriel e1e9bab006
gh-102778: Add sys.last_exc, deprecate sys.last_type, sys.last_value,sys.last_traceback (#102779) 2023-03-18 11:47:11 +00:00
gaogaotiantian 039714d00f
gh-101975: Fixed a potential SegFault on garbage collection (GH-102803) 2023-03-18 10:59:21 +00:00
Inada Naoki 65fb7c4055
gh-102701: Fix overflow in dictobject.c (GH-102750) 2023-03-17 22:39:09 +09:00
Kumar Aditya 4f5774f648
GH-78530: add support for generators in `asyncio.wait` (#102761) 2023-03-17 06:58:43 +05:30
Irit Katriel 3f9285a8c5
gh-102755: Add PyErr_DisplayException(exc) (#102756) 2023-03-16 22:18:04 +00:00
Steve Dower 0f175766e2
gh-99726: Improves correctness of stat results for Windows, and uses faster API when available (GH-102149)
This deprecates `st_ctime` fields on Windows, with the intent to change them to contain the correct value in 3.14. For now, they should keep returning the creation time as they always have.
2023-03-16 17:27:21 +00:00
Kumar Aditya adaed17341
GH-102748: remove legacy support for generator based coroutines from `asyncio.iscoroutine` (#102749)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-03-16 20:28:10 +05:30
Irit Katriel 51d693c584
gh-102594: PyErr_SetObject adds note to exception raised on normalization error (#102675) 2023-03-16 10:16:01 +00:00
yonatanp 2dc94634b5
gh-94440: Fix issue of ProcessPoolExecutor shutdown hanging (#94468)
Fix an issue of concurrent.futures ProcessPoolExecutor shutdown hanging.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-03-15 21:44:52 -07:00
Kumar Aditya a44553ea9f
GH-100112: avoid using iterable coroutines in asyncio internally (#100128) 2023-03-16 09:20:43 +05:30
Jamoo721 1c9f3391b9
gh-102690: Use Edge as fallback in webbrowser instead of IE (#102691) 2023-03-15 22:52:11 -04:00
Max Bachmann afa6092ee4
gh-102281: Fix potential nullptr dereference + use of uninitialized memory (gh-102282) 2023-03-15 21:58:43 +09:00
Nikita Sobolev 2b5781d659
gh-102615: Use `list` instead of `tuple` in `repr` of paramspec (#102637)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-03-15 09:33:41 +00:00
Tom Levy 8647ba4b63
Remove misformatted exclamation marks in docs (#102694)
Remove the exclamation mark from :program:`!foo` in .rst files because
it inadvertently shows up in the rendered HTML.

(Sphinx's cross-referencing roles use a '!' prefix to suppress
hyperlinking[1], but :program: is not a cross-referencing role so the
'!' is displayed verbatim.)

The exclamation marks in venv.rst were introduced in #98350. See
comments [2] and [3] for additional discussion.

[1]: https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#cross-referencing-syntax
[2]: https://github.com/python/cpython/pull/98350#issuecomment-1285965759
[3]: https://github.com/python/cpython/pull/98350#issuecomment-1286394047

Reported-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
2023-03-15 09:06:32 +02:00
Andre Hora 5e0865f22e
gh-101377: improving test_locale_calendar_formatweekday of calendar (#101378)
---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2023-03-14 22:36:31 -04:00
Jacob Bower cbd3fbfb6e
gh-102013: Add PyUnstable_GC_VisitObjects (#102014) 2023-03-14 01:35:54 +00:00
Raymond Hettinger 457e4d1a51
GH-102670: Use sumprod() to simplify, speed up, and improve accuracy of statistics functions (GH-102649) 2023-03-13 20:06:43 -05:00
Nikita Sobolev d97757f793
gh-102069: Fix `__weakref__` descriptor generation for custom dataclasses (#102075) 2023-03-13 15:42:05 -06:00
T 71e37d9079
gh-98169 dataclasses.astuple support DefaultDict (#98170)
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
2023-03-13 14:46:35 -06:00
Mark Shannon 233e32f936
GH-102300: Reuse objects with refcount == 1 in float specialized binary ops. (GH-102301) 2023-03-13 10:34:54 +00:00
gaogaotiantian 5d677c556f
GH-101673: Fix pdb bug where local variable changes are lost after longlist (#101674) 2023-03-12 23:09:55 +00:00
Виталий Дмитриев f6ca71a422
Fix duplicated words in the docs (GH-102629)
With grep utility found some duplicated words

Automerge-Triggered-By: GH:AlexWaygood
2023-03-12 11:03:59 -07:00
Thomas Krennwallner ced13c96a4
gh-79940: add introspection API for asynchronous generators to `inspect` module (#11590) 2023-03-11 18:49:40 +05:30
wangxiang-hz aa0a73d1bc
gh-102213: Optimize the performance of `__getattr__` (GH-102248)
When __getattr__ is defined, python with try to find an attribute using _PyObject_GenericGetAttrWithDict
find nothing is reasonable so we don't need an exception, it will hurt performance.
2023-03-11 19:11:37 +08:00
Brandt Bucher 08b67fb34f
GH-90997: Shrink the LOAD_GLOBAL caches (#102569) 2023-03-10 17:01:16 -08:00
Nikita Sobolev b48be8fa18
gh-102103: add `module` argument to `dataclasses.make_dataclass` (#102104) 2023-03-10 17:26:46 -07:00
Xuehai Pan ee6f8413a9
gh-102578: Optimise setting and deleting mutable attributes on non-dataclass subclasses of frozen dataclasses (gh-102573) 2023-03-10 19:21:22 -05:00
Barney Gale 90f1d77717
GH-80486: Fix handling of NTFS alternate data streams in pathlib (GH-102454)
Co-authored-by: Maor Kleinberger <kmaork@gmail.com>
2023-03-10 17:29:04 +00:00
Paul Ganssle 64bde502cf
GH-102537: Handle check for PYTHONTZPATH failing in zoneinfo test (GH-102538)
It is possible but unlikely for the `python_tzpath_context` function to fail between the start of the `try` block and the point where `os.environ.get` succeeds, in which case `old_env` will be undefined. In this case, we want to take no action.

Practically speaking this will really only happen in an error condition anyway, so it doesn't really matter, but we should probably do it right anyway.
2023-03-10 07:29:37 -08:00
Steve Dower cb35882773
gh-102519: Add os.listdrives, os.listvolumes and os.listmounts on Windows (GH-102544) 2023-03-10 12:21:37 +00:00
David Hewitt 71cf7c3ddd
gh-102378: don't bother stripping `/` from __text_signature__ (#102379) 2023-03-09 15:06:20 -08:00
Max Bachmann c6858d1e7f
gh-102255: Improve build support for Windows API partitions (GH-102256)
Add `MS_WINDOWS_DESKTOP`, `MS_WINDOWS_APPS`, `MS_WINDOWS_SYSTEM` and `MS_WINDOWS_GAMES` preprocessor definitions to allow switching off functionality missing from particular API partitions ("partitions" are used in Windows to identify overlapping subsets of APIs).
CPython only officially supports `MS_WINDOWS_DESKTOP` and `MS_WINDOWS_SYSTEM` (APPS is included by normal desktop builds, but APPS without DESKTOP is not covered). Other configurations are a convenience for people building their own runtimes.
`MS_WINDOWS_GAMES` is for the Xbox subset of the Windows API, which is also available on client OS, but is restricted compared to `MS_WINDOWS_DESKTOP`. These restrictions may change over time, as they relate to the build headers rather than the OS support, and so we assume that Xbox builds will use the latest available version of the GDK.
2023-03-09 21:09:12 +00:00
Kumar Aditya 1a84cc007e
GH-102397: Fix segfault from race condition in signal handling (#102399)
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-03-08 13:29:39 +05:30
Thomas Wouters f9774e57d8 Python 3.12.0a6 2023-03-07 22:48:18 +01:00
Irit Katriel a33ca2ad1f
gh-102493: fix normalization in PyErr_SetObject (#102502)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-03-07 13:27:46 -08:00
Pablo Galindo Salgado f533f216e6
gh-102416: Do not memoize incorrectly loop rules in the parser (#102467) 2023-03-06 14:41:53 +01:00
Barney Gale 6716254e71
GH-101362: Optimise PurePath(PurePath(...)) (GH-101667)
The previous `_parse_args()` method pulled the `_parts` out of any supplied `PurePath` objects; these were subsequently joined in `_from_parts()` using `os.path.join()`. This is actually a slower form of joining than calling `fspath()` on the path object, because it doesn't take advantage of the fact that the contents of `_parts` is normalized!

This reduces the time taken to run `PurePath("foo", "bar")` by ~20%, and the time taken to run `PurePath(p, "cheese")`, where `p = PurePath("/foo", "bar", "baz")`, by ~40%.

Automerge-Triggered-By: GH:AlexWaygood
2023-03-05 15:50:21 -08:00
Barney Gale 3e60e0213e
GH-101362: Check pathlib.Path flavour compatibility at import time (GH-101664)
This saves a comparison in `pathlib.Path.__new__()` and reduces the time taken to run `Path()` by ~5%.

Automerge-Triggered-By: GH:AlexWaygood
2023-03-05 14:46:45 -08:00
Barney Gale 3572c861d8
GH-101362: Call join() only when >1 argument supplied to pathlib.PurePath() (#101665)
GH-101362: Call join() only when >1 argument supplied to pathlib.PurePath

This reduces the time taken to run `PurePath("foo")` by ~15%
2023-03-05 22:00:56 +00:00
Yeojin Kim 9a478be1a4
gh-101979: argparse: fix a bug where parentheses in metavar argument of add_argument() were dropped (#102318) 2023-03-05 06:54:33 -08:00
Marta Gómez Macías 66aa78cbe6
gh-102356: Add thrashcan macros to filter object dealloc (#102426)
Add thrashcan macros to the deallocator of the filter objects to protect against deeply nested destruction of chains of nested filters.
2023-03-05 12:00:41 +01:00
Matthias Görgens eff9f43924
gh-96821: Add config option `--with-strict-overflow` (#96823)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Shantanu <hauntsaninja@gmail.com>
2023-03-04 13:39:52 -08:00
Jaysinh Shukla 81763341ed
gh-63301: Set exit code when tabnanny CLI exits on error (#7699)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-03-04 13:32:13 -08:00
Gouvernathor 90801e48fd
gh-102302 Micro-optimize `inspect.Parameter.__hash__` (#102303) 2023-03-04 15:08:57 +00:00
Alexey Izbyshev c2bd55d26f
gh-102179: Fix `os.dup2` error reporting for negative fds (#102180) 2023-03-04 19:54:08 +05:30
Raj 705487c655
gh-101892: Fix `SystemError` when a callable iterator call exhausts the iterator (#101896)
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
2023-03-04 19:51:29 +05:30
Max Bachmann c1748ed59d
gh-102344: Reimplement winreg QueryValue / SetValue using QueryValueEx / SetValueEx (GH-102345)
The newer APIs are more widely available than the old ones, and are called in a way to preserve functionality.
2023-03-01 14:50:38 +00:00
Max Bachmann 938e36f824
gh-102336: Remove code specifically for handling Windows 7 (GH-102337) 2023-03-01 00:31:21 +00:00
Petr Viktorin 6b2d7c0ddb
gh-101101: Unstable C API tier (PEP 689) (GH-101102) 2023-02-28 09:31:01 +01:00
Steven Troxler 0f89acf6cc
gh-101561: Add typing.override decorator (#101564)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-02-27 13:16:11 -08:00
Sergey B Kirpichev 4f3786b761
gh-101773: Optimize creation of Fractions in private methods (#101780)
This PR adds a private `Fraction._from_coprime_ints` classmethod for internal creations of `Fraction` objects, replacing the use of `_normalize=False` in the existing constructor. This speeds up creation of `Fraction` objects arising from calculations. The `_normalize` argument to the `Fraction` constructor has been removed.

Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
2023-02-27 18:53:22 +00:00
Dennis Sweeney e3c3f9fec0
gh-102250: Fix double-decref in COMPARE_AND_BRANCH error case (GH-102287) 2023-02-27 10:46:40 +00:00
Rotzbua f3cb15c88a
gh-91038: Change default argument value to `False` instead of `0` (#31621)
The argument is used as a switch and corresponds to a boolean logic. Therefore it is more intuitive to use the corresponding constant `False` as default value instead of the integer `0`.

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
2023-02-26 18:10:34 -08:00
Pradyun Gedam 89d9ff0f48
gh-101997: Update bundled pip version to 23.0.1 (#101998) 2023-02-25 12:00:12 +00:00
Kumar Aditya 5f11478ce7
GH-102126: fix deadlock at shutdown when clearing thread states (#102222) 2023-02-25 12:21:36 +05:30
Ionite 54dfa14c5a
gh-101765: Fix SystemError / segmentation fault in iter `__reduce__` when internal access of `builtins.__dict__` exhausts the iterator (#101769) 2023-02-24 15:02:04 -08:00
Max Bachmann 1fa38906f0
gh-102141: replace use of getpid on Windows with GetCurrentProcessId (GH-102142) 2023-02-24 12:38:21 +00:00
Yeojin Kim 347f7406df
gh-81652: Add MAP_ALIGNED_SUPER FreeBSD and MAP_CONCEAL OpenBSD constants (gh-102191) 2023-02-24 19:26:51 +09:00
Jacob Bower 0c857865e4
Fix deadlock on shutdown if test_current_{exception,frames} fails (#102019)
* Don't deadlock on shutdown if test_current_{exception,frames} fails

These tests spawn a thread that waits on a threading.Event. If the test fails any of its assertions, the Event won't be signaled and the thread will wait indefinitely, causing a deadlock when threading._shutdown() tries to join all outstanding threads.

Co-authored-by: Brett Simmers <bsimmers@meta.com>

* Add a news entry

* Fix whitespace

---------

Co-authored-by: Brett Simmers <bsimmers@meta.com>
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
2023-02-23 14:57:06 -08:00
Zackery Spytz 665730d217
bpo-23224: Fix segfaults and multiple leaks in the lzma and bz2 modules (GH-7822)
lzma.LZMADecompressor and bz2.BZ2Decompressor objects caused
segfaults when their `__init__()` methods were not called.

lzma.LZMADecompressor, lzma.LZMACompressor, bz2.BZ2Compressor,
and bz2.BZ2Decompressor objects would leak locks and internal buffers
when their `__init__()` methods were called multiple times.


https://bugs.python.org/issue23224
2023-02-23 06:00:58 -08:00
Erlend E. Aasland 5b9573eed4
gh-101578: Fixup NEWS and add What's New entry for new exception APIs (#102157) 2023-02-23 13:19:21 +01:00
Mark Shannon 22b8d77b98
GH-100719: Remove redundant `gi_code` field from generator object. (GH-100749) 2023-02-23 10:19:01 +00:00
Irit Katriel 572223f9ce
Revert "bpo-46978: Correct docstrings for in-place builtin operators #31802) (#102146)
Revert "bpo-46978: Correct docstrings for in-place builtin operators (#31802)"

This reverts commit 128379b8cd.
2023-02-23 10:17:44 +00:00
Carl Meyer 056dfc71dc
gh-87634: remove locking from functools.cached_property (GH-101890)
Remove the undocumented locking capabilities of functools.cached_property.
2023-02-22 17:49:22 -08:00
Jonathan Protzenko fcadc7e405
gh-99108: Import MD5 and SHA1 from HACL* (#102089)
Replaces our fallback non-OpenSSL MD5 and SHA1 implementations with those from HACL* as we've already done with SHA2.
2023-02-22 13:18:43 -08:00
Mark Shannon 7c106a443f
GH-100982: Restrict `FOR_ITER_RANGE` to a single instruction to allow instrumentation. (GH-101985) 2023-02-22 11:11:57 +00:00
Eli Schwartz 3ba7743b06
gh-99942: python.pc on android/cygwin should link to libpython per configure.ac (GH-100356)
In commit 254b309c80 a previous change to avoid linking to libpython was partially reverted for Android (and later Cygwin as well), to add back the link flags. This was applied to distutils and to python-config.sh, but not to python.pc.

Add it back to python.pc as well.

Automerge-Triggered-By: GH:gpshead
2023-02-21 17:21:24 -08:00
Vo Hoang Long 0d4c7fcd4f
gh-101936: Update the default value of fp from io.StringIO to io.BytesIO (gh-102100)
Co-authored-by: Long Vo <long.vo@linecorp.com>
2023-02-22 00:14:41 +09:00
Gihwan Kim 6f25657b83
gh-101961 fileinput.hookcompressed should not set the encoding value for the binary mode (gh-102068) 2023-02-21 12:10:29 +09:00
Irit Katriel 022b44f254
gh-102056: Fix a few bugs in error handling of exception printing code (#102078) 2023-02-20 22:16:09 +00:00
Jason R. Coombs 36854bbb24
gh-101566: Sync with zipp 3.14. (GH-102018) 2023-02-20 13:01:58 -08:00
Tim Hatch 59e86caca8
gh-88233: zipfile: handle extras after a zip64 extra (GH-96161)
Previously, any data _after_ the zip64 extra would be removed.

With many new tests.

Fixes #88233

Automerge-Triggered-By: GH:jaraco
2023-02-20 09:07:03 -08:00
Steve Dower a99eb5cd99
gh-101907: Stop using `_Py_OPCODE` and `_Py_OPARG` macros (GH-101912)
* gh-101907: Removes use of non-standard C++ extension from Include/cpython/code.h

* Make cases_generator correct on Windows
2023-02-20 14:56:48 +00:00
Mark Dickinson b1b375e267
gh-97786: Fix compiler warnings in pytime.c (#101826)
Fixes compiler warnings in pytime.c.
2023-02-19 17:16:11 -08:00