You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import copy
import pyswagger
m = pyswagger.primitives._model.Model()
nm = copy.deepcopy(m)
Got:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-156-f6bcd0227185> in <module>()
----> 1 nm = deepcopy(m)
/usr/lib64/python2.7/copy.pyc in deepcopy(x, memo, _nil)
170 y = _deepcopy_atomic(x, memo)
171 else:
--> 172 copier = getattr(x, "__deepcopy__", None)
173 if copier:
174 y = copier(memo)
KeyError: '__deepcopy__'
This is because of using dict.__getitem__ as __getattr__ in the Model class. On the occasion that an attribute is not found, it throws a KeyError instead of an AttributeError and it's not handled by python's getattr function.
The text was updated successfully, but these errors were encountered:
Example:
Got:
This is because of using
dict.__getitem__
as__getattr__
in theModel
class. On the occasion that an attribute is not found, it throws a KeyError instead of an AttributeError and it's not handled by python'sgetattr
function.The text was updated successfully, but these errors were encountered: