From ba483dfbb8d9c1a5b9c25fcb444e76ba9df74f09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E9=9B=84=E5=BA=B7?= <69671710@qq.com> Date: Fri, 23 Feb 2024 22:02:43 +0800 Subject: [PATCH] fix [use hasattr("cv2", "name") ,but first param is 'character string', resulting in an error in the judgment condition] --- modules/python/package/cv2/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/python/package/cv2/__init__.py b/modules/python/package/cv2/__init__.py index 550482bd17..7e148fc9f2 100644 --- a/modules/python/package/cv2/__init__.py +++ b/modules/python/package/cv2/__init__.py @@ -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