Fix dict compare for cmp function.

When passed 2 dicts, the cmp function would fail with a TypeError of "'>' not supported between instances of 'dict' and 'dict'\n". This change adds a check for dict types and compares them with ==.
This commit is contained in:
11chrisadams11 2020-10-13 16:02:07 -06:00 committed by Twangboy
parent ad5a80da42
commit 494c6391f6
No known key found for this signature in database
GPG key ID: ED267D5C0DE6F8A6

View file

@ -61,6 +61,8 @@ def cmp(x, y):
Return negative if x<y, zero if x==y, positive if x>y.
"""
if isinstance(x, dict) and isinstance(y, dict):
return 0 if x == y else -1
return (x > y) - (x < y)