Skip to content

Fix pickling of httpclient.HTTPError subclasses and web.HTTPError #3439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tornado/httpclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,6 @@ def __init__(
self.code = code
self.message = message or httputil.responses.get(code, "Unknown")
self.response = response
super().__init__(code, message, response)

def __str__(self) -> str:
return "HTTP %d: %s" % (self.code, self.message)
Expand Down
8 changes: 4 additions & 4 deletions tornado/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -2520,21 +2520,21 @@ def __init__(
) -> None:
self.status_code = status_code
self._log_message = log_message
self.args = args
self.log_args = args
self.reason = kwargs.get("reason", None)

@property
def log_message(self) -> Optional[str]:
"""
A backwards compatible way of accessing log_message.
"""
if self._log_message and not self.args:
if self._log_message and not self.log_args:
return self._log_message.replace("%", "%%")
return self._log_message

def get_message(self) -> Optional[str]:
if self._log_message and self.args:
return self._log_message % self.args
if self._log_message and self.log_args:
return self._log_message % self.log_args
return self._log_message

def __str__(self) -> str:
Expand Down