{ "instance_id": "CPython_PEP-820-PySlot-Unified-Slot-System_PR-149055", "project": "CPython", "requirement_doc": "https://peps.python.org/pep-0820/", "pr_link": "https://github.com/python/cpython/pull/149055", "pr_merge_date": "2026-04-23", "language": "C/Python", "build_system": "configure+make", "scope": { "touched_modules": [ "Doc", "Include", "Lib", "Misc", "Modules", "Objects", "PC", "Python" ], "f2p_module": "Lib/test/test_capi", "p2p_module": "Lib/test", "total_files_changed": 56 }, "base_commit": "5dd21617164cf69e848a70e3d7e32faf0bc3f279", "diff_source": "gh_api_pr_files", "solution_patch_sha256": "6a0b2d52f53a8e1dce904a4e89b61ba7728b72bd6da21bf45af5b050633bfb93", "eval_tests_patch_sha256": "e2c7617487e9dba0c8d0c53ba25edb7d707dc24972b23db45e0cd9f757bf4c49", "eval_helpers_patch_sha256": "c30bfffa181338fe2803aa29d8fca409252511eda7628496fd7856f8638a0821", "omitted_patch_sha256": "46b9b767765c9b4e2af7ab88e9ad8abff952a475edd3cb1f8e9f570ecce14b42", "toolchain": { "python_bootstrap": "system python3", "gcc": "11+" }, "build_modules": [ "./python" ], "test_framework": "cpython-unittest", "test_level": "system", "fail_to_pass": [ "test.test_capi.test_slots.TypeSlotsTests.test_basic_type_slots", "test.test_capi.test_slots.TypeSlotsTests.test_mod_slot_in_type", "test.test_capi.test_slots.TypeSlotsTests.test_size_slots", "test.test_capi.test_slots.TypeSlotsTests.test_flag_slots", "test.test_capi.test_slots.TypeSlotsTests.test_func_slots", "test.test_capi.test_slots.TypeSlotsTests.test_optional_end", "test.test_capi.test_slots.TypeSlotsTests.test_invalid", "test.test_capi.test_slots.TypeSlotsTests.test_compat_slot_numbers", "test.test_capi.test_slots.TypeSlotsTests.test_nonstatic_tp_members", "test.test_capi.test_slots.TypeSlotsTests.test_intptr_flags", "test.test_capi.test_slots.TypeSlotsTests.test_nested", "test.test_capi.test_slots.TypeSlotsTests.test_null_slot_handling", "test.test_capi.test_slots.TypeSlotsTests.test_repeat_warning", "test.test_capi.test_slots.TypeSlotsTests.test_repeat_error", "test.test_capi.test_slots.ModuleSlotsTests.test_basic_module_slots", "test.test_capi.test_slots.ModuleSlotsTests.test_type_slot_in_module", "test.test_capi.test_slots.ModuleSlotsTests.test_size_slots", "test.test_capi.test_slots.ModuleSlotsTests.test_flag_slots", "test.test_capi.test_slots.ModuleSlotsTests.test_exec_slot", "test.test_capi.test_slots.ModuleSlotsTests.test_optional_end", "test.test_capi.test_slots.ModuleSlotsTests.test_invalid", "test.test_capi.test_slots.ModuleSlotsTests.test_compat_slot_numbers", "test.test_capi.test_slots.ModuleSlotsTests.test_compat_slot_number_create", "test.test_capi.test_slots.ModuleSlotsTests.test_compat_slot_number_gil", "test.test_capi.test_slots.ModuleSlotsTests.test_nonstatic_mod_methods", "test.test_capi.test_slots.ModuleSlotsTests.test_intptr_methods", "test.test_capi.test_slots.ModuleSlotsTests.test_nested", "test.test_capi.test_slots.ModuleSlotsTests.test_nested_nonstatic_from_def", "test.test_capi.test_slots.ModuleSlotsTests.test_null_slot_handling", "test.test_capi.test_slots.ModuleSlotsTests.test_repeat_error", "test.test_capi.test_module.TestModFromSlotsAndSpec.test_repeated_def_slot", "test.test_capi.test_misc.CAPITest.test_tp_bases_slot_none", "test.test_capi.test_misc.TestHeapTypeRelative.test_heaptype_relative_members_errors", "test.test_capi.test_misc.TestHeapTypeRelative.test_heaptype_relative_special_members_errors", "test.test_stable_abi_ctypes.TestStableABIAvailability.test_available_symbols" ], "pass_to_pass": [ "test.test_int.IntTestCases.test_basic", "test.test_int.IntTestCases.test_invalid_signs", "test.test_int.IntTestCases.test_unicode", "test.test_capi.test_type.BuiltinStaticTypesTests.test_tp_bases_is_set", "test.test_capi.test_type.BuiltinStaticTypesTests.test_tp_mro_is_set", "test.test_capi.test_type.TypeTests.test_extension_managed_dict_type", "test.test_capi.test_type.TypeTests.test_extension_managed_weakref_nogc_type", "test.test_capi.test_type.TypeTests.test_freeze", "test.test_capi.test_type.TypeTests.test_freeze_meta", "test.test_capi.test_type.TypeTests.test_get_base_by_token", "test.test_capi.test_type.TypeTests.test_get_module_by_def", "test.test_capi.test_type.TypeTests.test_get_module_by_token", "test.test_capi.test_type.TypeTests.test_get_type_name", "test.test_capi.test_type.TypeTests.test_manual_heap_type", "test.test_capi.test_abstract.CAPITest.test_iter_next", "test.test_capi.test_abstract.CAPITest.test_iter_nextitem", "test.test_capi.test_abstract.CAPITest.test_mapping_check", "test.test_capi.test_abstract.CAPITest.test_mapping_delitemstring", "test.test_capi.test_abstract.CAPITest.test_mapping_getitemstring", "test.test_capi.test_abstract.CAPITest.test_mapping_getoptionalitem", "test.test_capi.test_abstract.CAPITest.test_mapping_getoptionalitemstring", "test.test_capi.test_abstract.CAPITest.test_mapping_haskey", "test.test_capi.test_abstract.CAPITest.test_mapping_haskeystring", "test.test_capi.test_abstract.CAPITest.test_mapping_haskeystringwitherror", "test.test_capi.test_abstract.CAPITest.test_mapping_haskeywitherror", "test.test_capi.test_abstract.CAPITest.test_mapping_keys_valuesitems", "test.test_capi.test_abstract.CAPITest.test_mapping_keys_valuesitems_bad_arg", "test.test_capi.test_abstract.CAPITest.test_mapping_setitemstring", "test.test_capi.test_abstract.CAPITest.test_mapping_size", "test.test_capi.test_abstract.CAPITest.test_object_ascii", "test.test_capi.test_abstract.CAPITest.test_object_bytes", "test.test_capi.test_abstract.CAPITest.test_object_delattr", "test.test_capi.test_abstract.CAPITest.test_object_delattrstring", "test.test_capi.test_abstract.CAPITest.test_object_delitem", "test.test_capi.test_abstract.CAPITest.test_object_generichash", "test.test_capi.test_abstract.CAPITest.test_object_getattr", "test.test_capi.test_abstract.CAPITest.test_object_getattrstring", "test.test_capi.test_abstract.CAPITest.test_object_getitem", "test.test_capi.test_abstract.CAPITest.test_object_getoptionalattr", "test.test_capi.test_abstract.CAPITest.test_object_getoptionalattrstring", "test.test_capi.test_abstract.CAPITest.test_object_hasattr", "test.test_capi.test_abstract.CAPITest.test_object_hasattrstring", "test.test_capi.test_abstract.CAPITest.test_object_hasattrstringwitherror", "test.test_capi.test_abstract.CAPITest.test_object_hasattrwitherror", "test.test_capi.test_abstract.CAPITest.test_object_repr", "test.test_capi.test_abstract.CAPITest.test_object_setattr", "test.test_capi.test_abstract.CAPITest.test_object_setattr_null_exc", "test.test_capi.test_abstract.CAPITest.test_object_setattrstring", "test.test_capi.test_abstract.CAPITest.test_object_setitem", "test.test_capi.test_abstract.CAPITest.test_object_str" ], "synthetic_tests": [], "triage": { "fail_to_pass": { "_summary": "PEP 820 introduces PySlot \u2014 a unified C-API slot system. 30 F2P from NEW Lib/test/test_capi/test_slots.py (TypeSlotsTests + ModuleSlotsTests, all ERROR pre-patch because _testlimitedcapi.type_from_slots/module_from_slots do not exist). 1 F2P from test_module.py (test_repeated_def_slot \u2014 assertion regex changed). 3 F2P from test_misc.py (test_tp_bases_slot_none + 2 test_heaptype_relative_*_errors \u2014 assertion text changed). 1 F2P from test_stable_abi_ctypes.py (test_available_symbols \u2014 PyType_FromSlots added to expected exports, pre-state ctypes lookup FAILS). Note: test_null_def_slot was excluded from F2P because its diff only narrows the loop set (removes Py_mod_state_size) \u2014 pre-state with the patched-narrowed loop still passes since the remaining slot names error correctly in base C code." }, "pass_to_pass": { "_summary": "Original P2P contains the three pre-existing test.test_int baseline selectors plus 47 pre-existing C-API selectors added on 2026-06-15 from test.test_capi.test_type and test.test_capi.test_abstract. These exercise adjacent type/object/mapping C-API behavior that may be affected by PySlot changes but is not required by PEP 820." }, "module_scope_rationale": "test_capi.test_slots is the canonical home for PEP 820 slot tests; test_capi.test_module covers module-slot updates; the original P2P set uses test_int as a stable baseline plus adjacent test_capi.test_type and test_capi.test_abstract selectors for C-API type/object/mapping behavior not required by PEP 820." }, "f2p_entry_count": 35, "p2p_entry_count": 50, "timeout_s": 7200, "resource_caps": { "cpu": 4, "mem_gb": 14 }, "validated_at": "2026-06-15", "build_status": "verified", "coverage_measurement_note": "Coverage refreshed on 2026-06-15 after adding 47 pre-existing original P2P selectors. The corrected PEP-820 harness measures 527 executable C lines in solution.patch: orig covers 348/527 (66.0%), union covers 350/527 (66.4%), and the expanded P2P lane covers 211/527 (40.0%). coverage_report.json mirrors coverage_report_union.json; coverage_report_orig.json and coverage_report_union.json are the canonical orig/union audit reports.", "repo": "python/cpython", "image": "lolbench/cpython-pr-149055:1", "pr_head_sha": "06b2c3dfcabffe0a959a4df309039f7463414d02", "merge_commit_sha": "06b2c3dfcabffe0a959a4df309039f7463414d02", "agent_contract": { "input": "/in/solution.patch", "output": "/out/agent_report.json", "invocation": "docker run --rm --memory 14g --cpus 4 -v $(pwd)/solution.patch:/in/solution.patch:ro -v $(pwd)/out:/out lolbench/cpython-pr-149055:1" }, "test_cmd_template": "./run_tests.sh ", "log_parser": "generic_log", "augmented": { "suite_support": [ "orig", "aug", "union" ], "eval_tests_patch": "eval_tests_aug.patch", "eval_tests_aug_helpers_patch": "eval_tests_aug_helpers.patch", "eval_tests_aug_patch_sha256": "69d4bcb6b61a3f353b8f25fea680d30a9174670a1f5810d15d518dd7da9dcbb2", "eval_tests_aug_helpers_patch_sha256": "5f835fac390a44bf9c5e0b1e987e6091f15c33ee337e010bf587bb4851fb8ff9", "f2p_aug_sha256": "ce155cb6a5c7859b312e1e3a862567e326ff5ecfc6789d6b5ecb07073c97091b", "p2p_aug_sha256": "e102dd5cdbf5dac10cd8c46d7f9130641f18ef745cf217024ad1f22ef2e99dd8", "patch_split_rationale": "eval_tests_aug.patch adds only new Python test files (Lib/test/test_capi/test_slots_aug.py, test_slots_compat_aug.py) so it applies in every state including validate_pre (where the augmented tests then ERROR because the _testlimitedcapi slot helpers do not exist pre-solution). eval_tests_aug_helpers.patch adds C test cases to Modules/_testlimitedcapi/slots.c, which is created by eval_helpers.patch (the Pattern-E test-scaffolding patch carrying the _testcapi/_testlimitedcapi/_testmultiphase C helpers plus their Modules/Setup.stdlib.in build registration, split out of solution.patch), so run_tests.sh applies both only when a source patch is present.", "fail_to_pass": [ "test.test_capi.test_slots_aug.SlotsAugTests.test_token_use_spec_requires_pytype_spec", "test.test_capi.test_slots_aug.SlotsAugTests.test_tp_bases_overrides_tp_base", "test.test_capi.test_slots_aug.SlotsAugTests.test_slots_only_module_requires_mod_abi" ], "pass_to_pass": [ "test.test_capi.test_slots_compat_aug.SlotsCompatAugTests.test_three_arg_type_construction_contract" ], "targets_mutants": [ "mutant_018_pytype_use_spec_token_allowed", "mutant_019_tp_base_overrides_tp_bases", "mutant_021_module_abi_requirement_disabled" ], "mutation_summary": { "mutants_total": 21, "killed_by_original": 14, "newly_killed_by_aug": 3, "equivalent_excluded": 4, "result": "all_non_equivalent_killed", "newly_killed": { "mutant_018_pytype_use_spec_token_allowed": "test_token_use_spec_requires_pytype_spec \u2014 Py_tp_token=Py_TP_USE_SPEC under PyType_FromSlots (spec=NULL) must raise SystemError; mutant skips the !spec guard and builds the type. Verified aug f2p 2 passed / 1 failed under the mutant.", "mutant_019_tp_base_overrides_tp_bases": "test_tp_bases_overrides_tp_base \u2014 with both Py_tp_bases and Py_tp_base set, Py_tp_bases wins (cls.__bases__ == (A,)); mutant forces Py_tp_base to override. Verified aug f2p 2 passed / 1 failed.", "mutant_021_module_abi_requirement_disabled": "test_slots_only_module_requires_mod_abi \u2014 a slots-only module without Py_mod_abi must raise SystemError; mutant skips the mandatory-Py_mod_abi check. Verified aug f2p 2 passed / 1 failed." }, "equivalent_mutants": { "members": [ "mutant_002_intptr_flag_is_zero", "mutant_005_type_legacy_slots_not_intptr", "mutant_006_module_legacy_slots_not_intptr", "mutant_011_intptr_casting_disabled" ], "classification": "equivalent_on_eval_architecture", "rationale": "All four are the PySlot INTPTR family. struct PySlot stores its payload in an anonymous union where sl_ptr, sl_size, sl_int64 and sl_uint64 overlay the same 8-byte slot; the INTPTR handler only does result->sl_size = (Py_ssize_t)(intptr_t)result->sl_ptr, a bit-for-bit no-op when sizeof(void*) == sizeof(Py_ssize_t) == sizeof(int64_t) == 8 with uniform endianness \u2014 the PR's own source comment states it 'should compile to nothing on common architectures'. The eval image is x86-64 (ubuntu:22.04), so the value written via sl_ptr and read via sl_size/sl_uint64 is identical bits whether or not the cast/flag runs. No value assertion in C or Python can distinguish golden from these mutants on this platform. The original 35 F2P already report 35/35 passing for each (undetected), and the augmented suite targets unrelated code (Py_tp_token / Py_tp_bases / Py_mod_abi), so union(orig+aug) cannot kill them either. They are excluded as architecture-equivalent; they would only be killable on a 32-bit or big-endian build, which this benchmark does not run." } }, "coverage_gate": { "minimum_line_coverage_percent": 80, "status": "below_target_documented", "coverage_report": "coverage_out/coverage_report_union.json", "union_line_coverage_percent": 66.4, "union_covered_lines": 350, "executable_lines_in_patch": 527, "coverage_complete": true, "per_file": { "Objects/moduleobject.c": "47/62 (75%)", "Objects/typeobject.c": "126/177 (71%)", "Python/slots.c": "177/287 (61%)", "Python/import.c": "0/1" }, "harness_fix_note": "The shipped coverage/run_coverage.sh was an un-adapted copy of the PEP-810 harness (its gcovr --filter matched lazyimportobject.c/import.c and measured only 63 lines, ignoring typeobject.c/Python/slots.c, which is why the historical pre-fix report read 74.6% of a wrong 63-line scope). It is corrected here to filter the PEP-820 source files (Objects/{typeobject,moduleobject}.c, Python/{slots,slots_generated,import,importdl}.c) and to run the union suite, giving a real 527-line scope. coverage_report.json now mirrors coverage_report_union.json.", "below_target_rationale": "The PR's own 35-test F2P suite covers 66.0% of the PySlot source; the augmented union suite reaches 66.4%. The 47 added pre-existing original P2P selectors broaden adjacent type/object/mapping C-API regression coverage and cover 211 executable patch lines, but they mostly overlap the F2P-covered PySlot lines. Every named _testlimitedcapi test case is already exercised by orig+aug (the 4 unused cases are legacy-slot-number duplicates of covered ones), so the residual 177 uncovered lines are defensive/edge branches in Python/slots.c (slot-validation, nesting-limit and legacy-conversion error paths) and typeobject.c that the feature does not reach through its public PyType_FromSlots / PyModule_FromSlotsAndSpec surface. Closing to 80% would require bespoke new C test cases targeting individual uncovered branches, beyond the mutant-killing remit of this augmentation. All 17 non-equivalent mutants are killed; the 4 INTPTR mutants are architecture-equivalent." }, "validation": { "augmented_pre": { "f2p": { "passed": 0, "failed": 0, "errored": 3, "total": 3 }, "p2p": { "passed": 1, "failed": 0, "errored": 0, "total": 1 }, "resolved": false }, "augmented_post": { "f2p": { "passed": 3, "failed": 0, "errored": 0, "total": 3 }, "p2p": { "passed": 1, "failed": 0, "errored": 0, "total": 1 }, "resolved": true }, "mutants": { "suite": "aug", "result": "all_targeted_killed", "per_mutant": "018 -> test_token_use_spec_requires_pytype_spec (f2p 2/1); 019 -> test_tp_bases_overrides_tp_base (f2p 2/1); 021 -> test_slots_only_module_requires_mod_abi (f2p 2/1). The INTPTR family (002/005/006/011) is documented as architecture-equivalent and excluded." } }, "triage": { "test_level": "system", "fail_to_pass": { "test.test_capi.test_slots_aug.SlotsAugTests.test_token_use_spec_requires_pytype_spec": { "public_surface": "PyType_FromSlots with a Py_tp_token=Py_TP_USE_SPEC slot, via _testlimitedcapi.type_from_slots('token_use_spec').", "rationale": "PEP 820 specifies Py_TP_USE_SPEC may only be used through PyType_Spec; the slots-only path must reject it with SystemError." }, "test.test_capi.test_slots_aug.SlotsAugTests.test_tp_bases_overrides_tp_base": { "public_surface": "PyType_FromSlots with both Py_tp_bases and Py_tp_base, via _testlimitedcapi.type_from_base_and_bases.", "rationale": "PEP 820: Py_tp_bases overrides Py_tp_base when both are present; asserts cls.__bases__ reflects Py_tp_bases." }, "test.test_capi.test_slots_aug.SlotsAugTests.test_slots_only_module_requires_mod_abi": { "public_surface": "PyModule_FromSlotsAndSpec from a slots-only array omitting Py_mod_abi, via _testlimitedcapi.module_from_slots_no_abi.", "rationale": "PEP 820: Py_mod_abi is mandatory for modules defined from slots only; omitting it is a SystemError." } }, "pass_to_pass": { "test.test_capi.test_slots_compat_aug.SlotsCompatAugTests.test_three_arg_type_construction_contract": { "public_surface": "Builtin three-argument type() construction.", "rationale": "Stable type-construction contract independent of the PySlot feature; passes pre and post." } } } }, "coverage": { "orig": 66.0, "aug": 66.4, "union": 66.4, "denominator": "union_executable_lines", "aug_note": "equals union; harness does not isolate augmented-only suite", "orig_report": "coverage_out/coverage_report_orig.json", "union_report": "coverage_out/coverage_report_union.json", "coverage_report_json": "coverage_out/coverage_report.json mirrors union", "orig_covered_lines": 348, "union_covered_lines": 350, "p2p_covered_lines": 211, "executable_lines_in_patch": 527 } }