)]}'
{"neutron/tests/tools.py":[{"author":{"_account_id":6854,"name":"YAMAMOTO Takashi","email":"yamamoto@midokura.com","username":"yamamoto"},"change_message_id":"859f810ca19d1b7a50f1a7c412d59e83777b0e26","unresolved":false,"context_lines":[{"line_number":130,"context_line":"        hash_ \u003d 0"},{"line_number":131,"context_line":"        for item in value.items():"},{"line_number":132,"context_line":"            hash_ ^\u003d hash(item)"},{"line_number":133,"context_line":"        return hash_"},{"line_number":134,"context_line":"    return hash(value)"}],"source_content_type":"text/x-python","patch_set":4,"id":"3a50d1a3_74b83e2b","line":133,"updated":"2015-07-24 05:24:09.000000000","message":"how about hash(frozenset(value.items())) ?","commit_id":"8b771076d9138b022e52f32c9c4b0fb9e3fe535c"},{"author":{"_account_id":9107,"name":"Victor Stinner","email":"vstinner@redhat.com","username":"haypo"},"change_message_id":"7179e2050557fb6364080451175a2febe8a70abe","unresolved":false,"context_lines":[{"line_number":130,"context_line":"        hash_ \u003d 0"},{"line_number":131,"context_line":"        for item in value.items():"},{"line_number":132,"context_line":"            hash_ ^\u003d hash(item)"},{"line_number":133,"context_line":"        return hash_"},{"line_number":134,"context_line":"    return hash(value)"}],"source_content_type":"text/x-python","patch_set":4,"id":"3a50d1a3_f73645b3","line":133,"in_reply_to":"3a50d1a3_74b83e2b","updated":"2015-07-27 08:11:47.000000000","message":"I suggest to use hash(sorted(value.items())) instead of computing explicitly the hash.","commit_id":"8b771076d9138b022e52f32c9c4b0fb9e3fe535c"},{"author":{"_account_id":6854,"name":"YAMAMOTO Takashi","email":"yamamoto@midokura.com","username":"yamamoto"},"change_message_id":"6fee749760b150f8a71f872dbece952e4cc3040f","unresolved":false,"context_lines":[{"line_number":124,"context_line":"def safe_hash(value):"},{"line_number":125,"context_line":"    \"\"\"Return value hash or build one for dictionaries.\"\"\""},{"line_number":126,"context_line":"    if isinstance(value, collections.Mapping):"},{"line_number":127,"context_line":"        return hash(sorted(value.items()))"},{"line_number":128,"context_line":"    return hash(value)"}],"source_content_type":"text/x-python","patch_set":5,"id":"3a50d1a3_3a4e663b","line":127,"updated":"2015-07-29 04:24:20.000000000","message":"list is not hashable.  it\u0027s why i suggested frozenset.","commit_id":"2f284524d29174530aa6031b6630f8dbaa903c92"},{"author":{"_account_id":9107,"name":"Victor Stinner","email":"vstinner@redhat.com","username":"haypo"},"change_message_id":"b0b31b027a076d9ff340c36f5ca59edddd9ce7da","unresolved":false,"context_lines":[{"line_number":124,"context_line":"def safe_hash(value):"},{"line_number":125,"context_line":"    \"\"\"Return value hash or build one for dictionaries.\"\"\""},{"line_number":126,"context_line":"    if isinstance(value, collections.Mapping):"},{"line_number":127,"context_line":"        return hash(sorted(value.items()))"},{"line_number":128,"context_line":"    return hash(value)"}],"source_content_type":"text/x-python","patch_set":5,"id":"3a50d1a3_10b4a27f","line":127,"in_reply_to":"3a50d1a3_3a4e663b","updated":"2015-07-29 09:04:42.000000000","message":"\u003e list is not hashable. it\u0027s why i suggested frozenset.\n\nOh, you\u0027re right, sorry.","commit_id":"2f284524d29174530aa6031b6630f8dbaa903c92"},{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"aa8d6d011775af2b55ba9f2ccb0fe1b91ce951b8","unresolved":false,"context_lines":[{"line_number":124,"context_line":"def safe_hash(value):"},{"line_number":125,"context_line":"    \"\"\"Return value hash or build one for dictionaries.\"\"\""},{"line_number":126,"context_line":"    if isinstance(value, collections.Mapping):"},{"line_number":127,"context_line":"        return hash(sorted(value.items()))"},{"line_number":128,"context_line":"    return hash(value)"}],"source_content_type":"text/x-python","patch_set":5,"id":"3a50d1a3_8a2de5a9","line":127,"in_reply_to":"3a50d1a3_3a4e663b","updated":"2015-07-29 08:14:56.000000000","message":"now, i remember why i didn\u0027t use sorted in PS1","commit_id":"2f284524d29174530aa6031b6630f8dbaa903c92"},{"author":{"_account_id":8122,"name":"Cyril Roelandt","email":"cyril@redhat.com","username":"cyril.roelandt.enovance"},"change_message_id":"7cd87853341c6c2a9abdd7fc2de319215a56ea81","unresolved":false,"context_lines":[{"line_number":115,"context_line":"    def __eq__(self, other):"},{"line_number":116,"context_line":"        if not isinstance(other, list):"},{"line_number":117,"context_line":"            return False"},{"line_number":118,"context_line":"        return sorted(self) \u003d\u003d sorted(other)"},{"line_number":119,"context_line":""},{"line_number":120,"context_line":"    def __neq__(self, other):"},{"line_number":121,"context_line":"        return not self \u003d\u003d other"}],"source_content_type":"text/x-python","patch_set":9,"id":"1a4dcd0f_fb51b40e","line":118,"updated":"2015-08-13 20:53:59.000000000","message":"I think you might need to do:\n\ntry: return sorted(self) \u003d\u003d sorted(other)\nexcept TypeError: # same with key\u003dsafe_sort_key\n\nWDYT ?","commit_id":"a383f4f641818be953f5e6099ba8138a8cc09597"},{"author":{"_account_id":9107,"name":"Victor Stinner","email":"vstinner@redhat.com","username":"haypo"},"change_message_id":"cf6bc16016318804ffcb732a49aa4d592f80b3d3","unresolved":false,"context_lines":[{"line_number":124,"context_line":"def safe_sort_key(value):"},{"line_number":125,"context_line":"    \"\"\"Return value hash or build one for dictionaries.\"\"\""},{"line_number":126,"context_line":"    if isinstance(value, collections.Mapping):"},{"line_number":127,"context_line":"        return frozenset(value.items())"},{"line_number":128,"context_line":"    return value"}],"source_content_type":"text/x-python","patch_set":9,"id":"3a50d1a3_8f8ba2c2","line":127,"updated":"2015-07-29 14:52:28.000000000","message":"I\u0027m not sure that frozenset() is \"safe\", it removes duplicates. Duplicates are values which are equal, but their type may be different. Example on Python 2:\n\n \u003e\u003e\u003e frozenset([1, 1.0, 1.0+0j])\n frozenset([1])\n \u003e\u003e\u003e frozenset([\"a\", u\"a\"])\n frozenset([\u0027a\u0027])\n\nMaybe it works because items() creates pairs of 2 items: (key, value).\n\nWell, if we don\u0027t know, it\u0027s safer to use: sorted(dict.items()). As I suggested multiple times ;-)","commit_id":"a383f4f641818be953f5e6099ba8138a8cc09597"},{"author":{"_account_id":9107,"name":"Victor Stinner","email":"vstinner@redhat.com","username":"haypo"},"change_message_id":"910aa2626e40569e0f867d9cdafaa783aab95d10","unresolved":false,"context_lines":[{"line_number":124,"context_line":"def safe_sort_key(value):"},{"line_number":125,"context_line":"    \"\"\"Return value hash or build one for dictionaries.\"\"\""},{"line_number":126,"context_line":"    if isinstance(value, collections.Mapping):"},{"line_number":127,"context_line":"        return frozenset(value.items())"},{"line_number":128,"context_line":"    return value"}],"source_content_type":"text/x-python","patch_set":9,"id":"3a50d1a3_9222e550","line":127,"in_reply_to":"3a50d1a3_12eb3514","updated":"2015-07-29 15:03:07.000000000","message":"Oh, right :-) So frozenset should work.","commit_id":"a383f4f641818be953f5e6099ba8138a8cc09597"},{"author":{"_account_id":9107,"name":"Victor Stinner","email":"vstinner@redhat.com","username":"haypo"},"change_message_id":"130a2ad1a3bea4c75344f34d704dbc4744e2dac5","unresolved":false,"context_lines":[{"line_number":124,"context_line":"def safe_sort_key(value):"},{"line_number":125,"context_line":"    \"\"\"Return value hash or build one for dictionaries.\"\"\""},{"line_number":126,"context_line":"    if isinstance(value, collections.Mapping):"},{"line_number":127,"context_line":"        return frozenset(value.items())"},{"line_number":128,"context_line":"    return value"}],"source_content_type":"text/x-python","patch_set":9,"id":"3a50d1a3_92150541","line":127,"in_reply_to":"3a50d1a3_8f8ba2c2","updated":"2015-07-29 14:55:45.000000000","message":"Example with a dictionary:\n\n \u003e\u003e\u003e frozenset({1: None, 1.0: None}.items())\n frozenset([(1, None)])\n\nI\u0027m not sure that I understand the consequence of removing \"duplicates\".","commit_id":"a383f4f641818be953f5e6099ba8138a8cc09597"},{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"ea60e5816b9d2a06e2b44ca4c012205cf19be3de","unresolved":false,"context_lines":[{"line_number":124,"context_line":"def safe_sort_key(value):"},{"line_number":125,"context_line":"    \"\"\"Return value hash or build one for dictionaries.\"\"\""},{"line_number":126,"context_line":"    if isinstance(value, collections.Mapping):"},{"line_number":127,"context_line":"        return frozenset(value.items())"},{"line_number":128,"context_line":"    return value"}],"source_content_type":"text/x-python","patch_set":9,"id":"3a50d1a3_12eb3514","line":127,"in_reply_to":"3a50d1a3_92150541","updated":"2015-07-29 15:01:19.000000000","message":"frozenset works as expected, duplicates are removed by dict:\n\n \u003e\u003e\u003e {1: None, 1.0: None}\n {1: None}","commit_id":"a383f4f641818be953f5e6099ba8138a8cc09597"},{"author":{"_account_id":8122,"name":"Cyril Roelandt","email":"cyril@redhat.com","username":"cyril.roelandt.enovance"},"change_message_id":"1e3895474f6746f28f7c773d1495bb0ae5a71a92","unresolved":false,"context_lines":[{"line_number":124,"context_line":"def safe_sort_key(value):"},{"line_number":125,"context_line":"    \"\"\"Return value hash or build one for dictionaries.\"\"\""},{"line_number":126,"context_line":"    if isinstance(value, collections.Mapping):"},{"line_number":127,"context_line":"        return frozenset(value.items())"},{"line_number":128,"context_line":"    return value"}],"source_content_type":"text/x-python","patch_set":9,"id":"1a4dcd0f_2fe4430b","line":127,"in_reply_to":"3a50d1a3_9222e550","updated":"2015-08-05 09:31:12.000000000","message":"Well, maybe not:\n\n\u003e\u003e\u003e frozenset({\u0027x\u0027: []}.items())\n\nTraceback (most recent call last):\n\n  File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\n\nTypeError: unhashable type: \u0027list\u0027","commit_id":"a383f4f641818be953f5e6099ba8138a8cc09597"}],"neutron/tests/unit/db/test_db_base_plugin_v2.py":[{"author":{"_account_id":9107,"name":"Victor Stinner","email":"vstinner@redhat.com","username":"haypo"},"change_message_id":"7179e2050557fb6364080451175a2febe8a70abe","unresolved":false,"context_lines":[{"line_number":731,"context_line":"            self.assertIn(k, resource[res_name])"},{"line_number":732,"context_line":"            if isinstance(keys[k], list):"},{"line_number":733,"context_line":"                self.assertEqual("},{"line_number":734,"context_line":"                     sorted(resource[res_name][k], key\u003dtools.safe_hash),"},{"line_number":735,"context_line":"                     sorted(keys[k], key\u003dtools.safe_hash))"},{"line_number":736,"context_line":"            else:"},{"line_number":737,"context_line":"                self.assertEqual(resource[res_name][k], keys[k])"}],"source_content_type":"text/x-python","patch_set":4,"id":"3a50d1a3_f70405c7","line":734,"updated":"2015-07-27 08:11:47.000000000","message":"I don\u0027t think that it\u0027s correct to use an hash function to sort items.\n\nIt\u0027s safer to build a tuple of items. I suggest the function:\n\ndef sort_func(obj):\n  if isinstance(obj, dict):\n    return sorted(obj.items())\n  return obj\n\nI used it in various OpenStack functions.\n\nSee also: https://review.openstack.org/#/c/205068/1/neutron/tests/tools.py","commit_id":"8b771076d9138b022e52f32c9c4b0fb9e3fe535c"},{"author":{"_account_id":6854,"name":"YAMAMOTO Takashi","email":"yamamoto@midokura.com","username":"yamamoto"},"change_message_id":"67ef9c2b479ac3354bef487a055a50d19d0e3afd","unresolved":false,"context_lines":[{"line_number":731,"context_line":"            self.assertIn(k, resource[res_name])"},{"line_number":732,"context_line":"            if isinstance(keys[k], list):"},{"line_number":733,"context_line":"                self.assertEqual("},{"line_number":734,"context_line":"                     sorted(resource[res_name][k], key\u003dtools.safe_hash),"},{"line_number":735,"context_line":"                     sorted(keys[k], key\u003dtools.safe_hash))"},{"line_number":736,"context_line":"            else:"},{"line_number":737,"context_line":"                self.assertEqual(resource[res_name][k], keys[k])"}],"source_content_type":"text/x-python","patch_set":4,"id":"3a50d1a3_7ab2ae07","line":734,"in_reply_to":"3a50d1a3_f70405c7","updated":"2015-07-29 04:25:34.000000000","message":"+1","commit_id":"8b771076d9138b022e52f32c9c4b0fb9e3fe535c"},{"author":{"_account_id":9107,"name":"Victor Stinner","email":"vstinner@redhat.com","username":"haypo"},"change_message_id":"760456049ad7dddbf3d9506e0874353a48fdb27a","unresolved":false,"context_lines":[{"line_number":731,"context_line":"            self.assertIn(k, resource[res_name])"},{"line_number":732,"context_line":"            if isinstance(keys[k], list):"},{"line_number":733,"context_line":"                self.assertEqual("},{"line_number":734,"context_line":"                     sorted(resource[res_name][k], key\u003dtools.safe_hash),"},{"line_number":735,"context_line":"                     sorted(keys[k], key\u003dtools.safe_hash))"},{"line_number":736,"context_line":"            else:"},{"line_number":737,"context_line":"                self.assertEqual(resource[res_name][k], keys[k])"}],"source_content_type":"text/x-python","patch_set":7,"id":"3a50d1a3_97441a47","line":734,"updated":"2015-07-29 13:55:03.000000000","message":"Sorry, I vote +1 in a previous patch set, but my previous comment is still up to date:\nhttps://review.openstack.org/#/c/204792/4/neutron/tests/unit/db/test_db_base_plugin_v2.py\n\nYou should not use a hash to sort items. The key function should return a list of items instead:\n\ndef sort_func(obj):\n    if isinstance(obj, collections.Mapping):\n        return sorted(obj.items())\n    return obj\n\nYou may put this function in this file. And maybe move it later to tools if it\u0027s used in many other files.","commit_id":"2b1e7d7ee9324ce4d1f894b7d827feee7bb760d4"}],"tox.ini":[{"author":{"_account_id":748,"name":"Armando Migliaccio","email":"armamig@gmail.com","username":"armando-migliaccio"},"change_message_id":"0777a49490bbfb56fd6e53d78295ac2b702178f3","unresolved":false,"context_lines":[{"line_number":125,"context_line":"    neutron.tests.unit.plugins.oneconvergence.test_nvsdlib \\"},{"line_number":126,"context_line":"    neutron.tests.unit.plugins.ibm.test_sdnve_agent \\"},{"line_number":127,"context_line":"    neutron.tests.unit.plugins.ibm.test_sdnve_api \\"},{"line_number":128,"context_line":"    neutron.tests.unit.plugins.ibm.test_sdnve_plugin \\"},{"line_number":129,"context_line":"    neutron.tests.unit.plugins.ml2.test_db \\"},{"line_number":130,"context_line":"    neutron.tests.unit.plugins.ml2.test_driver_context \\"},{"line_number":131,"context_line":"    neutron.tests.unit.plugins.ml2.test_port_binding \\"}],"source_content_type":"text/x-properties","patch_set":12,"id":"da20952f_d3b2be4b","line":128,"updated":"2015-08-31 18:32:19.000000000","message":"This test has been removed here:\n\nhttps://review.openstack.org/#/c/217703/","commit_id":"c112e22ecbaef1854c9d79b24f9a69c19eb6a9cc"},{"author":{"_account_id":748,"name":"Armando Migliaccio","email":"armamig@gmail.com","username":"armando-migliaccio"},"change_message_id":"0777a49490bbfb56fd6e53d78295ac2b702178f3","unresolved":false,"context_lines":[{"line_number":153,"context_line":"    neutron.tests.unit.plugins.ml2.drivers.l2pop.rpc_manager.test_l2population_rpc \\"},{"line_number":154,"context_line":"    neutron.tests.unit.plugins.ml2.drivers.l2pop.test_mech_driver \\"},{"line_number":155,"context_line":"    neutron.tests.unit.plugins.cisco.n1kv.test_n1kv_db \\"},{"line_number":156,"context_line":"    neutron.tests.unit.plugins.cisco.n1kv.test_n1kv_plugin \\"},{"line_number":157,"context_line":"    neutron.tests.unit.plugins.cisco.n1kv.fake_client \\"},{"line_number":158,"context_line":"    neutron.tests.unit.plugins.cisco.test_network_db \\"},{"line_number":159,"context_line":"    neutron.tests.unit.scheduler.test_l3_agent_scheduler \\"}],"source_content_type":"text/x-properties","patch_set":12,"id":"da20952f_737ad289","line":156,"updated":"2015-08-31 18:32:19.000000000","message":"this test is being removed here:\n\nhttps://review.openstack.org/#/c/212209/","commit_id":"c112e22ecbaef1854c9d79b24f9a69c19eb6a9cc"}]}
