fix dict eq() checks
This commit is contained in:
parent
477feb777b
commit
71c4807559
@ -11,6 +11,7 @@ import numpy as np
|
||||
import decimal, re
|
||||
import ctypes
|
||||
import sys, struct
|
||||
from .pgcollections import OrderedDict
|
||||
from .python2_3 import asUnicode, basestring
|
||||
from .Qt import QtGui, QtCore, QT_LIB
|
||||
from . import getConfigOption, setConfigOptions
|
||||
@ -446,11 +447,15 @@ def eq(a, b):
|
||||
if isinstance(a, dict) and isinstance(b, dict):
|
||||
if type(a) != type(b) or len(a) != len(b):
|
||||
return False
|
||||
if sorted(a.keys()) != sorted(b.keys()):
|
||||
if set(a.keys()) != set(b.keys()):
|
||||
return False
|
||||
for k,v in a.items():
|
||||
for k, v in a.items():
|
||||
if not eq(v, b[k]):
|
||||
return False
|
||||
if isinstance(a, OrderedDict) or sys.version_info >= (3, 7):
|
||||
for a_item, b_item in zip(a.items(), b.items()):
|
||||
if not eq(a_item, b_item):
|
||||
return False
|
||||
return True
|
||||
if isinstance(a, (list, tuple)) and isinstance(b, (list, tuple)):
|
||||
if type(a) != type(b) or len(a) != len(b):
|
||||
|
Loading…
Reference in New Issue
Block a user