✒️ Fix declared encoding of literal strings

This commit is contained in:
Miroslav Šedivý committed 2021-01-25 19:00:33 +01:00
1 parent 7f56d47dbc
commit dcd3592fd4
4 files changed
+7 -7

No files matched your search

+1 -1
View File
@@ -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")
+3 -3
View File
@@ -1,6 +1,6 @@
__author__ = u"Gina Häußge <osd@foosel.net>"
__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 <osd@foosel.net>"
__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
+2 -2
View File
@@ -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<x>\d+)".encode("utf-8")
x_regex = br"X:(?P<x>\d+)"
x_template = b"X: {x}"
x_key = md5sum(x_regex)
x_template_key = md5sum(x_template)
+1 -1
View File
@@ -27,7 +27,7 @@ class StringHelperTest(unittest.TestCase):
self.assertRaises(
UnicodeDecodeError,
octoprint.util.to_unicode,
"äöüß".encode("utf-8"),
"äöüß".encode(),
encoding="ascii",
)