Skip to content

fix(tests): make two tests hold on free-threaded CPython 3.14t (#1731) - #1734

Merged
JarryShaw merged 1 commit into
mainfrom
fix/1731-free-threaded-warnings
Oct 14, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/1731-free-threaded-warnings

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

Please follow the guide below

What is the purpose of your pull request?

Tick the commit type your subject line carries.

  • fix — corrects a defect
  • feat — adds a feature
  • perf — changes performance, not behaviour
  • refactor — changes neither behaviour nor performance
  • test — tests only
  • docs — documentation only
  • ci — workflows or build tooling
  • release — bumps the version or rolls up a distribution
  • chore — anything else

Description of your pull request and other information

Closes #1731. Two tests failed on free-threaded CPython 3.14t. Each came from a wrong assumption in the test, not a pcapkit defect, so no library code changes.

  • test_hold_is_local_to_its_context: under context-aware warnings, catch_warnings records through a ContextVar that an empty Context lacks. Free-threaded builds turn that on by default (CPython docs: -X context_aware_warnings). The failure follows the flag both ways: it fails on regular 3.14 with =1 and passes on 3.14t with =0. The test now warns in a context copied before the block, and in an empty context that records for itself.
  • test_the_captured_len_vector_parses_under_a_memory_cap: this one is not about warnings, since it fails on 3.14t with the flag off. mimalloc reserves 1 GiB at start-up (Objects/mimalloc/options.c:86-87), so the 512 MiB RLIMIT_AS was used up before the parse began. The cap is now 512 MiB above what is already mapped. The child also runs under PYTHONMALLOC=mimalloc where the build has it, so a GIL leg covers this case too.

Tests:

  • Both files pass on 3.14t, and on 3.14 with the flag at 0 and at 1, plus on 3.11 and 3.8.
  • On main both fail on 3.14t.
  • An unbounded-padding mutant and a global-hold mutant each still fail the fixed tests.

Two test assumptions, two root causes; no pcapkit change.

- test_trial_parse_warnings_1580_unit: test_hold_is_local_to_its_context
  recorded a warning from an empty context with the enclosing
  catch_warnings, which context-aware warnings (on by default on a
  free-threaded build) keep in a context variable that context lacks. It
  now warns in a context copied before the block, and in an empty context
  that records for itself.
- test_pcapng_unit: the #594 memory-cap subprocess capped the address
  space at 512 MiB in all, but mimalloc, which a free-threaded build always
  uses, reserves 1 GiB as the interpreter starts, so the child died loading
  chardet. The cap is now 512 MiB over what is already mapped; the child
  runs again under PYTHONMALLOC=mimalloc where the build has it, and its
  stderr goes into the failure message.

Tests: both files pass on 3.14t (context_aware_warnings 1 and 0), 3.14
(0 and 1), 3.11 and 3.8; both tests fail on origin/main on 3.14t.

Closes #1731
@JarryShaw JarryShaw added fix Pull requests that fix a defect (fix: subject prefix) review: good-to-go Cross-review at the current head says ready; CI state is separate labels Oct 14, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Verdict: GOOD TO GO at ba67ef70e. A Sonnet cross-review checked it on its own free-threaded 3.14t (author: Opus).

  • Two separate causes:
    • The hold test's failure follows -X context_aware_warnings both ways.
    • The memory-cap test fails on 3.14t even with that flag off, because mimalloc's 1 GiB start-up reservation uses up the 512 MiB RLIMIT_AS. Checked against CPython's Objects/mimalloc/options.c.
  • Not weakened: both tests still catch their mutants (unbounded padding, a global hold). No library code changes.
  • Interpreters: both pass on 3.14t, on 3.14 with the flag at 0 and at 1, and on 3.11 and 3.8.

@JarryShaw JarryShaw moved this to In review in PyPCAPKit Oct 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage: 89.65% (unit tier, Python 3.15, ba67ef70e, Unit Tests run failure)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 3 20 3 95.16%
pcapkit/const 18860 954 2368 868 91.06%
pcapkit/corekit 2384 67 764 35 96.51%
pcapkit/dumpkit 275 3 100 3 98.40%
pcapkit/foundation 2885 144 1010 34 94.20%
pcapkit/interface 138 7 52 5 93.68%
pcapkit/protocols 17174 226 4590 190 98.07%
pcapkit/toolkit 1015 173 372 10 80.89%
pcapkit/utilities 508 4 154 4 98.79%
pcapkit/vendor 4417 2342 1010 157 43.38%

Per-file detail: the coverage-html artifact of this run.

@JarryShaw
JarryShaw merged commit 4e1720c into main Oct 14, 2026
86 of 88 checks passed
@JarryShaw
JarryShaw deleted the fix/1731-free-threaded-warnings branch October 14, 2026 17:56
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 14, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Pull requests that fix a defect (fix: subject prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

fix(tests): two tests fail on free-threaded CPython 3.14t, likely from context-aware warnings

1 participant