Skip to content

Sqlite3 file control - #1

Open
qris wants to merge 8632 commits into
hashbrowncipher:sqlite3_file_controlfrom
qris:sqlite3_file_control
Open

qris wants to merge 8632 commits into
hashbrowncipher:sqlite3_file_controlfrom
qris:sqlite3_file_control

Conversation

@qris

@qris qris commented Mar 23, 2026

Copy link
Copy Markdown

Merge updates from master as requested in python#128507 (comment).

@qris
qris force-pushed the sqlite3_file_control branch from 628fe08 to 5ddea3b Compare July 18, 2026 22:04
smontanaro and others added 29 commits October 21, 2026 13:48
Co-authored-by: Muse Code (Meta Muse Spark)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: Lukasz Langa <ambv@meta.com>
…in configparser (python#159687)

* pythongh-159684: Use f-strings in configparser and its tests

Convert the remaining printf-style and str.format() call sites in
Lib/configparser.py and Lib/test/test_configparser.py to f-strings
(Ruff UP030, UP031, UP032), rewrapping the lines that would otherwise
exceed 79 columns. No behavior change; the rendered strings are
identical.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* pythongh-159684: Simplify a few constructs in configparser and its tests

Apply the straightforward simplifications Ruff reports for these two
modules: redundant list() calls (C408, C414), a literal set (C405),
a key check that get() already covers (RUF019), an unpacked value that
is never used (RUF059), an unused assertRaises binding (F841),
collapsible if statements (SIM102) and nested with statements (SIM117).
Also parenthesize an implicit string concatenation inside a list
literal (ISC004) so it is not mistaken for a missing comma.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* pythongh-159684: Convert the last percent-formatting in configparser

Ruff leaves these UP031 sites alone because the %d conversions are not
provably integral, so convert them by hand, keeping the explicit :d
format spec so a non-integer still raises rather than being coerced.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* pythongh-159684: Clear the remaining Ruff findings in configparser

Sort the imports (I001) and __all__ (RUF022), and annotate the mutable
class attributes as ClassVar (RUF012). The ClassVar annotation would
otherwise mean importing typing at runtime, which this module avoids,
so defer annotations with __future__ instead and import ClassVar only
under TYPE_CHECKING, as tomllib and importlib.metadata do. Deferring
annotations also lets ParsingError be referenced unquoted (UP037).

ExtendedInterpolation._interpolate_some gets an explicit noqa: C901,
tagged with pythongh-159686, which records why the complexity is inherent to
the interpolation grammar and what a refactoring might look like.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* pythongh-159684: Add a NEWS entry

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
python#139123)

The C implementation considerably boosts the performance of the key UUID operations:

------------------------------------
Operation                    Speedup
------------------------------------
uuid4() generation            15.01x
uuid7() generation            29.64x
UUID from string               6.76x
UUID from bytes                5.16x
str(uuid) conversion           6.66x
------------------------------------

Summary of changes:

* The UUID type is reimplemented in C in its entirety.

* The pure-Python is kept around and is used of the C implementation
  isn't available for some reason.

* Both implementations are tested extensively; additional tests are
  added to ensure that the C implementation of the type follows the pure
  Python implementation fully.

* The Python implementation stores UUID values as int objects. The C
  implementation stores them as `uint8_t[16]` array.

* The C implementation has faster hash() implementation but also caches
  the computed hash value to speedup cases when UUIDs are used as
  set/dict keys.

* The C implementation has a freelist to make new UUID object
  instantiation as fast as possible.

* uuid4() and uuid7() are now implmented in C. The most performance
  boost (10x) comes from overfetching entropy to decrease the number of
  _PyOS_URandom() calls. On its own it's a safe optimization with the
  edge case that Unix fork needs to be explicitly handled. We do that by
  comparing the current PID to the PID of when the random buffer was
  populated.

* Portions of code are coming from my implementation of faster UUID
  in gel-python [1]. I did use AI during the development, but basically
  had to rewrite the code it generated to be more idiomatic and
  efficient.

* The benchmark can be found here [2].

* This PR makes Python UUID operations as fast as they are in NodeJS and
  Bun runtimes.

[1] https://github.com/MagicStack/py-pgproto/blob/b8109fb311a59f30f9947567a13508da9a776564/uuid.pyx

[2] https://gist.github.com/1st1/f03e816f34a61e4d46c78ff98baf4818
….Path` (python#160103)

Synchronizes the fix from zipp 3.23.1. `str()` of a `zipfile.Path` whose
zipfile has no filename previously raised `TypeError`.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
…nfo (pythonGH-150278)

The on-disk data was correct, but the in-memory TarInfo was not being properly updated.

---------

Signed-off-by: grantlouisherman <grantlouisherman041@gmail.com>
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
…zendicts (pythonGH-154362)

* pythongh-154318: Guard C recursion when hashing nested tuples and frozendicts

tuple_hash() and frozendict_hash() fold each contained object's hash into
an accumulator with PyObject_Hash() inside an unguarded loop. For a deeply
nested tuple or frozendict this recurses back into the same function once
per level and overflows the C stack (SIGSEGV / STATUS_STACK_OVERFLOW)
instead of raising RecursionError.

Wrap both loops in _Py_EnterRecursiveCall() / _Py_LeaveRecursiveCall(), as
the sibling comparison and repr paths already do. The guard is placed after
the cached-hash early return, so repeated hashing of an already-hashed
tuple is unaffected.

This also covers types.GenericAlias, whose ga_hash() hashes its __args__
tuple and so crashed through tuple_hash().
…cOS (python#156486)

Ensures that a user-specified LIBFFI_CFLAGS and LIBFFI_LIBS is honored when
building on macOS.
Co-authored-by: Petr Viktorin <encukou@gmail.com>
…on#99319)

Co-authored-by: Muse Code (Meta Muse Spark)
Co-authored-by: Lukasz Langa <ambv@meta.com>
…h` (python#160007)

`make_paths_relative()` now keeps the absolute `base_prefix` for computing the other paths, and only the stored `base_prefix` is made relative to the config file's directory. This is the same fix python-build-standalone carries in `patch-python-relative-build-details.patch` (by @geofft). That patch also changes the Makefile to generate relative paths by default; this PR leaves the Makefile alone.
…amework builds (python#160005)

In framework builds, `libpython.dynamic` now joins `PYTHONFRAMEWORKPREFIX` with `LDLIBRARY` instead of `LIBDIR` with `LDLIBRARY`, so it points at the framework library that is actually installed. Other builds are unchanged.
… builds (pythongh-153015)

In free-threading builds gc.set_debug() stored gcstate->debug with a plain
write while gc.get_debug() and the collector read it without synchronisation,
which ThreadSanitizer reports as a data race.  Access the flag with
FT_ATOMIC_STORE/LOAD_INT_RELAXED, consistent with how gc.enable()/disable() already handle gcstate->enabled.
…onment (python#160133)

Use the base interpreter prefixes when expanding the system install scheme so nested virtual environments are compared with the base interpreter site-packages rather than the outer virtual environment.

Co-authored-by: Muse Code (Meta Muse Spark)
…nd to a value (python#101318)

Co-authored-by: Muse Code (Meta Muse Spark)
Co-authored-by: Lukasz Langa <ambv@meta.com>
…2679)

binascii.a2b_qp() and quopri now leave an invalid "=" escape in place and
rescan the following character instead of consuming it, like email.quoprimime
and other decoders (b'==41' now decodes to b'=A').

Add an opt-in strip_ws parameter to binascii.a2b_qp(), quopri.decode(),
quopri.decodestring() and email.quoprimime.decode() to strip trailing
whitespace per RFC 2045.  It is false by default everywhere except
email.quoprimime.decode(), preserving every existing default.

Also document that email's get_payload(decode=True) does not strip trailing
whitespace, contrary to RFC 2045.

Register the new "strip_ws" argument name in the global objects tables
(make regen-global-objects), needed by static builds where binascii is
compiled into the core, and replace an unresolved :func: reference to the
undocumented email.quoprimime.decode with a literal.

* pythongh-62222: Make strip_ws parameters keyword-only

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
* Update vendored mimalloc to v2.5.2

Upgrade mimalloc from v2.1.2 to v2.5.2 as-is from upstream.

v2.1.2: https://github.com/microsoft/mimalloc/releases/tag/v2.1.2
v2.5.2: https://github.com/microsoft/mimalloc/releases/tag/v2.5.2

* Re-apply CPython-specific changes to mimalloc v2.5.2

Most of the previous downstream changes were upstreamed in mimalloc
v2.1.3 - v2.1.7 (heap tags, _mi_heap_init/_mi_tld_init, MI_PRIM_THREAD_ID,
sub-processes, heap walk optimizations, platform fixes) and are dropped.

Remaining CPython-specific changes, all marked with a "CPython" comment:

- QSBR delayed page freeing for free-threaded builds (pythongh-115103,
  pythongh-145615): mi_page_t/mi_heap_t fields and _PyMem_mi_* hooks in
  page.c, heap.c and segment.c.
- debug_offset: preserve the first bytes of a PyObject (ob_tid, refcount
  fields) when filling freed or uninitialized memory in debug builds
  (pythongh-115491).
- Atomic mi_block_t.next loads/stores to avoid TSAN reports (pythongh-129748).
- Relax the owning thread assertion in _mi_free_delayed_block for
  free-threaded builds, since the GC traverses heaps of other threads.
- Call _mi_heap_delayed_free_partial() in mi_heap_visit_blocks()
  (pythongh-112532).
- Only count reclaimed pages up to MI_MEDIUM_OBJ_SIZE_MAX as a
  "right page" in mi_segment_reclaim (pythongh-115103).
- Rename the weak _ZSt15get_new_handlerv symbol and disable the
  mi_is_in_heap_region debug warning.
- Zero-initialize _mi_page_empty instead of a positional initializer.

* Update the free-threaded build to mimalloc v2.5.2 changes

mimalloc v2.1.4 replaced the list of abandoned segments with per-arena
bitmaps and introduced sub-processes (mi_subproc_t) to keep abandoned
segments of separate interpreters apart. Use them instead of the
CPython-specific mi_abandoned_pool_t:

- Each interpreter owns a mi_subproc_t created in init_interpreter().
- tstate_mimalloc_bind() sets tld->segments.subproc and uses the
  upstream _mi_heap_init() signature.
- The GC and sys.getallocatedblocks() visit abandoned segments with
  _PyMem_mi_visit_abandoned_blocks(), the upstream cursor API without
  the mi_option_visit_abandoned requirement, while STW.

* Update NEWS.d

* fix MSAN

* fix TSAN

* fix test_cext

* Disable THP

* Address code review

* Address code review

* Address code review

* nit

* Address code review

* Address code review
…at (pythonGH-159224)

The C parser treated the timezone designator as leftover input, then ignored that leftover whenever an offset was present. Strings such as '12:30x+05:00' were accepted even though the pure-Python implementation rejects them.

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
…framework (python#159966)

The rules that link `libpython$(LDVERSION).dylib` and the macOS and iOS frameworks don't pass `$(MODLIBS)`, unlike the `libpython$(LDVERSION).so` rule. When a module is built in, for example via `Modules/Setup.local`, the libraries that module needs are left out:

- **`--enable-framework`:** the build fails with undefined symbols.
- **`--enable-shared`:** the dylib is linked with `-undefined dynamic_lookup`, so the build succeeds and the failure only shows up at runtime.

To reproduce, build on macOS with this `Modules/Setup.local`:

```
*static*
_blake2 blake2module.c
```

On `main`:

- **`--enable-framework`:** linking `Python.framework` fails with 12 undefined `_Py_LibHacl_*` symbols.
- **`--enable-shared`:** `nm -u libpython3.16.dylib` lists the same 12 symbols. After `make install`, `python3 -c "import _blake2; _blake2.blake2b(b'abc')"` aborts with `dyld: missing symbol called`, and so does a C program that embeds Python.

With this change, both builds link with no undefined HACL symbols, and `_blake2` works as a built-in module. In default builds `$(MODLIBS)` is empty, so they are unaffected. `test_hashlib`, `test_hmac`, `test_embed` and `test_sysconfig` pass for shared and framework builds, both with and without the `Setup.local` above (macOS 14, arm64). I haven't tested the iOS framework rule, which gets the same one-line change.

python-build-standalone already carries the dylib part of this as a patch ([astral-sh/python-build-standalone#870](astral-sh/python-build-standalone#870)). This PR doesn't remove `-undefined dynamic_lookup`, as the earlier pythongh-145186 did.
pythonGH-160163)

Bound the shift count by MAX_LONG_DIGITS*PyLong_SHIFT instead of
PY_SSIZE_T_MAX*PyLong_SHIFT, so that the result size computed in
long_lshift1() cannot overflow Py_ssize_t.
…ng spaces (python#159820)

The shell `python-config` located its own prefix with unquoted command
substitutions, so any whitespace in the installation path made it print an
empty `--prefix` and `-I/include/...`-style paths while exiting 0.

- Quote the substitutions and the argument loop (POSIX `sh`, no bashisms).
- Exit 1 with a message when the script's directory cannot be resolved,
  instead of silently printing empty paths.
- Replace `sed "s#$prefix#$prefix_real#"` with a `relocate` helper using
  parameter expansion, so `#`, `&`, `\` and regex metacharacters in either
  prefix are handled literally. Same first-occurrence semantics.
- Add `test_python_config_sh_prefix_with_spaces`: runs the
  generated script from `…/path with spaces/bin/` and checks `--prefix`,
  `--exec-prefix`, `--includes` and empty stderr
brettcannon and others added 30 commits October 28, 2026 19:44
Co-authored-by: Savannah Ostrowski <savannah@python.org>
Discovered by running the test suite from a release build which can map all of `/` into the WASI guest (unlike when running the test suite in a source checkout).
…tending.rst` (python#151976)

* pythongh-151950: Document `async.BaseEventLoop` and fix `asyncio-extending.rst`

* Apply suggestions from code review

Co-authored-by: Stan Ulbrych <stan@python.org>

* Update Doc/library/asyncio-extending.rst

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>

---------

Co-authored-by: Stan Ulbrych <stan@python.org>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
…notify (python#160848)

The server called unwrap() right after corrupting the client's TLS
stream, which sent its own close_notify to a client that was about to
close its socket.  That turned the client's close into a TCP reset, and
on Windows a reset discards the client's close_notify that is still
unread, so the server failed with WinError 10054 (or 10053).

Wait for the client's close_notify with recv() before calling unwrap().
A ragged EOF without close_notify still makes unwrap() raise SSLError,
so the test keeps catching the pythongh-98078 regression.

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
…io.Runner (python#128293)

Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>

* Update Doc/library/asyncio-runner.rst

Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>

---------

Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
python#160851)

If Server.close() ran after a connection was accepted but before its
transport was created, Server._attach() hit an assertion, the error was
reported to the exception handler, and the half-built transport later
raised TypeError from __del__.  Close such connections quietly instead,
in both the selector and proactor accept paths.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* refactor(ceval): combine argument conversion loops

* choore(docs): remove news
Co-authored-by: Stan Ulbrych <stan@python.org>
…arge float arguments (python#160807)

Co-authored-by: Stan Ulbrych <stan@python.org>
… port (python#160899)

Co-authored-by: Stan Ulbrych <stan@python.org>
…ngh-160836)

Hold a strong reference to func_name in both recording hooks before
PyList_Append can detach while acquiring the recording list lock.
…roxy authority (python#160528)

AbstractDigestAuthHandler.get_authorization() always looked up
credentials using the target request URL (req.full_url), even when
invoked via ProxyDigestAuthHandler, whose credentials are registered
against the proxy's host:port.

The lookup never matched, no Proxy-Authorization header was produced,
and proxy digest auth failed with an unhandled 407.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…#160917)

Proxy Auth failure to raise 407 instead of 401

https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/407
is the correct status code to raise for the Proxy Authentication.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/401
is the generic code that can be raised for unauthorized response.
…`.help` (python#139106)

Signed-off-by: Keming <kemingy94@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <stan@python.org>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Brett Cannon <brett@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.