# HG changeset patch # User Denis Laxalde # Date 1511971685 -3600 # Node ID 24393ce335f5b97cd546000a87c5c87a48d1a15a # Parent 55924e962cd7190f5d060722f50eac6d30552deb [gcdebug] Only ignore weakref.WeakKeyDictionary class on Python 2 From Python 3.5, this class fails isinstance check with the following error: :: cls = , instance = def __instancecheck__(cls, instance): """Override for isinstance(instance, cls).""" # Inline the cache checking > subclass = instance.__class__ E AssertionError: [ in gc] 'functools._lru_list_elem' object has no attribute '__class__' /usr/lib/python3.5/abc.py:181: AssertionError I have no clue why this happens, but it makes cubicweb.web.test.test_views.AutomaticWebTest.test_startup_views fail on Python 3.5. So only consider this class for Python 2. diff -r 55924e962cd7 -r 24393ce335f5 cubicweb/_gcdebug.py --- a/cubicweb/_gcdebug.py Wed Nov 29 16:14:57 2017 +0100 +++ b/cubicweb/_gcdebug.py Wed Nov 29 17:08:05 2017 +0100 @@ -19,6 +19,8 @@ import gc, types, weakref +from six import PY2 + from cubicweb.schema import CubicWebRelationSchema, CubicWebEntitySchema try: from cubicweb.web.request import _NeedAuthAccessMock @@ -29,12 +31,16 @@ IGNORE_CLASSES = ( type, tuple, dict, list, set, frozenset, type(len), - weakref.ref, weakref.WeakKeyDictionary, + weakref.ref, listiterator, property, classmethod, types.ModuleType, types.FunctionType, types.MethodType, types.MemberDescriptorType, types.GetSetDescriptorType, ) +if PY2: + # weakref.WeakKeyDictionary fails isinstance check on Python 3.5. + IGNORE_CLASSES += (weakref.WeakKeyDictionary, ) + if _NeedAuthAccessMock is not None: IGNORE_CLASSES = IGNORE_CLASSES + (_NeedAuthAccessMock,)