From dcd3592fd4421f90b9cedef697d0127936e45b13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= <6774676+eumiro@users.noreply.github.com> Date: Fri, 22 Jan 2021 13:57:55 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=92=EF=B8=8F=20Fix=20declared=20encoding?= =?UTF-8?q?=20of=20literal=20strings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/octoprint/server/__init__.py | 2 +- src/octoprint_setuptools/__init__.py | 6 +++--- tests/util/test_comm_helpers.py | 4 ++-- tests/util/test_string_helpers.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/octoprint/server/__init__.py b/src/octoprint/server/__init__.py index 137caa7e4..41c04b6e7 100644 --- a/src/octoprint/server/__init__.py +++ b/src/octoprint/server/__init__.py @@ -2254,7 +2254,7 @@ class Server: break else: self.send_response(404) - self.wfile.write("Not found".encode("utf-8")) + self.wfile.write(b"Not found") base_path = os.path.realpath( os.path.join(os.path.dirname(__file__), "..", "static") diff --git a/src/octoprint_setuptools/__init__.py b/src/octoprint_setuptools/__init__.py index bdf61a114..682ee5d0a 100644 --- a/src/octoprint_setuptools/__init__.py +++ b/src/octoprint_setuptools/__init__.py @@ -1,6 +1,6 @@ -__author__ = u"Gina Häußge " -__license__ = u"GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" -__copyright__ = u"Copyright (C) 2015 The OctoPrint Project - Released under terms of the AGPLv3 License" +__author__ = "Gina Häußge " +__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" +__copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms of the AGPLv3 License" import glob import os diff --git a/tests/util/test_comm_helpers.py b/tests/util/test_comm_helpers.py index 51b869f51..750ee41ed 100644 --- a/tests/util/test_comm_helpers.py +++ b/tests/util/test_comm_helpers.py @@ -110,14 +110,14 @@ class TestCommHelpers(unittest.TestCase): return m.hexdigest() # rb'' doesn't exist in Python2 - temp_regex = r"T:((\d*\.)\d+)".encode("utf-8") + temp_regex = br"T:((\d*\.)\d+)" temp_template = b"Temp: {}" temp2_template = b"Temperature: {}" temp_key = md5sum(temp_regex) temp_template_key = md5sum(temp_template) temp2_template_key = md5sum(temp2_template) - x_regex = r"X:(?P\d+)".encode("utf-8") + x_regex = br"X:(?P\d+)" x_template = b"X: {x}" x_key = md5sum(x_regex) x_template_key = md5sum(x_template) diff --git a/tests/util/test_string_helpers.py b/tests/util/test_string_helpers.py index 4dc2a20a8..539383870 100644 --- a/tests/util/test_string_helpers.py +++ b/tests/util/test_string_helpers.py @@ -27,7 +27,7 @@ class StringHelperTest(unittest.TestCase): self.assertRaises( UnicodeDecodeError, octoprint.util.to_unicode, - "äöüß".encode("utf-8"), + "äöüß".encode(), encoding="ascii", )