Skip to content

merging into my modded python. thank you for helping me - #1

Open
sidlovescoding wants to merge 466 commits into
sidlovescoding:mainfrom
python:main
Open

sidlovescoding wants to merge 466 commits into
sidlovescoding:mainfrom
python:main

Conversation

@sidlovescoding

Copy link
Copy Markdown
Owner

No description provided.

vstinner and others added 30 commits November 19, 2026 23:18
Avoid a temporary PyMem_Malloc() buffer: create directly a bytes
object using PyBytesWriter API.
When a test fails with "worker bug" and tests are rerun in verbose
mode, reset worker_bug so that tests are marked as success if the
failed test doesn't fail again when rerun in verbose mode.

TestResult.write_json_into(file) now calls also file.flush().
….json (#161532)

With --with-build-python, the build Python can differ from the target in
patch version or release serial, but version_info and hexversion came from
the running interpreter. Read them from Include/patchlevel.h instead,
falling back to sys.version_info when the header is not there.

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
…60312)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
)

Py_INCREF(), Py_XINCREF(), Py_DECREF() and Py_XDECREF() are now
implemented as function calls on all limited C API versions.
Previously, they were only implemented as function calls on the
limited C API version 3.12 or newer.

Previously, if a C extension was built with the limited C API version
3.11 or newer, Py_DECREF() was implemented as "op->ob_refcnt--". But
Python 3.12 made Py_DECREF() more complicated to implement immortal
objects in an efficient way. "op->ob_refcnt--" can convert an
immortal object to a mortal object which causes various kinds of
nasty bugs.

Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
…ative() (#162268)

Wait for child execve() before creating `RemoteUnwinder`.
Use _target_processing() to sync with the child process.

Co-authored-by: Victor Stinner <vstinner@python.org>
…0619)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
…res (#161508)

Include intermediate Future nodes when the remote asyncio unwinder builds awaited-by graphs.
`socket.makefile("rwb")` passes the same raw stream to both sides of a `BufferedRWPair`. When the pair is deallocated, the reader closes the stream before the writer can flush its buffer.

Release the writer first, matching the order in `BufferedRWPair.close()`.
…#162352)

Temporary workaround to get bots green until importlib.metadata cleans
these up itself. FastPath keeps the fixture ZipFiles alive because of
a cycle in its cache. That means they get closed on deallocation
resulting in the unclosed file warning.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
… ARM64 Release builds (#162262)

* gh-153668: Disable ``unicodectype.c`` optimization in regular Windows ARM64 Release
builds due to a compiler bug in MSVC 14.50, 14.51, and 14.52. PGO builds are not affected.

---------

Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
)

configure sets _PYTHON_HOST_PLATFORM only for cross builds, but passed it
to the build Python for every --with-build-python build. In a native
build it was empty, so sysconfig.get_platform() returned "" and
build-details.json ended up with "platform": "".

Co-authored-by: Zanie Blue <contact@zanie.dev>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Kushal Das <mail@kushaldas.in>
…ize`, `st_creator`, `st_type` (#162382)

Classic Mac OS leftovers. Removed by #66074 but #66012 brought it back. Reusing a closed issue with more context if that's OK.
…taneous (#162366)

Reuse the short-sleep polling loop from test_stress_delivery_dependent.
The 10 ms minimum sleep of sleeping_retry() dominated the test's
runtime, especially under macOS background QoS where timer coalescing
stretches each sleep.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…writable (GH-162058)

On macOS and FreeBSD, poll() and select() can report a pipe as writable when a write to it would block. communicate() assumed a writable event meant a PIPE_BUF-sized write could not block... this works around that potential deadlock.

Changes:

Popen._communicate() makes stdin non-blocking while _communicate_io_posix() runs and restores blocking mode afterwards if stdin is still open. A resumed communicate() after TimeoutExpired and direct proc.stdin writes behave as before.
_communicate_io_posix() handles BlockingIOError by taking stdin out of the selector for a delay that doubles from 1 ms to 50 ms and resets on the next successful write. A timed retry is needed because the kernel keeps reporting the full pipe as writable, so there is no event to wait for. The other pipes are still serviced during the delay, and activity on them ends it early.

Nothing changes when the kernel reports readiness truthfully. In the affected state, a child that reads stdin but writes no output receives its input more slowly than with a blocking write.

---------

Co-authored-by: Johnny Wilson Dougherty <192861341+JohnnyWilson16@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
…hodType (#162408)

Add `@vectorcall` to Argument Clinic to generate `method.__new__`. Rename `method_new` as `method_type_new` to avoid the AC generated verctorcall name conflicting with existing `method_vectorcall`. Didn't add `Py_TPFLAGS_IMMUTABLETYPE` as this flag [automatically](https://docs.python.org/3/c-api/typeobj.html#c.Py_TPFLAGS_IMMUTABLETYPE) applies to static types.

Performance before:
```
Constructor microbenchmark (best of 7, 1000000 iterations each)
MethodType(f, obj)                   0.1073 s     107.3 ns/op
types.MethodType(f, obj)             0.1142 s     114.2 ns/op
MethodType(C.m, obj)                 0.1224 s     122.4 ns/op
call bound method m()                0.0944 s      94.4 ns/op
```

Performance after:
```
Constructor microbenchmark (best of 7, 1000000 iterations each)
MethodType(f, obj)                   0.0805 s      80.5 ns/op  (24.97% faster)
types.MethodType(f, obj)             0.0862 s      86.2 ns/op  (24.51% faster)
MethodType(C.m, obj)                 0.0927 s      92.7 ns/op  (24.26% faster)
call bound method m()                0.0946 s      94.6 ns/op  (-0.21% faster)
```

```python
import timeit

SETUP = """
import sys
import types
from types import MethodType

def f(self):
    pass

class C:
    def m(self):
        pass

obj = C()
m = MethodType(f, obj)
"""

CASES = [
    ("MethodType(f, obj)", "MethodType(f, obj)"),
    ("types.MethodType(f, obj)", "types.MethodType(f, obj)"),
    ("MethodType(C.m, obj)", "MethodType(C.m, obj)"),
    ("call bound method m()", "m()"),
]

NUMBER = 1_000_000
REPEAT = 7

print("Constructor microbenchmark (best of %d, %d iterations each)" % (REPEAT, NUMBER))
for name, stmt in CASES:
    times = timeit.repeat(stmt=stmt, setup=SETUP, number=NUMBER, repeat=REPEAT)
    best = min(times)
    print("%-34s %8.4f s   %7.1f ns/op" % (name, best, best / NUMBER * 1e9))
```
…61810)

ElementPath currently leaks a KeyError when a path contains a token that cannot
start a supported XPath step, such as @, =, or ). Check the token's handler
before calling it and raise SyntaxError("invalid path") when none exists.

Keep the C accelerator's literal tag fast path unchanged. This addresses the
exception leak described in the issue without changing which paths the
accelerator delegates to ElementPath.

The regression test covers find(), findall(), findtext(), and iterfind()
on both Element and ElementTree objects. The shared test suite runs it with
both the Python implementation and the C accelerator. Paths starting with
./ ensure that the accelerator also delegates these cases to ElementPath.

Fixes #161808
…rsion in `datetime` (#161747)

Co-authored-by: Stan Ulbrych <stan@python.org>
gatewaytofredom and others added 30 commits December 3, 2026 14:36
gh-161384: Fix IPv6Network.exploded with scope ID and avoid string round-trip
* commit 31765b252c42922e5dd5dd1fa8038147eec0de87:
  Backport applicable macro and configuration fixes (#1506)
* commit 256e4f7b8ef6a6b628e49df430746e69a34dd956:
  Fix slice-size typo and CMake configuration checks (#1506)
* commit cd9251e9280905dc485a713d1e0fc7293a4460e0:
  Make public headers -Wundef-safe and suppress it in static.c, see also #1506
* commit 0fe41040c07b2adc346801f2a520a3299f63615e:
  make internal headers -Wundef clean and include limits.h in types.h (see #1506)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Replace hand-written `defdict_init` with AC + vectorcall. There is no bad arguments message change.

For argument `default_factory`: `dd->default_factory = Py_NewRef(default_factory)` creates strong reference before `result = PyDict_Type.tp_init(self, newargs, kwargs)` runs arbitrary code. For `args` and `kwargs`: `defdict_vectorcall()` already creates strong references for both before calling `defdict_init_impl()`.

The `default_factory` argument defaults to `None`, so `defaultdict()` is functionally equivalent to `defaultdict(None)`, thus AC declaration uses `default_factory: object = None`. It should not add `(c_default="NULL")` as that causes error at the `default_factory != Py_None` check, thus didn't use `default_factory: object(c_default="NULL") = None`.


Benchmark:

```
+-------------------------+--------+----------------------+
| Benchmark               | main   | patch                |
+=========================+========+======================+
| defaultdict()           | 146 ns | 110 ns: 1.33x faster |
+-------------------------+--------+----------------------+
| defaultdict(list)       | 169 ns | 118 ns: 1.43x faster |
+-------------------------+--------+----------------------+
| defaultdict(list, kw)   | 239 ns | 168 ns: 1.42x faster |
+-------------------------+--------+----------------------+
| defaultdict(list, **kw) | 286 ns | 358 ns: 1.25x slower |
+-------------------------+--------+----------------------+
| Geometric mean          | (ref)  | 1.21x faster         |
+-------------------------+--------+----------------------+
```

```python
import pyperf

SETUP = """
from collections import defaultdict

kw = {'a': 1, 'b': 2}
"""

CASES = [
    ('defaultdict()', 'defaultdict()'),
    ('defaultdict(list)', 'defaultdict(list)'),
    ('defaultdict(list, kw)', 'defaultdict(list, kw)'),
    ('defaultdict(list, **kw)', 'defaultdict(list, **kw)')
]

runner = pyperf.Runner()
for name, stmt in CASES:
    runner.timeit(name, stmt=stmt, setup=SETUP)
```
…#163024)

If a build has already generated `idle3` and `pydoc3`, reconfiguring it with `--enable-relocatable` can leave both scripts with absolute shebangs. `make install` copies the stale scripts, which then fail when the installation moves. Make both targets depend on the generated `Makefile` so a change to the installation prefix or `--enable-relocatable` regenerates their headers.
The importlib tests of _write_atomic() used _pyio so they could patch
os.write(). Replace _io.open() with a BufferedWriter over a FileIO whose
writes are cut short instead. Also check the written contents and that no
temporary file is left behind after a failure.

The zipfile test only needs a BytesIO subclass that counts reads, which
io.BytesIO supports.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Replace the hand-written `dialect_new` with an Argument Clinic + vectorcall. Move `_csv_Dialect___replace___impl()` from calling `dialect_new()` to `dialect_new_helper()` to avoid temporary tuple.

Error message for too many arguments is now `TypeError: Dialect() takes at most 9 arguments (N given)` instead of `TypeError: function takes at most 9 arguments (N given)`.

Benchmark:

```
+-------------------------------------------------+---------+-----------------------+
| Benchmark                                       | main    | patch                 |
+=================================================+=========+=======================+
| _csv.Dialect()                                  | 240 ns  | 198 ns: 1.22x faster  |
+-------------------------------------------------+---------+-----------------------+
| _csv.Dialect().__replace__(**{'delimiter':','}) | 1.79 us | 1.55 us: 1.15x faster |
+-------------------------------------------------+---------+-----------------------+
| csv.reader(f)                                   | 409 ns  | 381 ns: 1.07x faster  |
+-------------------------------------------------+---------+-----------------------+
| csv.reader(f, delimiter=';')                    | 803 ns  | 557 ns: 1.44x faster  |
+-------------------------------------------------+---------+-----------------------+
| csv.writer(g)                                   | 399 ns  | 371 ns: 1.08x faster  |
+-------------------------------------------------+---------+-----------------------+
| parse_small()                                   | 5.45 us | 5.07 us: 1.07x faster |
+-------------------------------------------------+---------+-----------------------+
| Geometric mean                                  | (ref)   | 1.14x faster          |
+-------------------------------------------------+---------+-----------------------+

Benchmark hidden because not significant (1): parse_large()
```

```python
import pyperf

SETUP = """
import _csv, csv, io

f = io.StringIO()
g = io.StringIO()

small_data = "a,b,c\\n" + "1,2,3\\n" * 20        # ~140 bytes
large_data = "a,b,c\\n" + "1,2,3\\n" * 50000    # ~350 KB

def parse_small():
    for row in csv.reader(io.StringIO(small_data), delimiter=','):
        pass

def parse_large():
    for row in csv.reader(io.StringIO(large_data), delimiter=','):
        pass
"""

CASES = [
    ("_csv.Dialect()", "_csv.Dialect()"),
    ("_csv.Dialect().__replace__(**{'delimiter':','})", "_csv.Dialect().__replace__(**{'delimiter':','})"),
    ("csv.reader(f)", "csv.reader(f)"),
    ("csv.reader(f, delimiter=';')", "csv.reader(f, delimiter=';')"),
    ("csv.writer(g)", "csv.writer(g)"),
    ("parse_small()", "parse_small()"),
    ("parse_large()", "parse_large()"),
]

runner = pyperf.Runner()
for name, stmt in CASES:
    runner.timeit(name, stmt=stmt, setup=SETUP)
```
Co-authored-by: Victor Stinner <vstinner@python.org>
bug announcer: Replace unpinned npm install with Python stdlib
…H-162725)

Call Tcl_FinalizeThread() when the Python thread state is cleared at the
end of a thread which made calls to a Tcl interpreter in other thread or
created a Tcl interpreter, unless the thread still has a Tcl interpreter.
This fixes a leak of an event handle on Windows for every such thread.

The explicit _tkinter._finalize_thread() calls in tests are no longer
needed.
…t in `x_mul()` (#157743)

* Speed up int multiplication by not zeroing the whole result first
…s are avail… (#162474)

Fix test.test_capi.test_watchers assuming which watcher IDs are available

Some watcher tests hardcode watcher IDs 1 and 3 and assume them to be available.
Instead, force an available watcher ID by creating and then immediately removing
a watcher.  This makes the tests a bit more resilient in the face of other
modules registering watchers.
… event (#159238)

Co-authored-by: Victor Stinner <vstinner@python.org>
Run the io tests against the C implementation only. The _pyio test
classes and mocks go away, and tests that the C classes shared with them
move into mixins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
….guess_type()` (#162708)

Co-authored-by: NaveenKumarG-dev <naveen13524g@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Changes since the release of 3.15.0 on 2026-10-09.
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
* Add pseudo instructions JUMP_IF_NONE/NOT_NONE

* gh-162540: Implement PEP 824 - None-coalesce operator

---------

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
…e digit limit (#136279)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Stan Ulbrych <stan@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.