From c296652f441e48f73db58eed264591c9266a2139 2009-09-14 03:17:34 From: Brian Granger Date: 2009-09-14 03:17:34 Subject: [PATCH] Fixed Python 2.6 warning with traitlets object.__new__. In Python 2.6 a warning is given if object.__new__ is called with anything more than first cls argument. We are using super so we needed a way to see of the __new__ method about to be called is object.__new__. --- diff --git a/IPython/utils/traitlets.py b/IPython/utils/traitlets.py index b02e165..98c0613 100644 --- a/IPython/utils/traitlets.py +++ b/IPython/utils/traitlets.py @@ -342,7 +342,13 @@ class HasTraitlets(object): __metaclass__ = MetaHasTraitlets def __new__(cls, *args, **kw): - inst = super(HasTraitlets, cls).__new__(cls, *args, **kw) + # This is needed because in Python 2.6 object.__new__ only accepts + # the cls argument. + new_meth = super(HasTraitlets, cls).__new__ + if new_meth is object.__new__: + inst = new_meth(cls) + else: + inst = new_meth(cls, *args, **kw) inst._traitlet_values = {} inst._traitlet_notifiers = {} # Here we tell all the TraitletType instances to set their default