Skip to content

Commit

Permalink
*: Use default argument for str.encode()
Browse files Browse the repository at this point in the history
I had missed that this became hard-coded to utf-8 in py3k,
instead of being overridable as in python 2.

Automated change with modified pyupgrade.
  • Loading branch information
bdarnell committed Jun 13, 2024
1 parent e98b09f commit 6c4d751
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tornado/test/escape_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def test_xhtml_unescape_numeric(self):
def test_url_escape_unicode(self):
tests = [
# byte strings are passed through as-is
("\u00e9".encode("utf8"), "%C3%A9"),
("\u00e9".encode(), "%C3%A9"),
("\u00e9".encode("latin1"), "%E9"),
# unicode strings become utf8
("\u00e9", "%C3%A9"),
Expand Down
8 changes: 3 additions & 5 deletions tornado/test/httpserver_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,11 @@ def test_multipart_form(self):
[
b"Content-Disposition: form-data; name=argument",
b"",
"\u00e1".encode("utf-8"),
"\u00e1".encode(),
b"--1234567890",
'Content-Disposition: form-data; name="files"; filename="\u00f3"'.encode(
"utf8"
),
'Content-Disposition: form-data; name="files"; filename="\u00f3"'.encode(),
b"",
"\u00fa".encode("utf-8"),
"\u00fa".encode(),
b"--1234567890--",
b"",
]
Expand Down
2 changes: 1 addition & 1 deletion tornado/test/log_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_bytes_logging(self):

def test_utf8_logging(self):
with ignore_bytes_warning():
self.logger.error("\u00e9".encode("utf8"))
self.logger.error("\u00e9".encode())
if issubclass(bytes, basestring_type):
# on python 2, utf8 byte strings (and by extension ascii byte
# strings) are passed through as-is.
Expand Down

0 comments on commit 6c4d751

Please sign in to comment.