Commit Graph

124823 Commits

Author SHA1 Message Date
Kirill Podoprigora d9ed42bc00
gh-128201: Fix ``DeprecationWarning`` in ``test_pdb`` (#128202) 2024-12-25 12:56:51 +05:30
Will Childs-Klein 418114c139
gh-128035: Add ssl.HAS_PHA to detect libssl PHA support (GH-128036)
* Add ssl.HAS_PHA to detect libssl Post-Handshake-Auth support

Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-12-24 18:29:27 +00:00
Bogdan Romanyuk 7985d460c7
gh-128227: Regenerate `Doc/requirements-oldest-sphinx.txt` (#128228) 2024-12-24 20:00:24 +02:00
Dima Ryazanov 7ed6c5c696
gh-127847: Fix position in the special-cased zipfile seek (#127856)
---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
2024-12-24 15:56:42 +00:00
Kumar Aditya 9fce906825
gh-127949: deprecate `asyncio.set_event_loop` (#128218)
Deprecate `asyncio.set_event_loop` to be removed in Python 3.16.
2024-12-24 19:24:28 +05:30
Sergey Muraviov 3ddd70ceaa
gh-128217: Validate the normalized_environment variable instead of the similarly named function (GH-128220) 2024-12-24 13:06:41 +00:00
AraHaan bd3e200cce
Add Windows version comments to the python manifest. (GH-127439) 2024-12-24 13:01:21 +00:00
Kumar Aditya a391d80f4b
gh-127949: deprecate asyncio policy classes (#128216) 2024-12-24 17:30:26 +05:30
Thomas Grainger 3f6a618e49
gh-127949: fix `DeprecationWarning` in test_inspect.py (#128215) 2024-12-24 15:13:31 +05:30
Yan Yanchii 30efede33c
gh-128195: Add `_REPLACE_WITH_TRUE` to the tier2 optimizer (GH-128203)
Add `_REPLACE_WITH_TRUE` to the tier2 optimizer
2024-12-24 05:17:47 +08:00
Barney Gale d61542b5ff
pathlib tests: create test hierarchy without using class under test (#128200)
In the pathlib tests, avoid using the path class under test (`self.cls`) in
test setup. Instead we use `os` functions in `test_pathlib`, and direct
manipulation of `DummyPath` internal data in `test_pathlib_abc`.
2024-12-23 17:22:15 +00:00
Donghee Na c5b0c90b62
gh-115999: Update test_opcache to test with nested method (gh-128166)
gh-115999: Update test_opcace to test with nested method
2024-12-24 02:08:34 +09:00
T. Wouters 180d417e9f
gh-114203: Optimise simple recursive critical sections (#128126)
Add a fast path to (single-mutex) critical section locking _iff_ the mutex
is already held by the currently active, top-most critical section of this
thread. This can matter a lot for indirectly recursive critical sections
without intervening critical sections.
2024-12-23 13:31:33 +01:00
Alyssa Coghlan 831b6de6d7
gh-126180: Remove getopt and optparse deprecation notices (GH-126227)
* Remove getopt and optparse deprecation notices
* Add new docs sections for command line app helper libraries
* Add guidance on choosing a CLI parsing library to the optparse docs
* Link to the new guidance from the argparse and getopt docs
* Reword intro in docs section for superseded stdlib modules
* Reframe the optparse->argparse guide as a migration guide
  rather than as an upgrade guide

---------

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-12-23 14:17:19 +10:00
Zanie Blue 9d3a8f4949
gh-100384: Error on `unguarded-availability` in macOS builds (#128155)
Generate a build error on ``unguarded-availability`` in portable macOS builds (i.e. using MACOSX_DEPLOYMENT_TARGET), preventing invalid use of symbols that are not available in older versions of the OS.
2024-12-22 11:01:45 -08:00
Yan Yanchii f420bdd29f
gh-119786: Fix typos in `InternalDocs/interpreter.md` (#128174) 2024-12-22 18:34:16 +02:00
Thomas Grainger b66a4ad9fc
gh-127949: fix resource warnings in `test_tasks.py` (#128172) 2024-12-22 18:16:02 +05:30
Gregory P. Smith 228f275737
gh-126664: revert: Use `else` instead of `finally` in docs explaining "with" (#128169)
Revert "gh-126664: Use `else` instead of `finally` in "The with statement" documentation. (GH-126665)"

This reverts commit 25257d61cf.
2024-12-22 09:47:41 +00:00
Barney Gale 8d9f52a7be
GH-127807: pathlib ABCs: move private copying methods to dedicated class (#127810)
Move 9 private `PathBase` attributes and methods into a new `CopyWorker`
class. Change `PathBase.copy` from a method to a `CopyWorker` instance.

The methods remain private in the `CopyWorker` class. In future we might
make some/all of them public so that user subclasses of `PathBase` can
customize the copying process (in particular reading/writing of metadata,)
but we'd need to make `PathBase` public first.
2024-12-22 02:22:08 +00:00
Barney Gale f5ba74b819
GH-127807: pathlib ABCs: remove a few private attributes (#127851)
From `PurePathBase` delete `_globber`, `_stack` and `_pattern_str`, and
from `PathBase` delete `_glob_selector`. This helps avoid an unpleasant
surprise for a users who try to use these names.
2024-12-22 01:41:38 +00:00
Barney Gale a959ea1b0a
GH-127807: pathlib ABCs: remove `PurePathBase._raw_paths` (#127883)
Remove the `PurePathBase` initializer, and make `with_segments()` and
`__str__()` abstract. This allows us to drop the `_raw_paths` attribute,
and also the `Parser.join()` protocol method.
2024-12-22 01:17:59 +00:00
Petr Viktorin 2a66dd33df
gh-112328: Make EnumDict usable on its own and document it (GH-123669)
Co-authored-by: Rafi <rafi.promit@gmail.com>
Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
2024-12-20 11:40:58 -08:00
Nico-Posada 3879ca0100
gh-128049: Fix type confusion bug with the return value of a custom ExceptionGroup split function (#128079) 2024-12-20 19:20:31 +00:00
shallow-beach 5a584c8f54
Python Tutorial typo fix (#128077) 2024-12-20 18:09:56 +01:00
Mark Shannon 128cc47fbd
GH-127705: Add debug mode for `_PyStackRef`s inspired by HPy debug mode (GH-128121) 2024-12-20 16:52:20 +00:00
Petr Viktorin 78ffba4221
gh-127295: ctypes: Switch field accessors to fixed-width integers (GH-127297)
This should be a pure refactoring, without user-visible behaviour changes.

Before this change, ctypes uses traditional native C types, usually identified 
by [`struct` format characters][struct-chars] when a short (and 
identifier-friendly) name is needed:
- `signed char` (`b`) / `unsigned char` (`B`)
- `short` (`h`) / `unsigned short` (`h`)
- `int` (`i`) / `unsigned int` (`i`)
- `long` (`l`) / `unsigned long` (`l`)
- `long long` (`q`) / `unsigned long long` (`q`)

These map to C99 fixed-width types, which this PR switches to: - 
- `int8_t`/`uint8_t`
- `int16_t`/`uint16_t`
- `int32_t`/`uint32_t`
- `int64_t`/`uint64_t`

The C standard doesn't guarantee that the “traditional” types must map to the 
fixints. But, [`ctypes` currently requires it][swapdefs], so the assumption won't 
break anything.

By “map” I mean that the *size* of the types matches. The *alignment* 
requirements might not. This needs to be kept in mind but is not an issue in 
`ctypes` accessors, which [explicitly handle unaligned memory][memcpy] for the 
integer types.

Note that there are 5 “traditional” C type sizes, but 4 fixed-width ones. Two of 
the former are functionally identical to one another; which ones they are is 
platform-specific (e.g. `int`==`long`==`int32_t`.) This means that one of the 
[current][current-impls-1] [implementations][current-impls-2] is redundant on 
any given platform.


The fixint types are parametrized by the number of bytes/bits, and one bit for 
signedness. This makes it easier to autogenerate code for them or to write 
generic macros (though generic API like 
[`PyLong_AsNativeBytes`][PyLong_AsNativeBytes] is problematic for performance 
reasons -- especially compared to a `memcpy` with compile-time-constant size).

When one has a *different* integer type, determining the corresponding fixint  
means a `sizeof` and signedness check. This is easier and more robust than the 
current implementations (see [`wchar_t`][sizeof-wchar_t] or 
[`_Bool`][sizeof-bool]).


[swapdefs]: https://github.com/python/cpython/blob/v3.13.0/Modules/_ctypes/cfield.c#L420-L444
[struct-chars]: https://docs.python.org/3/library/struct.html#format-characters
[current-impls-1]: https://github.com/python/cpython/blob/v3.13.0/Modules/_ctypes/cfield.c#L470-L653
[current-impls-2]: https://github.com/python/cpython/blob/v3.13.0/Modules/_ctypes/cfield.c#L703-L944
[memcpy]: https://github.com/python/cpython/blob/v3.13.0/Modules/_ctypes/cfield.c#L613
[PyLong_AsNativeBytes]: https://docs.python.org/3/c-api/long.html#c.PyLong_AsNativeBytes
[sizeof-wchar_t]: https://github.com/python/cpython/blob/v3.13.0/Modules/_ctypes/cfield.c#L1547-L1555
[sizeof-bool]: https://github.com/python/cpython/blob/v3.13.0/Modules/_ctypes/cfield.c#L1562-L1572


Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-12-20 14:28:18 +01:00
Peter Bierma ba45e5cdd4
gh-127946: Use a critical section for `CFuncPtr` attributes (GH-128109) 2024-12-20 14:02:46 +01:00
Victor Stinner cbfe3023e4
gh-128116: Skip test_socket VSOCK testStream() on PermissionError (#128120) 2024-12-20 13:38:00 +01:00
Victor Stinner 0974d7bb86
gh-109959: Log the current directory in test_glob.test_selflink() (#128122) 2024-12-20 13:37:20 +01:00
Mark Shannon df46c780fe
GH-122548: Correct magic number comment (GH-128115)
Correct magic number comment
2024-12-20 11:57:44 +00:00
Shantanu 45e6dd63b8
gh-128030: Avoid error from PyModule_GetFilenameObject for non-module (#128047)
I missed the extra `PyModule_Check` in #127660 because I was looking at
3.12 as the base implementation for import from. This meant that I
missed the `PyModuleCheck` introduced in #112661.
2024-12-20 00:22:26 -08:00
Victor Stinner daa260ebb1
gh-128058: Fix test_builtin ImmortalTests (#128068)
On 32-bit Free Threading systems, immortal reference count
is 5 << 28, instead of 7 << 28.

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2024-12-20 08:50:18 +01:00
Md Rokibul Islam 39e69a7cd5
gh-112328: Document EnumDict in docs and release notes (GH-121720)
Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
2024-12-19 15:38:42 -08:00
Stephen Morton c14db20275
gh-128080: remove unnecessary `__init__` method from Enum (GH-128081)
remove unnecessary __init__ method from Enum

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2024-12-19 14:07:17 -08:00
mpage 255762c09f
gh-127274: Defer nested methods (#128012)
Methods (functions defined in class scope) are likely to be cleaned
up by the GC anyway.

Add a new code flag, `CO_METHOD`, that is set for functions defined
in a class scope. Use that when deciding to defer functions.
2024-12-19 13:03:14 -08:00
Zhikang Yan e163e8d4e1
gh-128062: Fix the font size and shortcut display of the turtledemo menu (#128063)
Leave the font of the menu bar the default to keep it consistent with the rest of the world. Display the shortcut keys in the right way, using the 'accelerator' option.
---------

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2024-12-19 15:24:47 -05:00
Neil Schemenauer 1b15c89a17
gh-115999: Specialize `STORE_ATTR` in free-threaded builds. (gh-127838)
* Add `_PyDictKeys_StringLookupSplit` which does locking on dict keys and
  use in place of `_PyDictKeys_StringLookup`.

* Change `_PyObject_TryGetInstanceAttribute` to use that function
  in the case of split keys.

* Add `unicodekeys_lookup_split` helper which allows code sharing
  between `_Py_dict_lookup` and `_PyDictKeys_StringLookupSplit`.

* Fix locking for `STORE_ATTR_INSTANCE_VALUE`.  Create
  `_GUARD_TYPE_VERSION_AND_LOCK` uop so that object stays locked and
  `tp_version_tag` cannot change.

* Pass `tp_version_tag` to `specialize_dict_access()`, ensuring
  the version we store on the cache is the correct one (in case of
  it changing during the specalize analysis).

* Split `analyze_descriptor` into `analyze_descriptor_load` and
  `analyze_descriptor_store` since those don't share much logic.
  Add `descriptor_is_class` helper function.

* In `specialize_dict_access`, double check `_PyObject_GetManagedDict()`
  in case we race and dict was materialized before the lock.

* Avoid borrowed references in `_Py_Specialize_StoreAttr()`.

* Use `specialize()` and `unspecialize()` helpers.

* Add unit tests to ensure specializing happens as expected in FT builds.

* Add unit tests to attempt to trigger data races (useful for running under TSAN).

* Add `has_split_table` function to `_testinternalcapi`.
2024-12-19 10:21:17 -08:00
Mark Shannon d2f1d917e8
GH-122548: Implement branch taken and not taken events for sys.monitoring (GH-122564) 2024-12-19 16:59:51 +00:00
Sam Gross 7b811d0562
gh-128008: Add `PyWeakref_IsDead()` (GH-128009)
The `PyWeakref_IsDead()` function tests if a weak reference is dead
without any side effects. Although you can also detect if a weak
reference is dead using `PyWeakref_GetRef()`, that function returns a
strong reference that must be `Py_DECREF()`'d, which can introduce side
effects if the last reference is concurrently dropped (at least in the
free threading build).
2024-12-19 16:17:15 +01:00
Pieter Eendebak b9b3e4a076
gh-127951: Add build option to enable pystats on Windows (GH-127952) 2024-12-19 14:45:34 +00:00
Peter Bierma b5d1e4552f
gh-128083: Fix macro redefinition warning in clinic. (GH-127950) 2024-12-19 15:00:30 +01:00
RUANG (James Roy) ea578fc6d3
gh-127688: Add `SCHED_DEADLINE` and `SCHED_NORMAL` constants to `os` module (GH-127689) 2024-12-19 14:51:21 +01:00
Kumar Aditya 19c5134d57
gh-122706: fix docs for asyncio ssl sockets (#128092) 2024-12-19 12:45:36 +00:00
Kumar Aditya 3c168f7f79
gh-128013: fix data race in `PyUnicode_AsUTF8AndSize` on free-threading (#128021) 2024-12-19 17:08:32 +05:30
Victor Stinner 46dc1ba9c6
gh-128069: brew link --overwrite tcl-tk@8 to prevent conflict with GitHub image's version (#128090)
brew link --overwrite tcl-tk@8 to prevent conflict with GitHub image's version

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-12-19 10:27:29 +00:00
Donghee Na 48c70b8f7d
gh-115999: Enable BINARY_SUBSCR_GETITEM for free-threaded build (gh-127737) 2024-12-19 11:08:17 +09:00
Victor Stinner f802c8bf87
gh-128013: Convert unicodeobject.c macros to functions (#128061)
Convert unicodeobject.c macros to static inline functions.

* Add _PyUnicode_SET_UTF8() and _PyUnicode_SET_UTF8_LENGTH() macros.
* Add PyUnicode_HASH() and PyUnicode_SET_HASH() macros.
* Remove unused _PyUnicode_KIND() and _PyUnicode_GET_LENGTH() macros.
2024-12-18 16:34:31 +01:00
Kumar Aditya 91c55085a9
gh-128033: change `PyMutex_LockFast` to take `PyMutex` as argument (#128054)
Change `PyMutex_LockFast` to take `PyMutex` as argument.
2024-12-18 20:49:00 +05:30
Kumar Aditya 8a433b683f
gh-121621: clear running loop early in asyncio (#128004) 2024-12-18 14:25:03 +00:00
Kumar Aditya dbd08fb60d
gh-127949: deprecate `asyncio.get_event_loop_policy` (#128053)
This deprecates `asyncio.get_event_loop_policy` and will be removed in Python 3.16.
2024-12-18 18:04:20 +05:30