diff --git a/src/pip_shims/shims.py b/src/pip_shims/shims.py
index <HASH>..<HASH> 100644
--- a/src/pip_shims/shims.py
+++ b/src/pip_shims/shims.py
@@ -143,6 +143,7 @@ class _shims(object):
 
         for method_name, fn in methods:
             new_functions[method_name] = classmethod(BaseFunc(fn, method_name))
+        classname = classname.encode(sys.getdefaultencoding())
         type_ = type(
             classname,
             (cls,),
diff --git a/tests/test_instances.py b/tests/test_instances.py
index <HASH>..<HASH> 100644
--- a/tests/test_instances.py
+++ b/tests/test_instances.py
@@ -94,7 +94,8 @@ def test_format_control():
         fc = namedtuple("FormatControl", "no_binary, only_binary")
     else:
         # after pip 18.0 this has its own model
-        fc = type("fc", (FormatControl,), {})
+        clsname = "fc".encode(sys.getdefaultencoding())
+        fc = type(clsname, (FormatControl,), {})
     assert fc(None, None) == FormatControl(None, None)
Make sure to encode classnames for class generators