models: Fix review comments

This commit is contained in:
Thomas Adamcik 2015-04-12 16:03:51 +02:00
parent 777a663896
commit 20019edf2d
2 changed files with 3 additions and 4 deletions

View File

@ -150,9 +150,8 @@ class ImmutableObjectMeta(type):
attrs['_instances'] = weakref.WeakValueDictionary() attrs['_instances'] = weakref.WeakValueDictionary()
attrs['__slots__'] = ['_hash'] + fields.values() attrs['__slots__'] = ['_hash'] + fields.values()
anncestors = [b for base in bases for b in inspect.getmro(base)] for ancestor in [b for base in bases for b in inspect.getmro(base)]:
for anncestor in anncestors: if '__weakref__' in getattr(ancestor, '__slots__', []):
if '__weakref__' in getattr(anncestor, '__slots__', []):
break break
else: else:
attrs['__slots__'].append('__weakref__') attrs['__slots__'].append('__weakref__')

View File

@ -8,7 +8,7 @@ from mopidy.models import (
TlTrack, Track, model_json_decoder) TlTrack, Track, model_json_decoder)
class InheritanecTest(unittest.TestCase): class InheritanceTest(unittest.TestCase):
def test_weakref_and_slots_play_nice_in_subclass(self): def test_weakref_and_slots_play_nice_in_subclass(self):
# Check that the following does not happen: # Check that the following does not happen: