-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Description
In face_recognition/api.py:
- The try/except block on lines 8-13 catches a broad Exception and then calls quit. Code below:
try:
import face_recognition_models
except Exception:
print("Please install face_recognition_models with this command before using face_recognition:\n")
print("pip install git+https://github.com/ageitgey/face_recognition_models")
quit()
Using ImportError instead of except Exception can prevent masking of unrelated errors, like syntax errors, that may happen during an import. Since the block calls an import and specifically checks for missing dependencies, use of ImportError is more focused on the codes specific purpose.
For the quit() --> SystemExit(1) suggestion, quit() isn't guaranteed to exist in all execution envs. Raising SystemExit(1) is more universal and serves the same purpose, preventing any disruption in existing code. SystemExit(1) also has the benefit of not needing an import to function.