Commit 52a0fc1
committed
Fix Advisory.__hash__()
The hash is computed from a string, which is built by iterating over
attributes of type Iterable/Sequence, such as impacted_package_urls.
This change sorts those attributes before concatenating to the string,
to avoid different hashes when the order of impacted_package_urls, etc
differs.
NB A better solution would be to avoid implementing __hash__() and use
immutable collections like tuple and frozenset for the above mentioned
attributes instead.
See https://eng.lyft.com/hashing-and-equality-in-python-2ea8c738fb9d
Signed-off-by: Haiko Schol <hs@haikoschol.com>1 parent 4f5caea commit 52a0fc1
1 file changed
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
65 | | - | |
66 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| |||
0 commit comments