Ensure that object.__new__ never gets called with arguments

This commit is contained in:
Mike Croucher 2015-02-28 18:36:52 +00:00
parent b4a3253e26
commit a6e28205e1

View file

@ -148,7 +148,11 @@ class LogGaussian(Gaussian):
for instance in cls._instances:
if instance().mu == mu and instance().sigma == sigma:
return instance()
o = super(Prior, cls).__new__(cls, mu, sigma)
newfunc = super(Prior, cls).__new__
if newfunc is object.__new__:
o = newfunc(cls)
else:
o = newfunc(cls, mu, sigma)
cls._instances.append(weakref.ref(o))
return cls._instances[-1]()