Traceback when using typing.Optional[Type] on xenial

Bug #1704473 reported by Dan Watkins
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python3.5 (Ubuntu)
Invalid
Undecided
Unassigned
Xenial
New
Wishlist
Dimitri John Ledkov
Yakkety
Won't Fix
Undecided
Unassigned

Bug Description

typing in the Python 3.5.2 stdlib tracebacks when passing Type to a Union (of which Optional is a specific case). (This is typing bug #266: https://github.com/python/typing/issues/266.)

(This is particularly annoying because as a stdlib library, the fix released by upstream to PyPI can't easily be used even via pip.)

Steps to Reproduce
==================

```
lxc launch ubuntu:x reproducer
lxc exec reproducer -- python3 -c "from typing import Optional, Type; Optional[Type[BaseException]]"
```

Expected Behaviour
==================

No output, exits 0.

Actual Behaviour
================

```
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.5/typing.py", line 649, in __getitem__
    return Union[arg, type(None)]
  File "/usr/lib/python3.5/typing.py", line 552, in __getitem__
    dict(self.__dict__), parameters, _root=True)
  File "/usr/lib/python3.5/typing.py", line 512, in __new__
    for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
  File "/usr/lib/python3.5/typing.py", line 512, in <genexpr>
    for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
  File "/usr/lib/python3.5/typing.py", line 1077, in __subclasscheck__
    if super().__subclasscheck__(cls):
  File "/usr/lib/python3.5/abc.py", line 225, in __subclasscheck__
    for scls in cls.__subclasses__():
TypeError: descriptor '__subclasses__' of 'type' object needs an argument
```

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Yakkety and xenial are the only affected. 3.5.3 has this fix in zesty and artful.

Dan Watkins (oddbloke)
Changed in python3.5 (Ubuntu Yakkety):
status: New → Won't Fix
Changed in python3.5 (Ubuntu):
status: New → Invalid
tags: added: id-596922a6adf3fe426db2d169
Changed in python3.5 (Ubuntu Xenial):
importance: Undecided → Wishlist
assignee: nobody → Dimitri John Ledkov (xnox)
milestone: none → xenial-updates
Revision history for this message
Brian Turek (brian-turek) wrote :

I just ran into this yesterday and was going to submit a bug report. Given that this is a one-line fix, can we get this backported? I'm happy to make the patch file.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.