From f5c403df21075f9d11dac3d852e6652b6e0fb81a 2015-03-20 17:04:42 From: Min RK Date: 2015-03-20 17:04:42 Subject: [PATCH] catch RuntimeError getting `obj._trait_validate` Qt mixins raise RuntimeError on undefined methods when called before `__init__`. Methods defined in Python will be found. --- diff --git a/IPython/utils/traitlets.py b/IPython/utils/traitlets.py index 297cd07..3c9545f 100644 --- a/IPython/utils/traitlets.py +++ b/IPython/utils/traitlets.py @@ -457,8 +457,13 @@ class TraitType(object): return value if hasattr(self, 'validate'): value = self.validate(obj, value) - if hasattr(obj, '_%s_validate' % self.name): - value = getattr(obj, '_%s_validate' % self.name)(value, self) + try: + obj_validate = getattr(obj, '_%s_validate' % self.name) + except (AttributeError, RuntimeError): + # Qt mixins raise RuntimeError on missing attrs accessed before __init__ + pass + else: + value = obj_validate(value, self) return value def __or__(self, other):