Skip to content

Add test coverage for interpreter loop generator overridden insts #142913

Description

@DinoV

The interpreter generator has long supported giving it multiple bytecodes files where the latter files override opcodes defined in the earlier opcodes. This enables PEP 523 hook users to generate an interpreter loop using the existing opcodes and their own set of customizations. But there've been no test cases that validate this actually works.

This adds such a test case and fixes things up so this practically works. static functions used directly in the interpreter loop are moved into ceval.h. APIs which are used but not exported are marked as exported.

Linked PRs

Activity

  1. self-assigned this
    on Dec 18, 2025
  2. added
    type-featureA feature request or enhancement
    testsTests in the Lib/test dir
    interpreter-core(Objects, Python, Grammar, and Parser dirs)
    and removed
    3.15bugs and security fixes
    on Dec 18, 2025
  3. added a commit that references this issue on Jan 16, 2026
  4. added a commit that references this issue on Jan 16, 2026
  5. added 2 commits that reference this issue on Jan 17, 2026
  6. encukou commented on Jan 19, 2026

    @encukou
    Member

    The newly added test test_replaced_interpreter fails when re-run, like in all refleaks buildbot runs.

    $ ./python -m test test_capi -R: -v -m test_replaced_interpreter
    == CPython 3.15.0a5+ (heads/main:bb2b9ba49d8, Jan 19 2026, 13:38:43) [GCC 15.2.1 20251211 (Red Hat 15.2.1-5)]
    == Linux-6.17.12-300.fc43.x86_64-x86_64-with-glibc2.42 little-endian
    == Python build: debug
    == cwd: /home/encukou/dev/cpython/build/test_python_worker_3768940æ
    == CPU count: 18 (process) / 20 (system)
    == encodings: locale=UTF-8 FS=utf-8
    == resources: all test resources are disabled, use -u option to unskip tests
    
    Using random seed: 826622625
    0:00:00 load avg: 0.42 Run 1 test sequentially in a single process
    0:00:00 load avg: 0.42 [1/1] test_capi
    beginning 9 repetitions. Showing number of leaks (. for 0 or less, X for 10 or more)
    12345:6789
    test_replaced_interpreter (test.test_capi.test_misc.Test_Pep523API.test_replaced_interpreter) ... ok
    
    ----------------------------------------------------------------------
    Ran 1 test in 0.000s
    
    OK
    Xtest_replaced_interpreter (test.test_capi.test_misc.Test_Pep523API.test_replaced_interpreter) ... FAIL
    
    ======================================================================
    FAIL: test_replaced_interpreter (test.test_capi.test_misc.Test_Pep523API.test_replaced_interpreter)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/encukou/dev/cpython/Lib/test/test_capi/test_misc.py", line 2875, in test_replaced_interpreter
        self.assertEqual(stats["resumes"], 5)
        ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
    AssertionError: 0 != 5
    
    ----------------------------------------------------------------------
    Ran 1 test in 0.003s
    
    FAILED (failures=1)
    test test_capi failed
    0:00:00 load avg: 0.42 [1/1/1] test_capi failed (1 failure)
    
    == Tests result: FAILURE ==
    
    1 test failed:
        test_capi
    
    Total duration: 179 ms
    Total tests: run=1 (filtered) failures=1
    Total test files: run=1/1 (filtered) failed=1
    Result: FAILURE
    
  7. added 2 commits that reference this issue on Jan 21, 2026
  8. encukou commented on Jan 22, 2026

    @encukou
    Member

    I've removed the test for now to get the buildbots green again.

  9. added a commit that references this issue on Jan 24, 2026
  10. added a commit that references this issue on Jan 24, 2026
  11. added 6 commits that reference this issue on Feb 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)testsTests in the Lib/test dirtype-featureA feature request or enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions