Commit graph

57273 commits

Author SHA1 Message Date
sobolevn
2f064fbc0b
gh-150899: Do not reset custom -Xlazy_imports mode in test_lazy_imports (#150900) 2026-06-05 11:03:57 +03:00
Serhiy Storchaka
45562c6f4f
gh-62825: Fix encoding aliases "KS_C_5601-1987", "KS X 1001", etc (GH-150933)
They are now aliases of CP949 instead of EUC-KR.
2026-06-05 10:58:20 +03:00
Hood Chatham
c83d3d789e
gh-145177: Bump emscripten version to 4.0.19 (#150926)
Bumpts the emscripten version to 4.0.19.
2026-06-05 13:59:43 +08:00
Bernát Gábor
f906522a4e
gh-150886: Remove unused importlib._bootstrap._object_name (#150884)
Introduced in GH-23469 (bpo-26131, "Deprecate usage of load_module()")
to render an object's qualified name inside the load_module()
deprecation warnings.

Orphaned by gh-142205 (GH-97850, "Remove all uses and definitions of
load_module() from importlib"), which deleted the warning-building call
sites f"{_object_name(spec.loader)}.exec_module() not found; ..." and
left the helper with no caller.

A word-boundary search across Lib, Modules, Python, Objects and Include
finds zero references outside its own definition, and a GitHub code
search finds no downstream importers. The frozen importlib was
regenerated; importlib._bootstrap._object_name no longer exists at
runtime and the full test_importlib suite passes.
2026-06-04 20:08:58 +00:00
Bernát Gábor
d4a8066c82
gh-150817: Speed up Flag bitwise operations (GH-150824)
Flag.__or__, __and__ and __xor__ walked both operands on every call to reject
None values. Run that scan only when one of the operand values is actually
None, so valid combinations skip it. The TypeError and its message are
unchanged for the invalid cases.
2026-06-04 12:58:20 -07:00
Bernát Gábor
e833f57383
gh-150818: Speed up logging.getLogger() for existing loggers (GH-150825) 2026-06-04 17:15:12 +01:00
Ivan Marton
ac3694b008
gh-84649: Make TimedRotatingFileHandler use CTIME instead of MTIME (GH-24660)
The TimedRotatingFileHandler previously only used st_mtime attribute of the
log file to detect whether it has to be rotate yet or not. In cases when the
file is changed within the rotatation period the st_mtime is also updated
to the current time and the rotation never happens.

It's more appropriate to check the file creation time (st_ctime) instead.
Whenever available, the more appropriate st_birthtime will be in use. (This
feature is available on FreeBSD, MacOS and Windows at the moment.) If
the st_mtime would be newer than st_ctime (e.g.: because the inode
related to the file has been changed without any file content
modification), then the earliest attribute will be used.
2026-06-04 13:50:33 +00:00
Jiseok CHOI
fc9c4db130
gh-150913: Fix sqlite3.Blob validation for empty slice assignment (GH-150915)
ass_subscript_slice() returned early when the computed slice length
was zero, bypassing validation performed for non-empty slices.
2026-06-04 16:41:47 +03:00
sobolevn
d83d50b5b7
gh-150750: Fix a race condition in deque.index with free-threading (#150779) 2026-06-04 13:31:31 +00:00
Batuhan Taskaya
3ff2117ea3
bpo-38131: Improve messages when generating AST nodes from objects with wrong field values (GH-17715) 2026-06-04 10:58:51 +00:00
jb2170
ae507e3b14
gh-119670: Add force keyword only argument to shlex.quote (#148846)
There are propositions to add a single-quote-double-quote switch
(gh-90630), so to avoid hiccups of people passing `force` as a
positional and it being used for the single-double switch, we make
kwargs kwargs-only.

Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
2026-06-04 11:06:02 +02:00
Abduaziz π
5915a1fb9d
gh-132467: Document and test that generic aliases are not classes (#133504)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2026-06-03 13:35:25 +00:00
Edward Xu
41eb8ee2bb
gh-148613: Fix race in gc_set_threshold and gc_get_threshold (#150356) 2026-06-03 16:58:26 +05:30
Nazım Can Altınova
494f2e3c92
gh-150723: Fix perf jitdump files on macOS (#150728)
The perf jitdump format defines the thread id field of the JR_CODE_LOAD
record as a 32-bit value, but on macOS it was declared as a uint64_t
(since pthread_threadid_np() returns a uint64_t). Those extra 8 bytes
plus alignment padding shifted every following field, so parsers reading
the file by the spec misread code_size as the code address and failed to
resolve any Python frames.

Declare thread_id as uint32_t on all platforms and truncate the macOS
thread id when writing the record. The value is only informational.
Symbols are resolved by address, and not thread ids so truncation is
safe here.

* Use mach_absolute_time for macOS jitdump timestamps

On macOS the jitdump file is consumed by profilers such as samply, which
timestamp their samples using mach_absolute_time(). The jitdump events were
stamped with clock_gettime(CLOCK_MONOTONIC), a different clock domain that
keeps advancing while the system is asleep, so the JIT code mappings could be
off by days relative to the samples and no Python frame would resolve. Stamp
jitdump events with mach_absolute_time() on macOS so they share the sampler's
clock domain. Linux continues to use CLOCK_MONOTONIC to stay aligned with perf.

Exercise the -Xperf_jit (jitdump) backend through samply and assert that
Python frames resolve, exercising the binary jitdump path end to end.
Skipped when samply is not installed.
2026-06-03 01:15:34 +01:00
Florian Best
29805f00a1
gh-91099: fix[imaplib]: call Exception with string instance (#31823)
* bpo-46943: fix[imaplib]: call Exception with string instance

Adjust the behavior of 'login' to be similar to `authenticate()`, 
where self.error is called with a str() instance.

Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
2026-06-02 16:42:04 -04:00
Gustaf
f7e0fb60cf
gh-101913: changed wording of docstring for _parsedate_tz (#134446)
Fixed incorrect word.

Co-authored-by: Gustaf <79180496+GGyll@users.noreply.github.com>
2026-06-02 11:02:19 -04:00
Seth Larson
991224b1e8
gh-149079: Fix O(n^2) canonical ordering in unicodedata.normalize() (GH-149080)
Replace the insertion sort used for canonical ordering of combining
characters with a hybrid approach: insertion sort for short runs (< 20)
and counting sort for longer runs, reducing worst-case complexity from
O(n^2) to O(n). This prevents denial of service via crafted Unicode
strings with many combining characters in alternating CCC order.

Co-authored-by: ch4n3-yoon <ch4n3.yoon@gmail.com>
Co-authored-by: Seokchan Yoon <13852925+ch4n3-yoon@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <stan@python.org>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Maurycy Pawłowski-Wieroński <maurycy@maurycy.com>
2026-06-02 11:39:50 +02:00
Stan Ulbrych
c52d2b16dd
gh-149805: Fix SystemError when compiling __classdict__ class annotation (#149806) 2026-06-02 10:17:03 +01:00
Sepehr Rasouli
60fdb3192b
gh-149738: Fix segmentation fault bug in sqllite3 (#149754)
Deleting the `row_factory` or `text_factory` attribute is no longer allowed.
2026-06-02 11:07:08 +02:00
Bartosz Sławecki
5a2d2736a6
gh-150052: Resolve un-loaded lazily loaded submodules via module.__getattr__ instead of publishing lazy values (#150055) (#150744) 2026-06-02 09:58:51 +01:00
Barry Warsaw
27ebd9abce
gh-150228: Improve the PEP 829 batch processing APIs (#150542)
* gh-150228: Improve the PEP 829 batch processing APIs

As previously discussed with @ncoghlan and approved for 3.15b2 by @hugovk,
this implements the batch processing APIs for addsitedir() and friends.  We
remove the `defer_processing_start_files` flag which required some implicit
module global state, and promote StartupState to the public documented API.

This also moves the bulk of the module global functions into methods of the
`StartupState` class, so it removes the awkward APIs in 3.15b1.  Now, instances
of this class are an accumulator for startup state, using `StartupState.process()`
to process them.  Callers can now batch up startup state themselves by using
the methods on this class.  The module global functions are shims for this
which preserve the legacy APIs and semantics using the new state class.

This PR also fixes the interleaving regression identified by @ncoghlan in the
same issue.  Now, .pth file sys.path extensions are added to sys.path after
the sitedir that the .pth file is found in, restoring the legacy behavior.

Along the way, I've made a lot of improvements to function docstrings,
site.rst documentation, and comments in the code explaining what's going on.

* Add a note that if known_paths is provided to StartupState.__init__(), it
  will get mutated in place.
* Improve some conditional flows.
* Improve some comments.
* Improve the what's new entry.

* Make test_impl_exec_imports_suppressed_by_matching_start() more robust

Based on PR comment, we need to read both the .pth and .start files, and prove
that the .pth file's import line (which passes a bigger increment) is not
called, but the .start file's entry point (which uses the default increment)
is called.

* As per review, move some methods to the private API

_read_pth_file() and _read_start_file() are not intended to be part of the
public API surface outside of the site module, so even though they are used by
methods outside of the StartupState class, make them privately named.

* Resolve several review feedbacks

* Move a `versionadded`
* Better list comprehension formatting (use the output from
  `ruff format --line-length 78`)

* Add docs for site.makepath() and point the case-normalization requirement to
  this utility function.
* Note that StartupState.process() is not idempotent.

* Address another feedback comment

This time, we get rid of the legacy implementation `reset` local, which was
always difficult to understand, and just implement a return value based on the
processing mode selected.

* Changes based on gh-150228 review

The comment by @encukou that started this change:

```
I still see two red flags here though: an argument that doesn't combine with
other arguments, and (another instance of) changing the return type based on
an argument.

Did you consider adding a StartupState.addsitedir(sitedir) method, instead of
the startup_state argument?
```

As it turns out, this is an even cleaner design.  By moving the bulk of the
previous module global functions into `StartupState` methods, we can get rid
of all the awkward `startup_state` keyword-only arguments which conflict
with `known_path` (Petr's first point).  We can also get rid of the
return value dichotomy (Petr's second point) because now we can preserve
exactly the Python 3.14 API in the module global functions, and implement
the better APIs in the class methods.  We also generally don't have to
pass around `process_known_sitedirs`.

Now the following module global functions are essentially shims around
class methods:

* site.addsitedir() -> StartupState.addsitedir()
* site.addusersitepackages() -> StartupState.addusersitepackages()
* site.addsitepackages() -> StartupState.addsitepackages()
* Additional minor changes
* Remove a now unused parameter


Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2026-06-01 18:43:18 -07:00
László Kiss Kollár
f4426654fd
gh-150720: Remove '-d 1' in test_script_error_treatment (#150736) 2026-06-02 00:51:51 +00:00
Pablo Galindo Salgado
ce073ec4cc
gh-150429: Fix sampling profiler generator stack test (#150433) 2026-06-01 21:27:39 +01:00
Serhiy Storchaka
b23646adf1
gh-93417: Improve test_mimetypes (GH-150725)
* Separate tests for module-level API and for the MimeTypes class.
* Add tests for mimetypes.init() and MimeTypes() with knownfiles and with
  explicitly passed files.
2026-06-01 23:02:40 +03:00
Mark Shannon
4996b99695
GH-150478: Add "show_jit" option to dis.dis to show jit entry points (GH-150554)
* Shows `ENTER_EXECUTOR` instructions
2026-06-01 17:52:40 +01:00
Victor Stinner
e8034dd841
gh-150436: Skip subprocess test on STATUS_DLL_INIT_FAILED (#150704)
If a subprocess spawned with CREATE_NEW_CONSOLE creation flag fails
with STATUS_DLL_INIT_FAILED return code, skip the test. It's likely a
memory allocation failure in the desktop heap memory which caused the
DLL init failure.
2026-06-01 14:50:15 +00:00
sobolevn
cc0269334f
gh-149534: Fix unification of defaultdict and frozendict with | (#149539) 2026-06-01 16:26:49 +03:00
Thomas Kowalski
c98773633c
gh-149046: fix: correctly handle str subclasses in io.StringIO (#149047) 2026-06-01 13:01:57 +00:00
Sergey B Kirpichev
46b5e3e941
gh-80480: Remove deprecated 'u' array type code (#149535)
Reuse array.typecodes in tests.
2026-06-01 11:57:55 +00:00
Dawid Konrad Kohnke
9d64c355b5
gh-150368: Change Windows user group to secure identifier in test_tempfile (#150369) 2026-06-01 11:35:48 +00:00
Russell Keith-Magee
540b3d0a7f
gh-148508: Add another common pattern for iOS SSL failures to test_ssl (#150442)
Match also '[SSL: HTTP_REQUEST] http request (_ssl.c:1143)'.
2026-06-01 11:37:53 +02:00
Stéphane Bidoul
f4bda4d6cb
gh-150685: update bundled pip to 26.1.2 (gh-150686) 2026-05-31 20:28:02 +01:00
Victor Stinner
350e9de765
gh-148605: Remove irepeat() thread test from test_bytes (#150576) 2026-05-31 14:57:10 +05:30
htjworld
2b94b92394
gh-131178: Fix mimetypes CLI docs, mention that errors go to stdout (#149683)
Co-authored-by: sobolevn <mail@sobolevn.me>
2026-05-31 07:45:48 +00:00
sobolevn
90c1d86f34
gh-149609: Raise deprecation warnings for abc.{abstractclassmethod,abstractstaticmethod,abstractproperty} (#149636) 2026-05-31 07:26:52 +00:00
Brij Kapadia
f586fd9e30
gh-144774: Add critical section in BaseException.__setstate__ (#150578) 2026-05-30 21:07:27 +05:30
Fang Li
6ecd197c03
gh-109503: Fix document for shutil.move() on usage of os.rename() since it's inaccurate (GH-109507)
Nonatomic move might be used even if the files are
on the same filesystem in some cases.
2026-05-30 14:26:03 +00:00
Tomi Belan
6d7a19e533
gh-121109: Fix performance of tarfile reading with "r|*" (GH-121296) 2026-05-30 09:23:50 +00:00
Serhiy Storchaka
1c7011d8fe
gh-150560: Fix crash in XML parser on invalid XML with multi-byte encoding (GH-150568) 2026-05-30 00:23:32 +03:00
Serhiy Storchaka
bcd29e466f
gh-149489: Fix ElementTree serialization to HTML (GH-149490)
* The content of comments, processing instructions and elements "xmp",
  "iframe", "noembed", "noframes", and "plaintext" is no longer escaped.
* The "plaintext" element no longer have the closing tag.
* Add support of empty attributes (with value None).
2026-05-30 00:04:50 +03:00
Thomas Kowalski
f87d9605d3
gh-149056: Properly pass array_hook in json.load() to json.loads() (GH-149057) 2026-05-29 22:53:21 +03:00
esadomer
26696a65f9
gh-132372: Speed up logging.config existing logger handling (GH-150242)
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
2026-05-29 16:50:05 +01:00
kodsurfer
6ac4dc8fc9
gh-150345: Fix incorrect reference in BaseSelectorEventLoop docstring (#150538) 2026-05-29 15:24:58 +05:30
Grant Herman
c72d5ea638
gh-150107: Fix asyncio sendfile fallback ignoring non-zero offset (#150270)
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-05-29 15:10:57 +05:30
Bartosz Sławecki
1d4e965829
gh-148587: Make sys.lazy_modules match PEP and keep internal lazy submodules tracking internal (#150086)
Make sys.lazy_modules match PEP and keep internal lazy submodules tracking internal

Co-authored-by: Dino Viehland <dinoviehland@meta.com>
2026-05-28 17:55:47 -07:00
Rafael Weingartner-Ortner
baf11a4e9a
gh-139398: [Enum] Add supported sunder names to __dir__ for REPL completions (GH-139985)
* Add supported sunder names to Enum `__dir__`

This change adds the sunder names `_generate_next_value_`
and `_missing_` to the `__dir__` method of `EnumType` and `Enum`.
In Addition, The instance level sunder names
`_add_alias_` and `_add_value_alias_` are added to `Enum.__dir__`.

With the sunder names exposed in the `dir()` method,
the REPL autocomplete will also show them.

---------

Co-authored-by: SimonGPrs <107691772+SimonGPrs@users.noreply.github.com>
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
2026-05-28 12:55:38 -07:00
Pradyun Gedam
ef2246f788
gh-150046: Fix test_add_python_opts to ignore PYTHON* env vars (#150089)
Avoid the runtime environment from affecting the tests' behaviours,
which notably checks the warning filters which can be controlled by
various PYTHON environment variables.
2026-05-28 18:48:51 +02:00
Chien Wong
cf2cd0be82
gh-115988: Add ARM64 and RISCV BCJ filters constants in lzma module (GH-115989)
---------

Signed-off-by: Chien Wong <m@xv97.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2026-05-28 08:05:03 -07:00
Sergey B Kirpichev
b6bae536ef
gh-85989: Add skip_if_double_rounding to test.support (#150219)
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-05-28 13:42:39 +02:00
Serhiy Storchaka
24c6bbc92b
gh-84353: Preserve non-UTF-8 filenames when appending to ZipFile (GH-150091)
Preserve non-UTF-8 filenames when appending to a ZipFile.

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2026-05-27 17:56:38 +00:00