Author Arfrever
Recipients Arfrever, gvanrossum, ncoghlan, rhettinger
Date 2016-10-02.15:21:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1475421693.5.0.638809019729.issue28339@psf.upfronthosting.co.za>
In-reply-to
Content
Commits 09cc43df4509 (3.5), 81f27d3ab214 (3.6), 8f0df4db2b06 (3.7) cause "TypeError: Parameterized generics cannot be used with class or instance checks" errors in 4 tests in Lib/test/test_functools.py file in situation when typing module is already imported.

Examples of steps to reproduce:
$ LD_LIBRARY_PATH="$(pwd)" ./python -m test -v test_typing test_functools
$ LD_LIBRARY_PATH="$(pwd)" ./python -m test -v test___all__ test_functools
$ LD_LIBRARY_PATH="$(pwd)" ./python -c 'import runpy, typing; runpy.run_module("test")' -v test_functools

Errors in test_functools:

======================================================================
ERROR: test_cache_invalidation (test.test_functools.TestSingleDispatch)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/cpython/Lib/functools.py", line 776, in dispatch
    impl = dispatch_cache[cls]
  File "/tmp/cpython/Lib/test/test_functools.py", line 1896, in __getitem__
    result = self.data[key]
KeyError: <class 'dict'>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/cpython/Lib/functools.py", line 779, in dispatch
    impl = registry[cls]
KeyError: <class 'dict'>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/cpython/Lib/test/test_functools.py", line 1955, in test_cache_invalidation
    self.assertEqual(g(d), "sized")
  File "/tmp/cpython/Lib/functools.py", line 801, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
  File "/tmp/cpython/Lib/functools.py", line 781, in dispatch
    impl = _find_impl(cls, registry)
  File "/tmp/cpython/Lib/functools.py", line 732, in _find_impl
    mro = _compose_mro(cls, registry.keys())
  File "/tmp/cpython/Lib/functools.py", line 709, in _compose_mro
    if sub not in bases and issubclass(cls, sub):
  File "/tmp/cpython/Lib/typing.py", line 1043, in __subclasscheck__
    raise TypeError("Parameterized generics cannot be used with class "
TypeError: Parameterized generics cannot be used with class or instance checks

======================================================================
ERROR: test_compose_mro (test.test_functools.TestSingleDispatch)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/cpython/Lib/test/test_functools.py", line 1594, in test_compose_mro
    m = mro(c.defaultdict, [c.Sized, c.Container, str])
  File "/tmp/cpython/Lib/functools.py", line 709, in _compose_mro
    if sub not in bases and issubclass(cls, sub):
  File "/tmp/cpython/Lib/typing.py", line 1043, in __subclasscheck__
    raise TypeError("Parameterized generics cannot be used with class "
TypeError: Parameterized generics cannot be used with class or instance checks

======================================================================
ERROR: test_mro_conflicts (test.test_functools.TestSingleDispatch)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/cpython/Lib/functools.py", line 776, in dispatch
    impl = dispatch_cache[cls]
  File "/tmp/cpython/Lib/test/test_functools.py", line 1896, in __getitem__
    result = self.data[key]
KeyError: <class 'collections.defaultdict'>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/cpython/Lib/functools.py", line 779, in dispatch
    impl = registry[cls]
KeyError: <class 'collections.defaultdict'>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/cpython/Lib/test/test_functools.py", line 1822, in test_mro_conflicts
    h(c.defaultdict(lambda: 0))
  File "/tmp/cpython/Lib/functools.py", line 801, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
  File "/tmp/cpython/Lib/functools.py", line 781, in dispatch
    impl = _find_impl(cls, registry)
  File "/tmp/cpython/Lib/functools.py", line 732, in _find_impl
    mro = _compose_mro(cls, registry.keys())
  File "/tmp/cpython/Lib/functools.py", line 709, in _compose_mro
    if sub not in bases and issubclass(cls, sub):
  File "/tmp/cpython/Lib/typing.py", line 1043, in __subclasscheck__
    raise TypeError("Parameterized generics cannot be used with class "
TypeError: Parameterized generics cannot be used with class or instance checks

======================================================================
ERROR: test_register_abc (test.test_functools.TestSingleDispatch)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/cpython/Lib/functools.py", line 776, in dispatch
    impl = dispatch_cache[cls]
  File "/tmp/cpython/Lib/test/test_functools.py", line 1896, in __getitem__
    result = self.data[key]
KeyError: <class 'dict'>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/cpython/Lib/functools.py", line 779, in dispatch
    impl = registry[cls]
KeyError: <class 'dict'>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/cpython/Lib/test/test_functools.py", line 1641, in test_register_abc
    self.assertEqual(g(d), "sized")
  File "/tmp/cpython/Lib/functools.py", line 801, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
  File "/tmp/cpython/Lib/functools.py", line 781, in dispatch
    impl = _find_impl(cls, registry)
  File "/tmp/cpython/Lib/functools.py", line 732, in _find_impl
    mro = _compose_mro(cls, registry.keys())
  File "/tmp/cpython/Lib/functools.py", line 709, in _compose_mro
    if sub not in bases and issubclass(cls, sub):
  File "/tmp/cpython/Lib/typing.py", line 1043, in __subclasscheck__
    raise TypeError("Parameterized generics cannot be used with class "
TypeError: Parameterized generics cannot be used with class or instance checks

----------------------------------------------------------------------
Ran 186 tests in 0.431s

FAILED (errors=4)
History
Date User Action Args
2016-10-02 15:21:33Arfreversetrecipients: + Arfrever, gvanrossum, rhettinger, ncoghlan
2016-10-02 15:21:33Arfreversetmessageid: <1475421693.5.0.638809019729.issue28339@psf.upfronthosting.co.za>
2016-10-02 15:21:33Arfreverlinkissue28339 messages
2016-10-02 15:21:33Arfrevercreate