Skip to content

gh-146453: fix _PyType_LookupByVersion for types with fixed pre-defined version tags#146454

Merged
kumaraditya303 merged 1 commit intopython:mainfrom
kumaraditya303:type-version
Mar 26, 2026
Merged

gh-146453: fix _PyType_LookupByVersion for types with fixed pre-defined version tags#146454
kumaraditya303 merged 1 commit intopython:mainfrom
kumaraditya303:type-version

Conversation

@kumaraditya303
Copy link
Copy Markdown
Contributor

@kumaraditya303 kumaraditya303 commented Mar 26, 2026

Without the fix on current main branch, the added test fails:

./python -m test test_capi.test_opt -m test_cached_attributes_fixed_version_tag -v   
== CPython 3.15.0a7+ (heads/type-version-dirty:eeacb3eab0b, Mar 26 2026, 14:11:52) [Clang 21.1.8 (++20251221032922+2078da43e25a-1~exp1~2025
1221153059.70)]                                                                                                                            == Linux-6.6.87.2-microsoft-standard-WSL2-x86_64-with-glibc2.39 little-endian
== Python build: debug JIT
== cwd: /home/realkumaraditya/cpython/build/test_python_worker_37285æ
== CPU count: 12
== encodings: locale=UTF-8 FS=utf-8
== resources: all test resources are disabled, use -u option to unskip tests

Using random seed: 1734361391
0:00:00 load avg: 1.83 Run 1 test sequentially in a single process
0:00:00 load avg: 1.83 [1/1] test_capi.test_opt
test_cached_attributes_fixed_version_tag (test.test_capi.test_opt.TestUopsOptimization.test_cached_attributes_fixed_version_tag) ... FAIL

======================================================================
FAIL: test_cached_attributes_fixed_version_tag (test.test_capi.test_opt.TestUopsOptimization.test_cached_attributes_fixed_version_tag)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/realkumaraditya/cpython/Lib/test/test_capi/test_opt.py", line 3032, in test_cached_attributes_fixed_version_tag
    self.assertNotIn("_LOAD_ATTR_METHOD_NO_DICT", uops)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: '_LOAD_ATTR_METHOD_NO_DICT' unexpectedly found in ['_START_EXECUTOR', '_MAKE_WARM', '_SET_IP', '_CHECK_PERIODIC', '_CHECK_V
ALIDITY', '_ITER_CHECK_RANGE', '_GUARD_NOT_EXHAUSTED_RANGE', '_ITER_NEXT_RANGE', '_SET_IP', '_SWAP_FAST_3', '_SPILL_OR_RELOAD', '_POP_TOP', '_CHECK_VALIDITY', '_LOAD_FAST_BORROW_2', '_LOAD_FAST_BORROW_1', '_GUARD_TYPE_VERSION', '_LOAD_ATTR_METHOD_NO_DICT', '_SET_IP', '_SPILL_OR_RELOAD', '_CALL_METHOD_DESCRIPTOR_NOARGS', '_TIER2_RESUME_CHECK', '_CHECK_VALIDITY', '_GUARD_TOS_INT', '_GUARD_NOS_INT', '_BINARY_OP_ADD_INT', '_POP_TOP_INT', '_POP_TOP_NOP', '_SWAP_FAST_2', '_POP_TOP_INT', '_JUMP_TO_TOP', '_DEOPT', '_ERROR_POP_N', '_DEOPT', '_EXIT_TRACE', '_EXIT_TRACE', '_ERROR_POP_N', '_DEOPT', '_EXIT_TRACE', '_EXIT_TRACE', '_ERROR_POP_N', '_HANDLE_PENDING_AND_DEOPT', '_DEOPT', '_EXIT_TRACE', '_EXIT_TRACE']                                                                                                                              
----------------------------------------------------------------------
Ran 1 test in 0.006s

FAILED (failures=1)
test test_capi.test_opt failed
0:00:00 load avg: 1.83 [1/1/1] test_capi.test_opt failed (1 failure)

== Tests result: FAILURE ==

1 test failed:
    test_capi.test_opt

Total duration: 108 ms
Total tests: run=1 (filtered) failures=1
Total test files: run=1/1 (filtered) failed=1
Result: FAILURE

Copy link
Copy Markdown
Member

@Fidget-Spinner Fidget-Spinner left a comment

Choose a reason for hiding this comment

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

Oh wow, great find and fix, thanks!

@kumaraditya303 kumaraditya303 merged commit 495178a into python:main Mar 26, 2026
57 checks passed
@kumaraditya303 kumaraditya303 deleted the type-version branch March 26, 2026 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants