Skip to content
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
2 changes: 1 addition & 1 deletion tornado/concurrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def wrapper(self: Any, *args: Any, **kwargs: Any) -> Future:
if len(args) == 1:
return run_on_executor_decorator(args[0])
elif len(args) != 0:
raise ValueError("expected 1 argument, got %d", len(args))
raise ValueError("expected 1 argument, got %d" % len(args))
return run_on_executor_decorator


Expand Down
2 changes: 1 addition & 1 deletion tornado/netutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def bind_unix_socket(
if stat.S_ISSOCK(st.st_mode):
os.remove(file)
else:
raise ValueError("File %s exists and is not a socket", file)
raise ValueError("File %s exists and is not a socket" % file)
sock.bind(file)
os.chmod(file, mode)
else:
Expand Down
2 changes: 1 addition & 1 deletion tornado/simple_httpclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ async def run(self) -> None:
if username is not None:
assert password is not None
if self.request.auth_mode not in (None, "basic"):
raise ValueError("unsupported auth_mode %s", self.request.auth_mode)
raise ValueError("unsupported auth_mode %s" % self.request.auth_mode)
self.request.headers["Authorization"] = "Basic " + _unicode(
base64.b64encode(
httputil.encode_username_password(username, password)
Expand Down
8 changes: 4 additions & 4 deletions tornado/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ def _convert_header_value(self, value: _HeaderTypes) -> str:
# If \n is allowed into the header, it is possible to inject
# additional headers or split the request.
if RequestHandler._VALID_HEADER_CHARS.fullmatch(retval) is None:
raise ValueError("Unsafe header value %r", retval)
raise ValueError("Unsafe header value %r" % retval)
return retval

@overload
Expand Down Expand Up @@ -1562,7 +1562,7 @@ def xsrf_token(self) -> bytes:
]
)
else:
raise ValueError("unknown xsrf cookie version %d", output_version)
raise ValueError("unknown xsrf cookie version %d" % output_version)
if version is None:
if self.current_user and "expires_days" not in cookie_kwargs:
cookie_kwargs["expires_days"] = 30
Expand Down Expand Up @@ -1999,14 +1999,14 @@ def stream_request_body(cls: Type[_RequestHandlerType]) -> Type[_RequestHandlerT
for example usage.
""" # noqa: E501
if not issubclass(cls, RequestHandler):
raise TypeError("expected subclass of RequestHandler, got %r", cls)
raise TypeError("expected subclass of RequestHandler, got %r" % cls)
cls._stream_request_body = True
return cls


def _has_stream_request_body(cls: Type[RequestHandler]) -> bool:
if not issubclass(cls, RequestHandler):
raise TypeError("expected subclass of RequestHandler, got %r", cls)
raise TypeError("expected subclass of RequestHandler, got %r" % cls)
return cls._stream_request_body


Expand Down
12 changes: 5 additions & 7 deletions tornado/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,9 +745,8 @@ def __init__(
# There is no symbolic constant for the minimum wbits value.
if not (8 <= max_wbits <= zlib.MAX_WBITS):
raise ValueError(
"Invalid max_wbits value %r; allowed range 8-%d",
max_wbits,
zlib.MAX_WBITS,
"Invalid max_wbits value %r; allowed range 8-%d"
% (max_wbits, zlib.MAX_WBITS)
)
self._max_wbits = max_wbits

Expand Down Expand Up @@ -794,9 +793,8 @@ def __init__(
max_wbits = zlib.MAX_WBITS
if not (8 <= max_wbits <= zlib.MAX_WBITS):
raise ValueError(
"Invalid max_wbits value %r; allowed range 8-%d",
max_wbits,
zlib.MAX_WBITS,
"Invalid max_wbits value %r; allowed range 8-%d"
% (max_wbits, zlib.MAX_WBITS)
)
self._max_wbits = max_wbits
if persistent:
Expand Down Expand Up @@ -1001,7 +999,7 @@ def _process_server_headers(
if ext[0] == "permessage-deflate" and self._compression_options is not None:
self._create_compressors("client", ext[1])
else:
raise ValueError("unsupported extension %r", ext)
raise ValueError("unsupported extension %r" % (ext,))

self.selected_subprotocol = headers.get("Sec-WebSocket-Protocol", None)

Expand Down