149 resp.raise_for_status()
150 image = Image.open(BytesIO(resp.content)).convert("RGBA")
151 return cv2.cvtColor(np.array(image), cv2.COLOR_RGBA2BGRA)
152 except (requests.RequestException, IOError):153 return np.zeros((200, 200, 4), dtype=np.uint8)
154
155 def paste_image(background, overlay, x, y):
Two or more exceptions in the same exception handler clause that are identical or parts of the same inheritance hierarchy (i.e. overlapping). It is recommmend to refactor this.
class SomeException(Exception):
pass
class SubclassException(SomeException):
pass
try:
raise SubclassException()
except (SomeException, SubclassException):
pass
Here, SubclassException
has been derived from SomeException
, which makes it overlapping.
class SomeException(Exception):
pass
class SubclassException(SomeException):
pass
try:
raise SubclassException()
except SomeException:
pass