This is an archive of the discontinued LLVM Phabricator instance.

[LNT] Python 3 support: define hash for Order class
ClosedPublic

Authored by thopre on Oct 16 2019, 8:14 AM.

Details

Summary

Method v4_machine in lnt.server.ui.views stores couples of Order and Run
instances in a multidict, thus making Order the key. This requires
instances of the Order class to be hashable but hashability rules have
changed under Python 3.

As per the Python's data model documentation regarding the hash
method, user-defined classes have a default hash method making their
instances hashable. However, under Python 3 if such a user-defined class
overrides eq but not hash (as is done by the class
lnt.server.db.testsuite.TestSuiteDB.Order) the hash method is set to
none making it unhashable. Under Python 2 one would have to explicitely
set hash to None in the class definition for such a class to be
unhashable.

This commit adds a hash method for
lnt.server.db.testsuite.TestSuiteDB.Order class to allow it to be used
as key in a multidict.