Skip to content

Commit

Permalink
Try to fix type inference?
Browse files Browse the repository at this point in the history
  • Loading branch information
ekzhang committed May 6, 2024
1 parent 7901b2c commit d7ed99c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions sanic/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,22 @@ def __init__(
headers = headers or getattr(self.__class__, "headers", {})
if isinstance(message, bytes):
# If a `bytes` object is provided, normalize it to a string.
message = message.decode("utf8")
if message is None:
message_str: str = message.decode("utf8")
elif message is not None:
message_str = message
else:
cls_message = getattr(self.__class__, "message", None)
if cls_message:
message = cls_message
message_str = cls_message
elif status_code:
message = STATUS_CODES.get(status_code, b"").decode("utf8")
message_str = STATUS_CODES.get(status_code, b"").decode("utf8")

super().__init__(message)
super().__init__(message_str)

self.status_code = status_code or self.status_code
self.quiet = quiet
self.headers = headers
self.message = message
self.message = message_str


class HTTPException(SanicException):
Expand Down

0 comments on commit d7ed99c

Please sign in to comment.