Skip to content

Sync remaining Python 3.15.2 test isolation helpers and coverage - #9911

Merged
youknowone merged 3 commits into
RustPython:mainfrom
youknowdot:update/lib-tests-3152-remainder-20261117
Nov 18, 2026
Merged

youknowone merged 3 commits into
RustPython:mainfrom
youknowdot:update/lib-tests-3152-remainder-20261117

Conversation

@youknowdot

@youknowdot youknowdot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Part of #9852. Batch the remaining related Python-only test infrastructure updates through scripts/update_lib:

  • Synchronize subprocess isolation helpers and sample fixtures with canonical CPython 3.15.2 (options, environment, timeout, bigmem isolation).
  • Bring in canonical support/subTests coverage, thread-helper class validation and FreeBSD descriptor-counting handling.
  • Add canonical SQLite DBM bool/bytearray/memoryview input cases and the ssl ordering comment.

The imported files follow CPython 3.15.2, except the explicitly justified isolation-helper fixes below. The JSON free-threading test is also synchronized with canonical 3.15.2, moving thread cleanup from the class to its three methods to match the upgraded helper. Existing RustPython support/init.py and other adaptations remain untouched. No bespoke repository tests, Rust changes or newly introduced skips/xfails.

Validation

  • RustPython test_support: 72 tests, 3 skipped, passed. Skips: missing builtin _sha2.sha512; cpu resource disabled; CPython source directory unavailable.
  • RustPython test_dbm_sqlite3: 30 tests, 1 skipped, passed, using the existing SQLite-enabled debug binary.
  • RustPython test_unittest: 1,101 tests, 3 skipped, passed with one discovery-path test filtered. The initial full run failed only that test because isolated subprocesses use the preserved binary's original Lib root rather than this worktree. The same test passed when the binary and Lib source roots were aligned. test_script_helper and test_threading_local also passed.
  • CPython 3.15.2 focused isolation/subTests reference: 20 tests passed. Its full support run hit six failures because this installed reference binary lacks test in isolated-mode paths; not a full reference pass. SQLite DBM reference passed.
  • Normal commit hooks passed. No fresh native rebuild, workspace/CAPI/Clippy, Windows/macOS/FreeBSD or performance execution. Existing binaries predate current main; CI must validate the final source checkout.

Remaining work

This does not close #9852. Canonical re LOCALE-negated-set, ssize-minimum format width and zlib negative combine-length tests exposed native failures and were left out for separate fixes, rather than marking them expected failures in this Python-only batch. Existing deliberate RustPython adaptations and deferred CAPI tests also require explicit accounting before the tracker can close.

AI-assisted by OpenAI Codex (GPT-6.1).

Review follow-up: worker lifecycle and inherited output

Both review findings also reproduce in the unmodified CPython 3.15.2 helper. A raising tick/KeyboardInterrupt left its worker alive; a 0.3-second timeout waited 2.45 seconds for a descendant holding inherited stdout/stderr pipes.

The helper now kills and reaps its direct worker on interrupted waits and captures output in temporary files. It waits only for that worker and snapshots a bounded file extent, never waiting for descendant pipe EOF. POSIX positional reads and an independent Windows delete-sharing/binary reader avoid changing the shared writer offset. Files and the result path are cleaned up. No process-group/session change or descendant termination is introduced.

This is an intentional upstream divergence: captured output is now a regular file (including seekability/fstat behavior), and output written later by surviving descendants is best-effort rather than awaited. Windows temporary-file deletion is deferred by the OS while inherited handles remain open.

Validation after this change:

  • Existing RustPython test_support: 72 tests, 2 skipped, passed under the shared test/build lock.
  • External focused cleanup/output probes: 3 passed on RustPython and CPython 3.15.2. Actual worker interruption is reaped and inherited-descendant timeout returns in 0.30 seconds. No custom test assertions were added to canonical Lib/test files.
  • Independent source review identified a shared-offset problem in the initial candidate; it was fixed before publication. No further confirmed blocker was found.
  • Normal commit hooks passed. Windows/macOS execution, full hosted CI, fresh native builds and performance comparison remain unverified for this revision. Existing binaries were reused; no native-code change is made.

Use update_lib to synchronize subprocess options, environment and timeout handling, related canonical support tests, and SQLite DBM input coverage. Preserve RustPython-specific support adaptations. Part of RustPython#9852.

Assisted-by: OpenAI Codex:GPT-6.1
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters: 1

  • Lib/test/support/isolation.py is excluded by !Lib/**

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@youknowone
youknowone marked this pull request as ready for review November 17, 2026 15:36
@youknowone
youknowone enabled auto-merge (squash) November 17, 2026 15:36
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T17:28:20.372080Z 2e0405e New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 70ecedcf42

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +168 to +170
finally:
try:
os.unlink(self._result_path)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restore worker cleanup when waiting is interrupted

If the waiting parent receives KeyboardInterrupt while the worker ignores or does not receive SIGINT, or if tick() raises, this finally block only deletes the result file: the worker remains running and its captured pipes remain open. The previous subprocess.run() path killed the worker on exceptions, so interrupting a long-running isolated test now leaks a process that can continue consuming memory and CPU. Add exceptional-exit cleanup to terminate and reap the worker and close its pipes.

Useful? React with 👍 / 👎.

Comment thread Lib/test/support/isolation.py Outdated
Comment on lines +155 to +156
self._proc.kill()
stdout, stderr = self._proc.communicate()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bound output collection after killing a timed-out test

On POSIX, if the isolated test spawns a descendant that inherits stdout/stderr, killing the test process leaves the descendant's copies of those pipe handles open. The subsequent unbounded communicate() waits for EOF until that descendant exits, so runInSubprocess(timeout=...) can still hang indefinitely instead of reporting the timeout. Keep post-kill output collection bounded, or terminate the subprocess group, before raising the timeout error.

Useful? React with 👍 / 👎.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

📦 Library Dependencies

The following Lib/ modules were modified. Here are their dependencies:

[ ] test: cpython/Lib/test/test_free_threading (TODO: 1)

dependencies:

dependent tests: (no tests depend on free_threading)

[x] lib: cpython/Lib/ssl.py
[ ] test: cpython/Lib/test/test_ssl.py

dependencies:

  • ssl

dependent tests: (57 tests)

  • ssl: test_asyncio test_ftplib test_httplib test_httpservers test_imaplib test_logging test_poplib test_ssl test_urllib test_urllib2_localnet test_venv test_xmlrpc
    • asyncio.selector_events: test_asyncio
    • ftplib: test_urllib2
      • urllib.request: test_http_cookiejar test_pathlib test_pydoc test_sax test_site test_urllib2net test_urllibnet
    • http.client: test_docxmlrpc test_hashlib test_ucn test_unicodedata test_wsgiref
      • logging.handlers: test_concurrent_futures test_pkgutil
    • http.server: test_robotparser
      • pydoc: test_enum
    • smtplib: test_smtplib test_smtpnet
    • urllib.request:
      • pathlib: test_ast test_dbm_sqlite3 test_ensurepip test_importlib test_json test_launcher test_netrc test_os test_pathlib test_peg_generator test_profiling test_pyrepl test_runpy test_tarfile test_tempfile test_tomllib test_tools test_traceback test_unparse test_winapi test_zipapp test_zipfile test_zoneinfo test_zstd
      • xml.dom.xmlbuilder: test_minidom

[ ] lib: cpython/Lib/test/support
[x] test: cpython/Lib/test/test_support.py
[x] test: cpython/Lib/test/test_script_helper.py

dependencies:

  • support (native: main, _hashlib, _helpers, _imp, _interpchannels, _opcode, _remote_debugging, _testcapi, _testinternalcapi, _testlimitedcapi, _thread, _winapi, asyncio.events, collections.abc, concurrent.interpreters, concurrent.interpreters._crossinterp, ctypes.wintypes, email._header_value_parser, errno, faulthandler, gc, hypothesis, hypothesis.configuration, hypothesis.database, import_helper, importlib.machinery, importlib.util, logging.handlers, marshal, math, msvcrt, os.path, os_helper, pwd, resource, script_helper, select, setuptools, setuptools._distutils, sys, time, unicodedata, unittest.case, unittest.mock, urllib.error, urllib.parse, urllib.request, zlib)
    • _pyrepl (native: _module_completer, _threading_handler, base_eventqueue, builtins, collections.abc, completing_reader, console, content, ctypes.wintypes, errno, fancy_termios, fancycompleter, fcntl, historical_reader, importlib.machinery, itertools, keymap, layout, main, nt, pager, posix, reader, readline, render, select, simple_interact, sys, terminfo, termios, time, unicodedata, unix_console, unix_eventqueue, utils, windows_console, windows_eventqueue)
    • ctypes (native: _ctypes, ctypes._aix, ctypes._endian, ctypes.macholib.dyld, ctypes.macholib.dylib, ctypes.macholib.framework, importlib.machinery, itertools, nt, sys)
    • io (native: _io, _thread, errno, msvcrt, sys)
    • opcode (native: _opcode, builtins)
    • platform (native: _wmi, itertools, sys, vms_lib, winreg)
    • sysconfig (native: _sysconfig, _winapi, importlib.machinery, importlib.util, os.path, sys)
    • unittest (native: _io, _log, async_case, builtins, case, loader, main, os.path, result, runner, signals, suite, sys, time, unittest.util, util)
    • _colorize, annotationlib, ast, bz2, codecs, collections, compression, contextlib, dataclasses, datetime, decimal, dis, enum, functools, getopt, getpass, glob, gzip, importlib, inspect, locale, logging, lzma, multiprocessing, os, pathlib, py_compile, re, selectors, shlex, shutil, signal, smtplib, socket, stat, string, struct, subprocess, tempfile, textwrap, threading, tkinter, tracemalloc, types, venv, warnings, zipfile

dependent tests: (2 tests)

  • support: test_pathlib test_pyrepl

[x] lib: cpython/Lib/dbm
[ ] test: cpython/Lib/test/test_dbm.py (TODO: 2)
[x] test: cpython/Lib/test/test_dbm_dumb.py
[x] test: cpython/Lib/test/test_dbm_gnu.py
[x] test: cpython/Lib/test/test_dbm_ndbm.py
[x] test: cpython/Lib/test/test_dbm_sqlite3.py

dependencies:

  • dbm

dependent tests: (5 tests)

  • dbm: test_dbm test_dbm_dumb test_dbm_ndbm test_dbm_sqlite3 test_shelve

Legend:

  • [+] path exists in CPython
  • [x] up-to-date, [ ] outdated

Move reap_threads from the test class to its three test methods, matching canonical CPython 3.15.2. The upgraded helper deliberately rejects class decorators. Preserve all assertions and thread cleanup; do not weaken the helper.

Assisted-by: OpenAI Codex:GPT-6.1
auto-merge was automatically disabled November 17, 2026 16:46

Head branch was pushed to by a user without write access

Reap the direct worker when a tick or parent wait is interrupted. Capture output in temporary files so inherited descendant handles cannot hold timeout reporting open. Snapshot without altering the shared writer offset, with delete-sharing independent readers on Windows.

This intentionally fixes two defects also present in canonical CPython 3.15.2. Process groups and test assertions remain unchanged. Windows runtime validation remains pending hosted CI.

Assisted-by: OpenAI Codex:GPT-6.1

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2e0405e351

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

(3.14, b"3.14"),
("string", b"string"),
(b"bytes", b"bytes"),
(True, b"1"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Revert non-marker edits to CPython test data

These added cases directly modify test data, and the same patch makes further non-marker test-logic changes under Lib/test. The repository's critical policy permits only adding or removing RustPython failure markers in CPython test files and explicitly forbids test logic or data edits, so these changes must not be landed directly.

AGENTS.md reference: AGENTS.md:L76-L81

Useful? React with 👍 / 👎.

if os.path.exists(f"/dev/fd/{dirfd}"):
names = list(os.scandir(dirfd))
# Don't count dirfd
return len(names) - 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Exclude scandir's duplicate fd from the count

When /proc/self/fd is unavailable on FreeBSD but fdescfs is mounted, RustPython's FdDirStream::from_fd() preserves dirfd by duplicating it, and fdescfs exposes both descriptors in this names list. Subtracting only one therefore makes fd_count() report one descriptor too many on this path; account for both helper descriptors or enumerate without creating the second one.

Useful? React with 👍 / 👎.

@codspeed

codspeed Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 62 untouched benchmarks
⏩ 4 skipped benchmarks1


Comparing youknowdot:update/lib-tests-3152-remainder-20261117 (2e0405e) with main (b1665f0)2

Open in CodSpeed

Footnotes

  1. 4 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (e634ec6) during the generation of this report, so b1665f0 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@youknowone
youknowone merged commit c53b44c into RustPython:main Nov 18, 2026
22 checks passed
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.

Upgrade Python libraries and tests from Python 3.15

3 participants