Skip to content
Snippets Groups Projects
Commit a11f62a4 authored by Christof Kaufmann's avatar Christof Kaufmann
Browse files

python: Use warnings module for unknown attribute warning

parent 52018179
No related branches found
No related tags found
No related merge requests found
...@@ -68,8 +68,8 @@ from imagefusion._imagefusion import Rectangle ...@@ -68,8 +68,8 @@ from imagefusion._imagefusion import Rectangle
from imagefusion._imagefusion import Size from imagefusion._imagefusion import Size
import os import os
import sys
import numpy as np import numpy as np
import warnings
# opencv requires channel values next to each other, then x values. y values can have arbitrary stride. # opencv requires channel values next to each other, then x values. y values can have arbitrary stride.
def fix_memory_layout(img): def fix_memory_layout(img):
...@@ -1504,7 +1504,7 @@ class UnknownAttrWarnMixin: ...@@ -1504,7 +1504,7 @@ class UnknownAttrWarnMixin:
def __setattr__(self, name, val): def __setattr__(self, name, val):
if hasattr(self, '_warn_unknown_attr') and self._warn_unknown_attr and not hasattr(self, name): if hasattr(self, '_warn_unknown_attr') and self._warn_unknown_attr and not hasattr(self, name):
print('WARNING: You set the attribute', name, 'to', f'{val}, but there does not exist a property with the name ' + name + '. Check whether its a typo!', file=sys.stderr) warnings.warn(f'WARNING: You set the attribute {name} to {val}, but there does not exist a property with the name {name}. Check whether its a typo!')
super().__setattr__(name, val) super().__setattr__(name, val)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment