[Python-Dev] Python3.7 backwards incompatible
Guido van Rossum
guido at python.org
Sat Jun 23 18:10:44 EDT 2018
First, the typing module is still provisional, so there is no strict
backwards compatibility guarantee.
With that out of the way, I can reproduce your problem, and I assume it's
caused by the implementation of PEP 560, which is meant to speed up the
typing module (among other goals).
I'm wondering about your claim that this breaks many "libraries that use
annotations". Most code using annotations would not need to use
issubclass() in this way. Where exactly did you encounter this?
I'm CC'ing Ivan Levkivskyi, who knows the relevant code better and will be
able to explain whether this is an oversight or an intentional regression.
On Sat, Jun 23, 2018 at 2:59 PM Rokker Ruslan <rokkerruslan at yandex.com>
wrote:
> Python 3.7 in the status of RC, but I do not see information about the
> fact that python3.7 is backwards incompatible with python3.5.
>
> $ ~ python3.5
> Python 3.5.2 (default, Nov 23 2017, 16:37:01)
> [GCC 5.4.0 20160609] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from typing import List
> >>> class MyList(list):
> ... pass
> ...
> >>> issubclass(MyList, List)
> True
> >>> issubclass(List, MyList)
> False
> >>>
>
> $ ~ python3.7
> Python 3.7.0rc1+ (heads/3.7:3747dd16d5, Jun 22 2018, 22:53:42)
> [GCC 5.4.0 20160609] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from typing import List
> >>> class MyList(list):
> ... pass
> ...
> >>> issubclass(MyList, List)
> True
> >>> issubclass(List, MyList)
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: issubclass() arg 1 must be a class
> >>>
>
> And so with all types of "typing" module.
> This breaks down many libraries that use annotations as part of the
> functionality if we now can't use typing.* into issubclass function.
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/guido%40python.org
>
--
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20180623/f775c8b2/attachment.html>
More information about the Python-Dev
mailing list