-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Python type stubs: Class cv2.error is missing properties #23925
Copy link
Copy link
Closed
Description
System Information
OpenCV python: opencv-python-headless==4.8.0.74
Operating System / Platform: 10.0.19045 Build 19045
Python version: 3.9.13
Detailed description
Class cv2.error is currently typed as:
class error(Exception): ...but should be something like:
class error(Exception):
code: int
err: str
file: str
func: str
line: int
msg: str(They are technically ClassVars, but would be None)
As inspected with:
>>> import cv2
>>> error_dir = dir(cv2.error)
>>> exception_dir = dir(Exception)
>>> [x for x in error_dir if x not in exception_dir]
['__module__', '__weakref__', 'code', 'err', 'file', 'func', 'line', 'msg']
>>> try:
... cv2.VideoCapture().read("aaa")
... except cv2.error as error:
... print(type(error.code), type(error.err), type(error.file), type(error.func), type(error.line), type(error.msg))
...
<class 'int'> <class 'str'> <class 'str'> <class 'str'> <class 'int'> <class 'str'>Steps to reproduce
Issue submission checklist
- I report the issue, it's not a question
- I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- I updated to the latest OpenCV version and the issue is still there
- There is reproducer code and related data files (videos, images, onnx, etc)
Reactions are currently unavailable
