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: 5 additions & 3 deletions tornado/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -1869,7 +1869,9 @@ def log_exception(
if isinstance(value, HTTPError):
if value.log_message:
format = "%d %s: " + value.log_message
args = [value.status_code, self._request_summary()] + list(value.args)
args = [value.status_code, self._request_summary()] + list(
value.log_args
)
gen_log.warning(format, *args)
else:
app_log.error(
Expand Down Expand Up @@ -2474,7 +2476,7 @@ 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)
if log_message and not args:
self.log_message = log_message.replace("%", "%%")
Expand All @@ -2485,7 +2487,7 @@ def __str__(self) -> str:
self.reason or httputil.responses.get(self.status_code, "Unknown"),
)
if self.log_message:
return message + " (" + (self.log_message % self.args) + ")"
return message + " (" + (self.log_message % self.log_args) + ")"
else:
return message

Expand Down