From: Ben Darnell Date: Thu, 13 Jun 2024 18:43:57 +0000 (-0400) Subject: *: Use default argument for str.encode() X-Git-Tag: v6.5.0b1~47^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6c4d751028fdb662e8167920c8aa47b88460da92;p=thirdparty%2Ftornado.git *: Use default argument for str.encode() 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. --- diff --git a/tornado/test/escape_test.py b/tornado/test/escape_test.py index 3115a194..b9614dcb 100644 --- a/tornado/test/escape_test.py +++ b/tornado/test/escape_test.py @@ -247,7 +247,7 @@ class EscapeTestCase(unittest.TestCase): 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"), diff --git a/tornado/test/httpserver_test.py b/tornado/test/httpserver_test.py index 07244634..85755405 100644 --- a/tornado/test/httpserver_test.py +++ b/tornado/test/httpserver_test.py @@ -282,13 +282,11 @@ class HTTPConnectionTest(AsyncHTTPTestCase): [ 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"", ] diff --git a/tornado/test/log_test.py b/tornado/test/log_test.py index fec4c389..5b4f9918 100644 --- a/tornado/test/log_test.py +++ b/tornado/test/log_test.py @@ -89,7 +89,7 @@ class LogFormatterTest(unittest.TestCase): 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.