Files
opencv-MIRROR/modules/python
AJ 56690289fb python: restore sys.path when the native cv2 module fails to load
bootstrap() inserts the package directory into sys.path before importing
the native module, but restores sys.path (#18930) and clears
sys.OpenCV_LOADER only after that import succeeds. When the native module
fails to load (e.g. a missing libGL/libxcb), the cv2/ directory stays on
sys.path. Callers that treat cv2 as optional keep running, and
multiprocessing "spawn" children inherit that sys.path, where cv2/typing
shadows the standard typing module.

Restore both before re-raising, and add a test that imports a loader
whose native module raises ImportError.

Fixes #28766
2026-11-12 16:50:06 -08:00
..