Update onvif error checking to use explict None check (#92642)

pull/92713/head
J. Nick Koston 2023-05-06 17:47:15 -05:00 committed by GitHub
parent 4a2af45e37
commit c624e50b60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -17,16 +17,16 @@ def stringify_onvif_error(error: Exception) -> str:
"""Stringify ONVIF error."""
if isinstance(error, Fault):
message = error.message
if error.detail:
if error.detail is not None: # checking true is deprecated
# Detail may be a bytes object, so we need to convert it to string
if isinstance(error.detail, bytes):
detail = error.detail.decode("utf-8", "replace")
else:
detail = str(error.detail)
message += ": " + detail
if error.code:
if error.code is not None: # checking true is deprecated
message += f" (code:{error.code})"
if error.subcodes:
if error.subcodes is not None: # checking true is deprecated
message += (
f" (subcodes:{','.join(extract_subcodes_as_strings(error.subcodes))})"
)