Skip to content

Commit 6585e9f

Browse files
DinoVfacebook-github-bot
authored andcommitted
Make strict modules appear as normal modules
Summary: There's a big perf difference when getting the source info for a strict module vs a normal module: https://fb.workplace.com/groups/653235072286882/permalink/1791930228417355/ This is because `getmodule` gets a lot more complicated when things aren't modules: https://www.internalfb.com/code/fbsource/[630a7e128132fa049cea4b73d9d9eb079e0608d6]/third-party/python/3.12/Lib/inspect.py?lines=988 This does the same strict to make our StrictModule test as a normal module for `isinstance` that we use with generators. Reviewed By: alexmalyshev Differential Revision: D79454110 fbshipit-source-id: b1b5d4e8680ae354a46fa584fd9f79287786ee79
1 parent 1c5638f commit 6585e9f

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

cinderx/StaticPython/strictmoduleobject.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,7 @@ static PyObject* strictmodule_lookupattro_impl(
443443
} else if (
444444
PyUnicode_GET_LENGTH(name) == 9 && PyUnicode_READ_CHAR(name, 0) == '_' &&
445445
PyUnicode_CompareWithASCIIString(name, "__class__") == 0) {
446-
Py_INCREF(&Ci_StrictModule_Type);
447-
return (PyObject*)&Ci_StrictModule_Type;
446+
return Py_NewRef(&PyModule_Type);
448447
} else if (
449448
PyUnicode_GET_LENGTH(name) == 8 && PyUnicode_READ_CHAR(name, 0) == '_' &&
450449
PyUnicode_CompareWithASCIIString(name, "__dict__") == 0) {

0 commit comments

Comments
 (0)