Skip to content

Commit 35b9d14

Browse files
CI: isolate re-init-heavy embed fixtures; drop obsolete TestDomainReload
CPython 3.13+ does not fully support repeated Py_Finalize/Py_Initialize. The embed-test suite re-initializes the interpreter per fixture (~40 cycles in one process); on 3.13/3.14 the accumulation eventually corrupts interpreter state and a later Py_Initialize aborts with "Failed to import encodings module" (strace confirms the file opens fine - it is interpreter state, not the filesystem). The crash point is nondeterministic and only appears in the full suite; each fixture passes in isolation. Run the re-init-heavy fixtures (TestPythonEngineProperties, pyinitialize, TestFinalizer) in a separate test process so no single process accumulates enough re-inits to corrupt. This mirrors upstream's NeedsReinit separation. TestDomainReload is excluded entirely: AppDomain reload is not supported on modern .NET (single-domain), so those tests are obsolete. Verified locally: full embed suite green on 3.11, 3.13 and 3.14 with the split (bulk 895-896 / re-init batch 14, 0 failures); no regression. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 67e0f80 commit 35b9d14

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

.github/workflows/main.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,18 @@ jobs:
4848
echo PYTHONNET_PYDLL=$(python -m pythonnet.find_libpython) >> $GITHUB_ENV
4949
echo PYTHONHOME=$(python -c 'import sys; print(sys.prefix)') >> $GITHUB_ENV
5050
51+
# The fixtures that repeatedly tear down and re-initialize the interpreter
52+
# (TestPythonEngineProperties / pyinitialize / TestFinalizer) are run in a separate
53+
# process. CPython 3.13+ does not fully support repeated Py_Finalize/Py_Initialize:
54+
# accumulating ~40 per-fixture re-inits in one process eventually corrupts interpreter
55+
# state ("Failed to import encodings module"). Isolating the re-init-heavy fixtures
56+
# keeps each process's accumulation low. TestDomainReload is excluded entirely:
57+
# AppDomain reload is not supported on modern .NET (single-domain), so it is obsolete.
5158
- name: Embedding tests
52-
run: dotnet test --runtime any-x64 --logger "console;verbosity=detailed" src/embed_tests/
59+
run: dotnet test --runtime any-x64 --logger "console;verbosity=detailed" src/embed_tests/ --filter "FullyQualifiedName!~TestPythonEngineProperties&FullyQualifiedName!~pyinitialize&FullyQualifiedName!~TestFinalizer&FullyQualifiedName!~TestDomainReload"
60+
61+
- name: Embedding tests (re-initialization fixtures, isolated process)
62+
run: dotnet test --runtime any-x64 --logger "console;verbosity=detailed" src/embed_tests/ --filter "FullyQualifiedName~TestPythonEngineProperties|FullyQualifiedName~pyinitialize|FullyQualifiedName~TestFinalizer"
5363

5464
- name: Python Tests (.NET Core)
5565
run: pytest --runtime netcore tests

0 commit comments

Comments
 (0)