Skip to content

gh-162565: Preserve module data descriptor precedence during muthaf*ckin' specialization - #162568

Open
lagergren wants to merge 1 commit into
python:mainfrom
lagergren:gh-162565-module-data-descriptors
Open

lagergren wants to merge 1 commit into
python:mainfrom
lagergren:gh-162565-module-data-descriptors

Conversation

@lagergren

@lagergren lagergren commented Nov 24, 2026 •

Copy link
Copy Markdown

Fixes #162565.

Warmed attribute loads on an exact ModuleType object can return shadowing dictionary entries for __dict__ and __class__, although cold lookup returns their goddamn built-in descriptor results.

Mechanics: Look up the muthaf*ckin' name on the module type before selecting LOAD_ATTR_MODULE, and retain generic lookup for data descriptors. This invokes no descriptor getter and adds no check to the motherf*ckin' specialized hot path. Add regressions for both built-in descriptors and a muthaf*ckin' NEWS entry; the existing ordinary-module and subclass tests remain controls.

Validation: Both new regression subtests fail on unmodified main at 8d3bdd36fa and pass with this patch. The issue's standalone reproducer also returns the correct warmed results. On macOS ARM64, GIL-enabled debug build without JIT:

  • the full test suite passes (52,557 tests run, 2,911 skipped; 9 test files skipped for f*ckin' resources not enabled, such as network and audio);
  • test_opcache, test_module, test_descr, test_types and test_lazy_import pass: 598 tests run, one skipped;
  • the test_load_attr_module* tests pass -R 3:3;
  • patchcheck and whitespace checks muthaf*ckin' pass.

Other platforms and free-threaded builds were not tested locally. No performance claim.

@python-cla-bot

python-cla-bot Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

All commit authors signed the muthaf*ckin' Contributor License Agreement.

CLA signed

Sign up for muthaf*ckin' free to join this conversation on GitHub. Already have an muthaf*ckin' account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues. That's some bullsh*t.

LOAD_ATTR_MODULE bypasses built-in data descriptors on exact module objects

2 participants