]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
21 months agopathlib ABCs: add `_raw_path` property (#113976)
Barney Gale [Sat, 13 Jan 2024 08:03:21 +0000 (08:03 +0000)] 
pathlib ABCs: add `_raw_path` property (#113976)

It's wrong for the `PurePathBase` methods to rely so much on `__str__()`.
Instead, they should treat the raw path(s) as opaque objects and leave the
details to `pathmod`.

This commit adds a `PurePathBase._raw_path` property and uses it through
many of the other ABC methods. These methods are all redefined in
`PurePath` and `Path`, so this has no effect on the public classes.

21 months agoGH-44626, GH-105476: Fix `ntpath.isabs()` handling of part-absolute paths (#113829)
Barney Gale [Sat, 13 Jan 2024 07:36:05 +0000 (07:36 +0000)] 
GH-44626, GH-105476: Fix `ntpath.isabs()` handling of part-absolute paths (#113829)

On Windows, `os.path.isabs()` now returns `False` when given a path that
starts with exactly one (back)slash. This is more compatible with other
functions in `os.path`, and with Microsoft's own documentation.

Also adjust `pathlib.PureWindowsPath.is_absolute()` to call
`ntpath.isabs()`, which corrects its handling of partial UNC/device paths
like `//foo`.

Co-authored-by: Jon Foster <jon@jon-foster.co.uk>
21 months agoGH-111798: skip `test_super_deep()` from `test_call` under pydebug builds on WASI...
Brett Cannon [Sat, 13 Jan 2024 00:29:16 +0000 (16:29 -0800)] 
GH-111798: skip `test_super_deep()` from `test_call` under pydebug builds on WASI (GH-114010)

21 months agogh-89159: Document missing TarInfo members (#91564)
Stanley [Fri, 12 Jan 2024 23:19:57 +0000 (15:19 -0800)] 
gh-89159: Document missing TarInfo members (#91564)

21 months agoGH-111801: set a lower recursion limit for `test_infintely_many_bases()` in `test_isi...
Brett Cannon [Fri, 12 Jan 2024 23:19:21 +0000 (15:19 -0800)] 
GH-111801: set a lower recursion limit for `test_infintely_many_bases()` in `test_isinstance` (#113997)

21 months agodatamodel: Fix a typo in ``object.__init_subclass__`` (#111599)
InSync [Fri, 12 Jan 2024 22:59:24 +0000 (05:59 +0700)] 
datamodel: Fix a typo in ``object.__init_subclass__`` (#111599)

21 months agoLink to the glossary for "magic methods" in ``MagicMock`` (#111292)
Pierre Equoy [Fri, 12 Jan 2024 22:54:36 +0000 (06:54 +0800)] 
Link to the glossary for "magic methods" in ``MagicMock`` (#111292)

The MagicMock documentation mentions magic methods several times without
actually pointing to the term in the glossary. This can be helpful for
people to fully understand what those magic methods are.

21 months agoTutorial: Clarify 'nonzero exit status' in the appendix (#112039)
Andrew Zipperer [Fri, 12 Jan 2024 22:42:51 +0000 (14:42 -0800)] 
Tutorial: Clarify 'nonzero exit status' in the appendix (#112039)

21 months agoFix a grammatical error in `pycore_pymem.h` (#112993)
Joseph Pearson [Fri, 12 Jan 2024 22:25:52 +0000 (17:25 -0500)] 
Fix a grammatical error in `pycore_pymem.h` (#112993)

21 months agogh-101100: Fix Sphinx Lint warnings in `Misc/` (#113946)
Hugo van Kemenade [Fri, 12 Jan 2024 22:25:04 +0000 (00:25 +0200)] 
gh-101100: Fix Sphinx Lint warnings in `Misc/` (#113946)

Fix Sphinx Lint warnings in Misc/

21 months agogh-95649: Document that asyncio contains uvloop code (#107536)
Alois Klink [Fri, 12 Jan 2024 22:21:13 +0000 (22:21 +0000)] 
gh-95649: Document that asyncio contains uvloop code (#107536)

Some of the asyncio SSL changes in GH-31275 [1] were taken from
v0.16.0 of the uvloop project [2]. In order to comply with the MIT
license, we need to just need to document the copyright information.

[1]: https://github.com/python/cpython/pull/31275
[2]: https://github.com/MagicStack/uvloop/tree/v0.16.0

21 months agoGH-111802: set a low recursion limit for `test_bad_getattr()` in `test.pickletester...
Brett Cannon [Fri, 12 Jan 2024 22:14:09 +0000 (14:14 -0800)] 
GH-111802: set a low recursion limit for `test_bad_getattr()` in `test.pickletester` (GH-113996)

21 months agogh-113971: Make `zipfile.ZipInfo._compresslevel` public as `.compress_level` (#113969)
Gregory P. Smith [Fri, 12 Jan 2024 20:15:05 +0000 (12:15 -0800)] 
gh-113971: Make `zipfile.ZipInfo._compresslevel` public as `.compress_level` (#113969)

Make zipfile.ZipInfo.compress_level public.

A property is used to retain the behavior of the ._compresslevel.

People constructing zipfile.ZipInfo instances to pass into existing APIs to control per-file compression levels already treat this as public, there was never a reason for it not to be.

I used the more modern name compress_level instead of compresslevel as the keyword argument on other ZipFile APIs is called to be consistent with compress_type and a general long term preference of not runningwordstogether without a separator in names.

21 months agogh-113710: Add types to the interpreter DSL (#113711)
Ken Jin [Fri, 12 Jan 2024 17:30:27 +0000 (01:30 +0800)] 
gh-113710: Add types to the interpreter DSL (#113711)

Co-authored-by: Jules <57632293+JuliaPoo@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
21 months agogh-113868: Add a number of MAP_* flags from macOS to module mmap (#113869)
Ronald Oussoren [Fri, 12 Jan 2024 15:56:18 +0000 (16:56 +0100)] 
gh-113868: Add a number of MAP_* flags from macOS to module mmap (#113869)

The new flags were extracted from the macOS 14.2 SDK.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
21 months agogh-107901: duplicate blocks with no lineno that have an eval break and multiple prede...
Irit Katriel [Fri, 12 Jan 2024 15:38:09 +0000 (15:38 +0000)] 
gh-107901: duplicate blocks with no lineno that have an eval break and multiple predecessors (#113950)

21 months agogh-113980: Fix resource warnings in test_asyncgen (GH-113984)
Serhiy Storchaka [Fri, 12 Jan 2024 15:30:26 +0000 (17:30 +0200)] 
gh-113980: Fix resource warnings in test_asyncgen (GH-113984)

21 months agogh-111877: Fixes stat() handling for inaccessible files on Windows (GH-113716)
Steve Dower [Fri, 12 Jan 2024 15:27:56 +0000 (15:27 +0000)] 
gh-111877: Fixes stat() handling for inaccessible files on Windows (GH-113716)

21 months agoDocs: Amend codeobject.co_lines docs; end number is exclusive (#113970)
Ned Batchelder [Fri, 12 Jan 2024 15:04:14 +0000 (10:04 -0500)] 
Docs: Amend codeobject.co_lines docs; end number is exclusive (#113970)

The end number should be exclusive, not inclusive.

21 months agoGH-113860: Get rid of `_PyUOpExecutorObject` (GH-113954)
Brandt Bucher [Fri, 12 Jan 2024 11:58:23 +0000 (03:58 -0800)] 
GH-113860: Get rid of `_PyUOpExecutorObject` (GH-113954)

21 months agogh-113027: Fix timezone check in test_variable_tzname in test_email (GH-113835)
Pablo Galindo Salgado [Fri, 12 Jan 2024 10:46:17 +0000 (10:46 +0000)] 
gh-113027: Fix timezone check in test_variable_tzname in test_email (GH-113835)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
21 months agogh-108364: In sqlite3, disable foreign keys before dumping SQL schema (#113957)
Mariusz Felisiak [Fri, 12 Jan 2024 09:50:37 +0000 (10:50 +0100)] 
gh-108364: In sqlite3, disable foreign keys before dumping SQL schema (#113957)

sqlite3.Connection.iterdump now ensures that foreign key support is
disabled before dumping the database schema, if there is any foreign key
violation.

Co-authored-by: Erlend E. Aasland <erlend@python.org>
21 months agogh-113858: Cut down ccache size (GH-113945)
Petr Viktorin [Fri, 12 Jan 2024 09:48:25 +0000 (10:48 +0100)] 
gh-113858: Cut down ccache size (GH-113945)

Cut down ccache size

- Only save the ccache in the main reusable builds, not on builds that
  don't use special build options:
  - Generated files check
  - OpenSSL tests
  - Hypothesis tests
- Halve the max cache size, to 200M

21 months agogh-113937 Fix failures in type cache tests due to re-running (GH-113953)
Peter Lazorchak [Fri, 12 Jan 2024 05:18:19 +0000 (21:18 -0800)] 
gh-113937 Fix failures in type cache tests due to re-running (GH-113953)

21 months agogh-113903: Fix an IDLE configdialog test (#113973)
Terry Jan Reedy [Fri, 12 Jan 2024 03:10:00 +0000 (22:10 -0500)] 
gh-113903: Fix an IDLE configdialog test (#113973)

test_configdialog.HighPageTest.test_highlight_target_text_mouse fails
if a line of the Highlight tab text sample is not visible. If so, bbox()
in click_char() returns None and the unpacking iteration fails.

This occurred on a Devuan Linux system. Fix by moving the
'see character' call inside click_char, just before the bbox call.

Also, reduce the click_char calls to just one per tag name and
replace the other nested function with a dict comprehension.

21 months agogh-111968: Explicit handling for finalized freelist (gh-113929)
Donghee Na [Fri, 12 Jan 2024 00:31:28 +0000 (09:31 +0900)] 
gh-111968: Explicit handling for finalized freelist (gh-113929)

21 months agoImprove kde graph with better caption and number formatting (gh-113967)
Raymond Hettinger [Fri, 12 Jan 2024 00:25:18 +0000 (18:25 -0600)] 
Improve kde graph with better caption and number formatting (gh-113967)

21 months agoGH-107678: Improve Unicode handling clarity in ``library/re.rst`` (#107679)
Adam Turner [Thu, 11 Jan 2024 23:56:10 +0000 (23:56 +0000)] 
GH-107678: Improve Unicode handling clarity in ``library/re.rst`` (#107679)

21 months agogh-81489: Use Unicode APIs for mmap tagname on Windows (GH-14133)
Zackery Spytz [Thu, 11 Jan 2024 22:39:47 +0000 (14:39 -0800)] 
gh-81489: Use Unicode APIs for mmap tagname on Windows (GH-14133)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
21 months agoUpdate KDE recipe to match the standard use of the h parameter (gh-#113958)
Raymond Hettinger [Thu, 11 Jan 2024 22:21:21 +0000 (16:21 -0600)] 
Update KDE recipe to match the standard use of the h parameter (gh-#113958)

21 months agogh-111968: Use per-thread freelists for tuple in free-threading (gh-113921)
Donghee Na [Thu, 11 Jan 2024 18:46:28 +0000 (03:46 +0900)] 
gh-111968: Use per-thread freelists for tuple in free-threading (gh-113921)

21 months agogh-113845: Fix a compiler warning in Python/suggestions.c (GH-113949)
Serhiy Storchaka [Thu, 11 Jan 2024 18:31:24 +0000 (20:31 +0200)] 
gh-113845: Fix a compiler warning in Python/suggestions.c (GH-113949)

21 months agoGH-113853: Guarantee forward progress in executors (GH-113854)
Mark Shannon [Thu, 11 Jan 2024 18:20:42 +0000 (18:20 +0000)] 
GH-113853: Guarantee forward progress in executors (GH-113854)

21 months agogh-107901: jump leaving an exception handler doesn't need an eval break check (#113943)
Irit Katriel [Thu, 11 Jan 2024 14:27:41 +0000 (14:27 +0000)] 
gh-107901: jump leaving an exception handler doesn't need an eval break check (#113943)

21 months agogh-91960: Remove Cirrus CI configuration (#113938)
Victor Stinner [Thu, 11 Jan 2024 13:33:24 +0000 (14:33 +0100)] 
gh-91960: Remove Cirrus CI configuration (#113938)

Remove .cirrus.yml which was already disabled by being renamed to
.cirrus-DISABLED.yml. In total, Cirrus CI only run for less than one
month.

21 months agogh-113932: assert ``SyntaxWarning`` in test_compile.TestSpecifics.test_… (#113933)
Kirill Podoprigora [Thu, 11 Jan 2024 11:25:07 +0000 (14:25 +0300)] 
gh-113932: assert ``SyntaxWarning`` in test_compile.TestSpecifics.test_… (#113933)

21 months agogh-112419: Document removal of sys.meta_path's 'find_module' fallback (#112421)
AN Long [Thu, 11 Jan 2024 09:43:35 +0000 (17:43 +0800)] 
gh-112419: Document removal of sys.meta_path's 'find_module' fallback (#112421)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
21 months agogh-112640: Add `kwdefaults` parameter to `types.FunctionType.__new__` (#112641)
Nikita Sobolev [Thu, 11 Jan 2024 08:42:30 +0000 (11:42 +0300)] 
gh-112640: Add `kwdefaults` parameter to `types.FunctionType.__new__` (#112641)

21 months agogh-89811: Check for valid tp_version_tag in specializer (GH-113558)
Peter Lazorchak [Thu, 11 Jan 2024 05:33:05 +0000 (21:33 -0800)] 
gh-89811: Check for valid tp_version_tag in specializer (GH-113558)

21 months agogh-111968: Unify naming scheme for freelist (gh-113919)
Donghee Na [Wed, 10 Jan 2024 23:51:51 +0000 (08:51 +0900)] 
gh-111968: Unify naming scheme for freelist (gh-113919)

21 months agogh-113896: Fix test_builtin.BuiltinTest.test___ne__() (#113897)
Kirill Podoprigora [Wed, 10 Jan 2024 23:39:48 +0000 (02:39 +0300)] 
gh-113896: Fix test_builtin.BuiltinTest.test___ne__() (#113897)

Fix DeprecationWarning in test___ne__().

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
21 months agogh-87868: Skip `test_one_environment_variable` in `test_subprocess` when the platform...
AN Long [Wed, 10 Jan 2024 23:17:05 +0000 (07:17 +0800)] 
gh-87868: Skip `test_one_environment_variable` in `test_subprocess` when the platform or build cannot do that (#113867)

* improve the assert for test_one_environment_variable
* skip some test in test_subprocess when python is configured with shared
* also skip the test if AddressSanitizer is enabled

---------

Co-authored-by: Steve Dower <steve.dower@microsoft.com>
21 months agogh-77046: os.pipe() sets _O_NOINHERIT flag on fds (#113817)
Victor Stinner [Wed, 10 Jan 2024 22:02:17 +0000 (23:02 +0100)] 
gh-77046: os.pipe() sets _O_NOINHERIT flag on fds (#113817)

On Windows, set _O_NOINHERIT flag on file descriptors
created by os.pipe() and io.WindowsConsoleIO.

Add test_pipe_spawnl() to test_os.

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
21 months agogh-112302: Point core developers to SBOM devguide on errors (#113490)
Seth Michael Larson [Wed, 10 Jan 2024 19:21:04 +0000 (13:21 -0600)] 
gh-112302: Point core developers to SBOM devguide on errors (#113490)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
21 months agogh-113753: Clear finalized bit when putting PyAsyncGenASend back into free list ...
Sam Gross [Wed, 10 Jan 2024 18:18:38 +0000 (13:18 -0500)] 
gh-113753: Clear finalized bit when putting PyAsyncGenASend back into free list (#113754)

21 months agogh-113625: Align object addresses in the Descriptor HowTo Guide (#113894)
Raymond Hettinger [Wed, 10 Jan 2024 16:23:40 +0000 (10:23 -0600)] 
gh-113625: Align object addresses in the Descriptor HowTo Guide (#113894)

21 months agoAdd @requires_zlib() decorator for gh-109858 tests (GH-113918)
Serhiy Storchaka [Wed, 10 Jan 2024 15:56:40 +0000 (17:56 +0200)] 
Add @requires_zlib() decorator for gh-109858 tests (GH-113918)

21 months agogh-111968: Use per-thread freelists for float in free-threading (gh-113886)
Donghee Na [Wed, 10 Jan 2024 15:47:13 +0000 (00:47 +0900)] 
gh-111968: Use per-thread freelists for float in free-threading (gh-113886)

21 months agoGH-113860: All executors are now defined in terms of micro ops. Convert counter execu...
Mark Shannon [Wed, 10 Jan 2024 15:44:34 +0000 (15:44 +0000)] 
GH-113860: All executors are now defined in terms of micro ops. Convert counter executor to use uops. (GH-113864)

21 months agogh-111139: Optimize math.gcd(int, int) (#113887)
Victor Stinner [Wed, 10 Jan 2024 15:38:56 +0000 (16:38 +0100)] 
gh-111139: Optimize math.gcd(int, int) (#113887)

Add a fast-path for the common case.

Benchmark:

    python -m pyperf timeit \
        -s 'import math; gcd=math.gcd; x=2*3; y=3*5' \
        'gcd(x,y)'

Result: 1.07x faster (-3.4 ns)

    Mean +- std dev: 52.6 ns +- 4.0 ns -> 49.2 ns +- 0.4 ns: 1.07x faster

21 months agogh-109858: Protect zipfile from "quoted-overlap" zipbomb (GH-110016)
Serhiy Storchaka [Wed, 10 Jan 2024 13:55:36 +0000 (15:55 +0200)] 
gh-109858: Protect zipfile from "quoted-overlap" zipbomb (GH-110016)

Raise BadZipFile when try to read an entry that overlaps with other entry or
central directory.

21 months agogh-111789: Use PyDict_GetItemRef() in Modules/_zoneinfo.c (GH-112078)
Serhiy Storchaka [Wed, 10 Jan 2024 13:35:10 +0000 (15:35 +0200)] 
gh-111789: Use PyDict_GetItemRef() in Modules/_zoneinfo.c (GH-112078)

21 months agogh-66515: Fix locking of an MH mailbox without ".mh_sequences" file (GH-113482)
Serhiy Storchaka [Wed, 10 Jan 2024 13:31:55 +0000 (15:31 +0200)] 
gh-66515: Fix locking of an MH mailbox without ".mh_sequences" file (GH-113482)

Guarantee that it either open an existing ".mh_sequences" file or create
a new ".mh_sequences" file, but do not replace existing ".mh_sequences"
file.

21 months agogh-89850: Add default C implementations of persistent_id() and persistent_load()...
Serhiy Storchaka [Wed, 10 Jan 2024 13:30:37 +0000 (15:30 +0200)] 
gh-89850: Add default C implementations of persistent_id() and persistent_load() (GH-113579)

Previously the C implementation of pickle.Pickler and pickle.Unpickler
classes did not have such methods and they could only be used if
they were overloaded in subclasses or set as instance attributes.

Fixed calling super().persistent_id() and super().persistent_load() in
subclasses of the C implementation of pickle.Pickler and pickle.Unpickler
classes. It no longer causes an infinite recursion.

21 months agogh-58032: Do not use argparse.FileType in module CLIs and scripts (GH-113649)
Serhiy Storchaka [Wed, 10 Jan 2024 13:07:19 +0000 (15:07 +0200)] 
gh-58032: Do not use argparse.FileType in module CLIs and scripts (GH-113649)

Open and close files manually. It prevents from leaking files,
preliminary creation of output files, and accidental closing of stdin
and stdout.

21 months agogh-113664: Improve style of Big O notation (GH-113695)
Serhiy Storchaka [Wed, 10 Jan 2024 13:01:18 +0000 (15:01 +0200)] 
gh-113664: Improve style of Big O notation (GH-113695)

Use cursive to make it looking like mathematic formulas.

21 months agogh-113594: Fix UnicodeEncodeError in TokenList.fold() (GH-113730)
Serhiy Storchaka [Wed, 10 Jan 2024 12:54:36 +0000 (14:54 +0200)] 
gh-113594: Fix UnicodeEncodeError in TokenList.fold() (GH-113730)

It occurred when try to re-encode an unknown-8bit part combined with non-unknown-8bit part.

21 months agogh-70835: Clarify error message for CSV file opened with wrong newline (GH-113786)
Serhiy Storchaka [Wed, 10 Jan 2024 12:52:29 +0000 (14:52 +0200)] 
gh-70835: Clarify error message for CSV file opened with wrong newline (GH-113786)

Based on patch by SilentGhost.

21 months agogh-96037: Always insert TimeoutError when exit an expired asyncio.timeout() block...
Serhiy Storchaka [Wed, 10 Jan 2024 10:50:31 +0000 (12:50 +0200)] 
gh-96037: Always insert TimeoutError when exit an expired asyncio.timeout() block (GH-113819)

If other exception was raised during exiting an expired
asyncio.timeout() block, insert TimeoutError in the exception context
just above the CancelledError.

21 months agogh-113879: Fix ResourceWarning in test_asyncio.test_server (GH-113881)
Serhiy Storchaka [Wed, 10 Jan 2024 10:38:36 +0000 (12:38 +0200)] 
gh-113879: Fix ResourceWarning in test_asyncio.test_server (GH-113881)

21 months agogh-113877: Fix Tkinter method winfo_pathname() on 64-bit Windows (GH-113900)
Serhiy Storchaka [Wed, 10 Jan 2024 10:36:03 +0000 (12:36 +0200)] 
gh-113877: Fix Tkinter method winfo_pathname() on 64-bit Windows (GH-113900)

winfo_id() converts the result of "winfo id" command to integer, but
"winfo pathname" command requires an argument to be a hexadecimal number
on Win64.

21 months agoGH-113858: GitHub Actions config: Only save ccache on pushes (GH-113859)
Petr Viktorin [Wed, 10 Jan 2024 08:49:18 +0000 (09:49 +0100)] 
GH-113858: GitHub Actions config: Only save ccache on pushes (GH-113859)

21 months agogh-112182: Replace StopIteration with RuntimeError for future (#113220)
Jamie Phan [Wed, 10 Jan 2024 05:21:00 +0000 (16:21 +1100)] 
gh-112182: Replace StopIteration with RuntimeError for future (#113220)

When an `StopIteration` raises into `asyncio.Future`, this will cause
a thread to hang. This commit address this by not raising an exception
and silently transforming the `StopIteration` with a `RuntimeError`,
which the caller can reconstruct from `fut.exception().__cause__`

21 months agopathlib ABCs: Require one or more initialiser arguments (#113885)
Barney Gale [Wed, 10 Jan 2024 01:12:58 +0000 (01:12 +0000)] 
pathlib ABCs: Require one or more initialiser arguments (#113885)

Refuse to guess what a user means when they initialise a pathlib ABC
without any positional arguments. In mainline pathlib it's normalised to
`.`, but in the ABCs this guess isn't appropriate; for example, the path
type may not represent the current directory as `.`, or may have no concept
of a "current directory" at all.

21 months agoGH-113528: Deoptimise `pathlib._abc.PurePathBase` (#113559)
Barney Gale [Tue, 9 Jan 2024 23:52:15 +0000 (23:52 +0000)] 
GH-113528: Deoptimise `pathlib._abc.PurePathBase` (#113559)

Apply pathlib's normalization and performance tuning in `pathlib.PurePath`, but not `pathlib._abc.PurePathBase`.

With this change, the pathlib ABCs do not normalize away alternate path separators, empty segments, or dot segments. A single string given to the initialiser will round-trip by default, i.e. `str(PurePathBase(my_string)) == my_string`. Implementors can set their own path domain-specific normalization scheme by overriding `__str__()`

Eliminating path normalization makes maintaining and caching the path's parts and string representation both optional and not very useful, so this commit moves the `_drv`, `_root`, `_tail_cached` and `_str` slots from `PurePathBase` to `PurePath`. Only `_raw_paths` and `_resolving` slots remain in `PurePathBase`. This frees the ABCs from the burden of some of pathlib's hardest-to-understand code.

21 months agogh-111968: Introduce _PyFreeListState and _PyFreeListState_GET API (gh-113584)
Donghee Na [Tue, 9 Jan 2024 23:04:41 +0000 (08:04 +0900)] 
gh-111968: Introduce _PyFreeListState and _PyFreeListState_GET API (gh-113584)

21 months agoGH-113528: Deoptimise `pathlib._abc.PurePathBase.relative_to()` (again) (#113882)
Barney Gale [Tue, 9 Jan 2024 23:04:14 +0000 (23:04 +0000)] 
GH-113528: Deoptimise `pathlib._abc.PurePathBase.relative_to()` (again) (#113882)

Restore full battle-tested implementations of `PurePath.[is_]relative_to()`. These were recently split up in 3375dfe and a15a773.

In `PurePathBase`, add entirely new implementations based on `_stack`, which itself calls `pathmod.split()` repeatedly to disassemble a path. These new implementations preserve features like trailing slashes where possible, while still observing that a `..` segment cannot be added to traverse an empty or `.` segment in *walk_up* mode. They do not rely on `parents` nor `__eq__()`, nor do they spin up temporary path objects.

Unfortunately calling `pathmod.relpath()` isn't an option, as it calls `abspath()` and in turn `os.getcwd()`, which is impure.

21 months agoGH-113528: Deoptimise `pathlib._abc.PurePathBase.parts` (#113883)
Barney Gale [Tue, 9 Jan 2024 22:46:50 +0000 (22:46 +0000)] 
GH-113528: Deoptimise `pathlib._abc.PurePathBase.parts` (#113883)

Implement `parts` using `_stack`, which itself calls `pathmod.split()`
repeatedly. This avoids use of `_tail`, which will be moved to `PurePath`
shortly.

21 months agogh-66060: Use actual class name in _io type's __repr__ (#30824)
AN Long [Tue, 9 Jan 2024 20:39:36 +0000 (04:39 +0800)] 
gh-66060: Use actual class name in _io type's __repr__ (#30824)

Use the object's actual class name in the following _io type's __repr__:
- FileIO
- TextIOWrapper
- _WindowsConsoleIO

21 months agoGH-113528: Deoptimise `pathlib._abc.PathBase.resolve()` (#113782)
Barney Gale [Tue, 9 Jan 2024 19:50:23 +0000 (19:50 +0000)] 
GH-113528: Deoptimise `pathlib._abc.PathBase.resolve()` (#113782)

Replace use of `_from_parsed_parts()` with `with_segments()` in
`resolve()`.

No effect on `Path.resolve()`, which uses `os.path.realpath()`.

21 months agoGH-113661: unittest runner: Don't exit 5 if tests were skipped (#113856)
Stefano Rivera [Tue, 9 Jan 2024 19:50:01 +0000 (11:50 -0800)] 
GH-113661: unittest runner: Don't exit 5 if tests were skipped (#113856)

The intention of exiting 5 was to detect issues where the test suite
wasn't discovered at all. If we skipped tests, it was correctly
discovered.

21 months agogh-113781: Silence AttributeError in warning module during Python finalization (GH...
Serhiy Storchaka [Tue, 9 Jan 2024 19:44:05 +0000 (21:44 +0200)] 
gh-113781: Silence AttributeError in warning module during Python finalization (GH-113813)

The tracemalloc module can already be cleared.

21 months agogh-113848: Handle CancelledError subclasses in asyncio TaskGroup() and timeout()...
Serhiy Storchaka [Tue, 9 Jan 2024 19:41:31 +0000 (21:41 +0200)] 
gh-113848: Handle CancelledError subclasses in asyncio TaskGroup() and timeout() (GH-113850)

21 months agogh-113848: Use PyErr_GivenExceptionMatches() for check for CancelledError (GH-113849)
Serhiy Storchaka [Tue, 9 Jan 2024 19:41:02 +0000 (21:41 +0200)] 
gh-113848: Use PyErr_GivenExceptionMatches() for check for CancelledError (GH-113849)

21 months agoGH-113528: Deoptimise `pathlib._abc.PathBase._make_child_relpath()` (#113532)
Barney Gale [Tue, 9 Jan 2024 19:11:17 +0000 (19:11 +0000)] 
GH-113528: Deoptimise `pathlib._abc.PathBase._make_child_relpath()` (#113532)

Call straight through to `joinpath()` in `PathBase._make_child_relpath()`.
Move optimised/caching code to `pathlib.Path._make_child_relpath()`

21 months agoSimplify binomial approximation example with random.binomialvariate() (gh-113871)
Raymond Hettinger [Tue, 9 Jan 2024 19:02:07 +0000 (13:02 -0600)] 
Simplify binomial approximation example with random.binomialvariate() (gh-113871)

21 months agoFix opcode name printing in debug mode (#113870)
Guido van Rossum [Tue, 9 Jan 2024 18:18:11 +0000 (10:18 -0800)] 
Fix opcode name printing in debug mode (#113870)

Fix a few places where the lltrace debug output printed ``(null)`` instead of an opcode name, because it was calling ``_PyUOpName()`` on a Tier-1 opcode.

21 months agogh-113650: Add workaround option for MSVC ARM64 bug affecting string encoding (GH...
Steve Dower [Tue, 9 Jan 2024 17:32:22 +0000 (17:32 +0000)] 
gh-113650: Add workaround option for MSVC ARM64 bug affecting string encoding (GH-113836)

21 months agogh-103092: Test _ctypes type hierarchy and features (#113727)
AN Long [Tue, 9 Jan 2024 17:28:43 +0000 (01:28 +0800)] 
gh-103092: Test _ctypes type hierarchy and features (#113727)

Test the following features for _ctypes types:
- disallow instantiation
- inheritance (MRO)
- immutability
- type name

The following _ctypes types are tested:
- Array
- CField
- COMError
- PyCArrayType
- PyCFuncPtrType
- PyCPointerType
- PyCSimpleType
- PyCStructType
- Structure
- Union
- UnionType
- _CFuncPtr
- _Pointer
- _SimpleCData

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
21 months agogh-87868: Sort and remove duplicates in getenvironment() (GH-102731)
AN Long [Tue, 9 Jan 2024 15:58:26 +0000 (23:58 +0800)] 
gh-87868: Sort and remove duplicates in getenvironment() (GH-102731)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
21 months agogh-113842: Add missing error check for PyIter_Next() in Python/symtable.c (GH-113843)
Yan Yanchii [Tue, 9 Jan 2024 10:43:58 +0000 (11:43 +0100)] 
gh-113842: Add missing error check for PyIter_Next() in Python/symtable.c (GH-113843)

21 months agogh-101100: Fix Sphinx warnings for 2.6 port-specific deprecations (#113752)
Hugo van Kemenade [Tue, 9 Jan 2024 08:18:15 +0000 (10:18 +0200)] 
gh-101100: Fix Sphinx warnings for 2.6 port-specific deprecations (#113752)

22 months agogh-113692: skip a test if multiprocessing isn't available. (GH-113704)
Vinay Sajip [Tue, 9 Jan 2024 07:47:42 +0000 (07:47 +0000)] 
gh-113692: skip a test if multiprocessing isn't available. (GH-113704)

22 months agoDocs: Link tokens in the format string grammars (#108184)
William Andrea [Tue, 9 Jan 2024 02:47:59 +0000 (21:47 -0500)] 
Docs: Link tokens in the format string grammars (#108184)

Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
22 months agogh-112087: Update list.{pop,clear,reverse,remove} to use CS (gh-113764)
Donghee Na [Tue, 9 Jan 2024 00:00:55 +0000 (09:00 +0900)] 
gh-112087: Update list.{pop,clear,reverse,remove} to use CS (gh-113764)

22 months agogh-112808: Fix mimalloc build on Solaris (#112809)
Jakub Kulík [Mon, 8 Jan 2024 23:50:56 +0000 (00:50 +0100)] 
gh-112808: Fix mimalloc build on Solaris (#112809)

22 months agogh-112806: Remove unused function warnings during mimalloc build on Solaris (#112807)
Jakub Kulík [Mon, 8 Jan 2024 23:49:33 +0000 (00:49 +0100)] 
gh-112806: Remove unused function warnings during mimalloc build on Solaris (#112807)

22 months agoreadme: fix displaying issue of command (#113719)
mara004 [Mon, 8 Jan 2024 23:42:56 +0000 (00:42 +0100)] 
readme: fix displaying issue of command (#113719)

Avoid line break in command as this causes displaying issues on GH.

22 months agogh-113027: Fix test_variable_tzname in test_email (#113821)
Serhiy Storchaka [Mon, 8 Jan 2024 22:33:53 +0000 (00:33 +0200)] 
gh-113027: Fix test_variable_tzname in test_email (#113821)

Determine the support of the Kyiv timezone by checking the result of
astimezone() which uses the system tz database and not the one
populated by zoneinfo.

22 months agogh-113827: Move Windows frozen modules directory to allow PGO builds (GH-113828)
Steve Dower [Mon, 8 Jan 2024 21:51:39 +0000 (21:51 +0000)] 
gh-113827: Move Windows frozen modules directory to allow PGO builds (GH-113828)

22 months agoGH-111693: Propagate correct asyncio.CancelledError instance out of asyncio.Condition...
Kristján Valur Jónsson [Mon, 8 Jan 2024 19:57:48 +0000 (19:57 +0000)] 
GH-111693: Propagate correct asyncio.CancelledError instance out of asyncio.Condition.wait() (#111694)

Also fix a race condition in `asyncio.Semaphore.acquire()` when cancelled.

22 months agogh-113791: Expose CLOCK_MONOTONIC_RAW_APPROX and CLOCK_UPTIME_RAW_APROX on macOS...
Ronald Oussoren [Mon, 8 Jan 2024 19:44:00 +0000 (20:44 +0100)] 
gh-113791: Expose CLOCK_MONOTONIC_RAW_APPROX and CLOCK_UPTIME_RAW_APROX on macOS in the time module (#113792)

22 months agoGH-113528: Speed up pathlib ABC tests. (#113788)
Barney Gale [Mon, 8 Jan 2024 19:31:52 +0000 (19:31 +0000)] 
GH-113528: Speed up pathlib ABC tests. (#113788)

- Add `__slots__` to dummy path classes.
- Return namedtuple rather than `os.stat_result` from `DummyPath.stat()`.
- Reduce maximum symlink count in `DummyPathWithSymlinks.resolve()`.

22 months agogh-113688: fix dtrace build on Solaris (#113814)
Jakub Kulík [Mon, 8 Jan 2024 19:28:09 +0000 (20:28 +0100)] 
gh-113688: fix dtrace build on Solaris (#113814)

(the gcmodule -> gc refactoring broke it)

22 months agoGH-113528: Move a few misplaced pathlib tests (#113527)
Barney Gale [Mon, 8 Jan 2024 19:17:18 +0000 (19:17 +0000)] 
GH-113528: Move a few misplaced pathlib tests (#113527)

`PurePathBase` does not define `__eq__()`, and so we have no business checking path equality in `test_eq_common` and `test_equivalences`. The tests only pass at the moment because we define the test class's `__eq__()` for use elsewhere.

Also move `test_parse_path_common` into the main pathlib test suite. It exercises a private `_parse_path()` method that will be moved to `PurePath` soon.

Lastly move a couple more tests concerned with optimisations and path normalisation.

22 months agoMinor algebraic simplification for the totient() recipe (gh-113822)
Raymond Hettinger [Mon, 8 Jan 2024 19:16:22 +0000 (13:16 -0600)] 
Minor algebraic simplification for the totient() recipe (gh-113822)

22 months agogh-113755: Fully adapt gcmodule.c to Argument Clinic (#113756)
Erlend E. Aasland [Mon, 8 Jan 2024 17:32:34 +0000 (18:32 +0100)] 
gh-113755: Fully adapt gcmodule.c to Argument Clinic (#113756)

Adapt the following functions to Argument Clinic:

- gc.set_threshold
- gc.get_referrers
- gc.get_referents

22 months agogh-113787: Fix refleaks in test_capi (gh-113816)
neonene [Mon, 8 Jan 2024 16:34:51 +0000 (01:34 +0900)] 
gh-113787: Fix refleaks in test_capi (gh-113816)

Fix refleaks and a typo.

22 months agogh-113391: fix outdated PyObject_HasAttr docs (#113420)
Sergey B Kirpichev [Mon, 8 Jan 2024 15:23:43 +0000 (18:23 +0300)] 
gh-113391: fix outdated PyObject_HasAttr docs (#113420)

After #53875: PyObject_HasAttr is not an equivalent of hasattr.
PyObject_HasAttrWithError is; it already has the note.

22 months agogh-110721: Remove unused code from suggestions.c after moving PyErr_Display to use...
Pablo Galindo Salgado [Mon, 8 Jan 2024 15:10:45 +0000 (15:10 +0000)] 
gh-110721: Remove unused code from suggestions.c after moving PyErr_Display to use the traceback module (#113712)