From 8f81bdac8f4cd7f2b2a5b364ebd7d3b9a3c2d333 2015-03-20 17:29:10 From: Thomas Kluyver Date: 2015-03-20 17:29:10 Subject: [PATCH] Merge pull request #8099 from minrk/catch-runtime-trait catch RuntimeError getting `obj._trait_validate` --- 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):