New submission from Arfrever Frehtes Taifersar Arahesis:
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)
----------
components: Library (Lib), Tests
messages: 277896
nosy: Arfrever, gvanrossum, ncoghlan, rhettinger
priority: normal
severity: normal
status: open
title: "TypeError: Parameterized generics cannot be used with class or instance
checks" in test_functools after importing typing module
versions: Python 3.5, Python 3.6, Python 3.7
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue28339>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com