Merge pull request #25079 from lxk696:4.x

fix [use hasattr("cv2", "name") ,but first param is 'character string',
This commit is contained in:
Alexander Smorkalov 2024-02-26 12:46:17 +03:00 committed by GitHub
commit 37e056c06c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -33,7 +33,7 @@ def __load_extra_py_code_for_module(base, name, enable_debug_print=False):
# Extension doesn't contain extra py code
return False
if not hasattr(base, name):
if base in sys.modules and not hasattr(sys.modules[base], name):
setattr(sys.modules[base], name, py_module)
sys.modules[export_module_name] = py_module
# If it is C extension module it is already loaded by cv2 package