From b01e1c269dea2f99edbdc1401e2a14da72147375 Mon Sep 17 00:00:00 2001 From: Matthias Urlichs Date: Sun, 3 Feb 2019 16:34:35 +0100 Subject: [PATCH] owchie to_native --- src/octoprint/server/util/tornado.py | 7 ++++--- src/octoprint/util/__init__.py | 1 - tests/plugin/test_core.py | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/octoprint/server/util/tornado.py b/src/octoprint/server/util/tornado.py index 78c191832..513788645 100644 --- a/src/octoprint/server/util/tornado.py +++ b/src/octoprint/server/util/tornado.py @@ -1179,9 +1179,10 @@ class GlobalHeaderTransform(tornado.web.OutputTransform): if removed_headers is None: removed_headers = [] - return type(name, (GlobalHeaderTransform,), dict(HEADERS=headers, - FORCED_HEADERS=forced_headers, - REMOVED_HEADERS=removed_headers)) + return type(octoprint.util.to_native_str(name), (GlobalHeaderTransform,), + dict(HEADERS=headers, + FORCED_HEADERS=forced_headers, + REMOVED_HEADERS=removed_headers)) def __init__(self, request): tornado.web.OutputTransform.__init__(self, request) diff --git a/src/octoprint/util/__init__.py b/src/octoprint/util/__init__.py index 111ead3d5..942ac242e 100644 --- a/src/octoprint/util/__init__.py +++ b/src/octoprint/util/__init__.py @@ -517,7 +517,6 @@ def to_bytes(s_or_u, encoding="utf-8", errors="strict"): to_str = deprecated("to_str has been renamed to to_bytes", since="1.4.0")(to_bytes) - return to_bytes(s_or_u, encoding=encoding, errors=errors) def to_unicode(s_or_u, encoding="utf-8", errors="strict"): """Make sure ``s_or_u`` is a unicode string.""" diff --git a/tests/plugin/test_core.py b/tests/plugin/test_core.py index 695abcbfb..5616dc005 100644 --- a/tests/plugin/test_core.py +++ b/tests/plugin/test_core.py @@ -7,6 +7,7 @@ import ddt import octoprint.plugin import octoprint.plugin.core +from octoprint.util import to_native_str ##~~ Helpers for testing mixin type extraction @@ -337,7 +338,7 @@ class PluginTestCase(unittest.TestCase): ) @ddt.unpack def test_mixins_matching_bases(self, bases_to_set, bases_to_check, expected): - Foo = type("Foo", bases_to_set, dict()) + Foo = type(to_native_str("Foo"), bases_to_set, dict()) actual = octoprint.plugin.core.PluginManager.mixins_matching_bases(Foo, *bases_to_check) self.assertSetEqual(actual, set(expected))