]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
2 years agogh-114101: Correct PyErr_Format arguments in _testcapi module (#114102)
AN Long [Tue, 16 Jan 2024 08:32:39 +0000 (16:32 +0800)] 
gh-114101: Correct PyErr_Format arguments in _testcapi module (#114102)

- use PyErr_SetString() iso. PyErr_Format() in parse_tuple_and_keywords()
- fix misspelled format specifier in CHECK_SIGNNESS() macro

2 years agogh-78502: Add a trackfd parameter to mmap.mmap() (GH-25425)
Zackery Spytz [Tue, 16 Jan 2024 07:51:46 +0000 (23:51 -0800)] 
gh-78502: Add a trackfd parameter to mmap.mmap() (GH-25425)

If *trackfd* is False, the file descriptor specified by *fileno*
will not be duplicated.

Co-authored-by: Erlend E. Aasland <erlend@python.org>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2 years agogh-112087: Update list impl to be thread-safe with manual CS (gh-113863)
Donghee Na [Tue, 16 Jan 2024 00:11:14 +0000 (09:11 +0900)] 
gh-112087: Update list impl to be thread-safe with manual CS (gh-113863)

2 years agogh-91539: Small performance improvement of urrlib.request.getproxies_environment...
Raphaël Marinier [Mon, 15 Jan 2024 23:45:01 +0000 (00:45 +0100)] 
gh-91539: Small performance improvement of urrlib.request.getproxies_environment() (#108771)

 Small performance improvement of getproxies_environment() when there are many environment variables. In a benchmark with 5k environment variables not related to proxies, and 5 specifying proxies, we get a 10% walltime improvement.

2 years agogh-114070: correct the specification of ``digit`` in the float() docs (#114080)
Sergey B Kirpichev [Mon, 15 Jan 2024 22:19:59 +0000 (01:19 +0300)] 
gh-114070: correct the specification of ``digit`` in the float() docs (#114080)

2 years agogh-99437: runpy: decode path-like objects before setting globals
Kamil Turek [Mon, 15 Jan 2024 16:58:50 +0000 (17:58 +0100)] 
gh-99437: runpy: decode path-like objects before setting globals

2 years agogh-111968: Use per-thread slice_cache in free-threading (gh-113972)
Donghee Na [Mon, 15 Jan 2024 15:38:57 +0000 (00:38 +0900)] 
gh-111968: Use per-thread slice_cache in free-threading (gh-113972)

2 years agogh-112532: Fix memory block count for free-threaded build (gh-113995)
Sam Gross [Mon, 15 Jan 2024 15:37:36 +0000 (10:37 -0500)] 
gh-112532: Fix memory block count for free-threaded build (gh-113995)

This fixes `_PyInterpreterState_GetAllocatedBlocks()` and
`_Py_GetGlobalAllocatedBlocks()` in the free-threaded builds. The
gh-113263 change that introduced multiple mimalloc heaps per-thread
broke the logic for counting the number of allocated blocks. For subtle
reasons, this led to reported reference count leaks in the refleaks
buildbots.

2 years agogh-109598: make PyComplex_RealAsDouble/ImagAsDouble use __complex__ (GH-109647)
Sergey B Kirpichev [Mon, 15 Jan 2024 15:04:17 +0000 (18:04 +0300)] 
gh-109598: make PyComplex_RealAsDouble/ImagAsDouble use __complex__ (GH-109647)

`PyComplex_RealAsDouble()`/`PyComplex_ImagAsDouble` now try to convert
an object to a `complex` instance using its `__complex__()` method
before falling back to the ``__float__()`` method.

PyComplex_ImagAsDouble() also will not silently return 0.0 for
non-complex types anymore.  Instead we try to call PyFloat_AsDouble()
and return 0.0 only if this call is successful.

2 years agoGH-112354: `_GUARD_IS_TRUE_POP` side-exits to target the next instruction, not themse...
Mark Shannon [Mon, 15 Jan 2024 11:41:06 +0000 (11:41 +0000)] 
GH-112354: `_GUARD_IS_TRUE_POP` side-exits to target the next instruction, not themselves. (GH-114078)

2 years agogh-113666: Adding missing UF_ and SF_ flags to module 'stat' (#113667)
Ronald Oussoren [Mon, 15 Jan 2024 11:22:43 +0000 (12:22 +0100)] 
gh-113666: Adding missing UF_ and SF_ flags to module 'stat' (#113667)

Add some constants to module 'stat' that are used on macOS.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2 years agogh-114075: Capture `test_compileall` stdout output (#114076)
Kirill Podoprigora [Mon, 15 Jan 2024 10:21:34 +0000 (13:21 +0300)] 
gh-114075: Capture `test_compileall` stdout output  (#114076)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2 years agogh-109862: Fix test_create_subprocess_with_pidfd when it was run separately (GH-113991)
Serhiy Storchaka [Mon, 15 Jan 2024 07:26:49 +0000 (09:26 +0200)] 
gh-109862: Fix test_create_subprocess_with_pidfd when it was run separately (GH-113991)

2 years agogh-113317: Move FormatCounterFormatter into libclinic (#114066)
Erlend E. Aasland [Sun, 14 Jan 2024 23:09:26 +0000 (00:09 +0100)] 
gh-113317: Move FormatCounterFormatter into libclinic (#114066)

2 years agoReplace `pathlib._abc.PathModuleBase.splitroot()` with `splitdrive()` (#114065)
Barney Gale [Sun, 14 Jan 2024 23:06:04 +0000 (23:06 +0000)] 
Replace `pathlib._abc.PathModuleBase.splitroot()` with `splitdrive()` (#114065)

This allows users of the `pathlib-abc` PyPI package to use `posixpath` or
`ntpath` as a path module in versions of Python lacking
`os.path.splitroot()` (3.11 and before).

2 years agoAdd `pathlib._abc.PathModuleBase` (#113893)
Barney Gale [Sun, 14 Jan 2024 21:49:53 +0000 (21:49 +0000)] 
Add `pathlib._abc.PathModuleBase` (#113893)

Path modules provide a subset of the `os.path` API, specifically those
functions needed to provide `PurePathBase` functionality. Each
`PurePathBase` subclass references its path module via a `pathmod` class
attribute.

This commit adds a new `PathModuleBase` class, which provides abstract
methods that unconditionally raise `UnsupportedOperation`. An instance of
this class is assigned to `PurePathBase.pathmod`, replacing `posixpath`.
As a result, `PurePathBase` is no longer POSIX-y by default, and
all its methods raise `UnsupportedOperation` courtesy of `pathmod`.

Users who subclass `PurePathBase` or `PathBase` should choose the path
syntax by setting `pathmod` to `posixpath`, `ntpath`, `os.path`, or their
own subclass of `PathModuleBase`, as circumstances demand.

2 years agogh-101100: Fix Sphinx warnings in `howto/urllib2.rst` and `library/http.client.rst...
Hugo van Kemenade [Sun, 14 Jan 2024 20:38:53 +0000 (22:38 +0200)] 
gh-101100: Fix Sphinx warnings in `howto/urllib2.rst` and `library/http.client.rst` (#114060)

2 years agogh-113317: Move global utility functions into libclinic (#113986)
Erlend E. Aasland [Sun, 14 Jan 2024 18:26:09 +0000 (19:26 +0100)] 
gh-113317: Move global utility functions into libclinic (#113986)

Establish Tools/clinic/libclinic/utils.py and move the following
functions over there:

- compute_checksum()
- create_regex()
- write_file()

2 years agogh-111803: Support loading more deeply nested lists in binary plist format (GH-114024)
Serhiy Storchaka [Sat, 13 Jan 2024 13:26:55 +0000 (15:26 +0200)] 
gh-111803: Support loading more deeply nested lists in binary plist format (GH-114024)

It no longer uses the C stack. The depth of nesting is only limited by
Python recursion limit setting.

2 years agogh-114014: Update `fractions.Fraction()`'s rational parsing regex (#114015)
Crowthebird [Sat, 13 Jan 2024 12:02:39 +0000 (20:02 +0800)] 
gh-114014: Update `fractions.Fraction()`'s rational parsing regex (#114015)

Fix a bug in the regex used for parsing a string input to the `fractions.Fraction` constructor. That bug led to an inconsistent exception message being given for some inputs.

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
2 years agogh-101225: Increase the socket backlog when creating a multiprocessing.connection...
Ronald Oussoren [Sat, 13 Jan 2024 09:48:33 +0000 (10:48 +0100)] 
gh-101225: Increase the socket backlog when creating a multiprocessing.connection.Listener (#113567)

Increase the backlog for multiprocessing.connection.Listener` objects created
 by `multiprocessing.manager` and `multiprocessing.resource_sharer` to
 significantly reduce the risk of getting a connection refused error when creating
 a `multiprocessing.connection.Connection` to them.

2 years agoAdd module docstring for `pathlib._abc`. (#113691)
Barney Gale [Sat, 13 Jan 2024 08:47:00 +0000 (08:47 +0000)] 
Add module docstring for `pathlib._abc`. (#113691)

2 years 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.

2 years 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>
2 years 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)

2 years 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)

2 years 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)

2 years 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)

2 years 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.

2 years 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)

2 years 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)

2 years 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/

2 years 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

2 years 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)

2 years 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.

2 years 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>
2 years 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>
2 years 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)

2 years 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)

2 years 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)

2 years 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.

2 years 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)

2 years 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>
2 years 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>
2 years 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

2 years 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)

2 years 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.

2 years 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)

2 years 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)

2 years 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)

2 years 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>
2 years 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)

2 years 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)

2 years 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)

2 years 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)

2 years 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)

2 years 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.

2 years 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)

2 years 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>
2 years 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)

2 years 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)

2 years 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)

2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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)

2 years 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)

2 years 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)

2 years 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)

2 years 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)

2 years 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

2 years 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.

2 years 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)

2 years 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.

2 years 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.

2 years 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.

2 years 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.

2 years 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.

2 years 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.

2 years 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.

2 years 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)

2 years 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.

2 years 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)

2 years 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__`

2 years 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.

2 years 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.

2 years 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)

2 years 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.

2 years 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.

2 years 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

2 years 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()`.

2 years 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.

2 years 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.

2 years 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)

2 years 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)

2 years 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()`

2 years 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)

2 years 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.

2 years 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)