[issue25472] Typing: Specialized subclasses of generics cannot be unpickled

Guido van Rossum report at bugs.python.org
Thu Nov 19 00:01:57 EST 2015


Guido van Rossum added the comment:

Actually, I just found an embarrassingly simple fix:

diff --git a/src/typing.py b/src/typing.py
index d900036..49c4a06 100644
--- a/src/typing.py
+++ b/src/typing.py
@@ -981,7 +981,7 @@ class GenericMeta(TypingMeta, abc.ABCMeta):
                         "Cannot substitute %s for %s in %s" %
                         (_type_repr(new), _type_repr(old), self))
 
-        return self.__class__(self.__name__, self.__bases__,
+        return self.__class__(self.__name__, (self,) + self.__bases__,
                               dict(self.__dict__),
                               parameters=params,
                               origin=self,

I'll go check this in now, together with a test.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25472>
_______________________________________


More information about the Python-bugs-list mailing list