r20564 - gnucash/branches/2.4/src/optional/python-bindings - [20479] Bug #644762: Deprecated __new__() call in function_class.py

Christian Stimming cstim at code.gnucash.org
Sun Apr 17 15:05:18 EDT 2011


Author: cstim
Date: 2011-04-17 15:05:18 -0400 (Sun, 17 Apr 2011)
New Revision: 20564
Trac: http://svn.gnucash.org/trac/changeset/20564

Modified:
   gnucash/branches/2.4/src/optional/python-bindings/function_class.py
Log:
[20479] Bug #644762: Deprecated __new__() call in function_class.py

Patch by Sara Arenson:

Patch to fix the deprecated __new__() call in function_class.py

When you create an object of type ClassFromFunctions (a subclass of object),
you get the following warning:

/opt/gnucash-2.4.0/lib/python2.6/site-packages/gnucash/function_class.py:55:
DeprecationWarning: object.__new__() takes no parameters
  return super(ClassFromFunctions, cls).__new__(cls, *args, **kargs)

As per Python docs (http://docs.python.org/reference/datamodel.html), __new__()
accepts class name and a list of arguments for the object's constructor.  Since
ClassFromFunctions's superclass's constructor has no arguments, we should not
be passing *args and **kargs.

Modified: gnucash/branches/2.4/src/optional/python-bindings/function_class.py
===================================================================
--- gnucash/branches/2.4/src/optional/python-bindings/function_class.py	2011-04-17 19:05:07 UTC (rev 20563)
+++ gnucash/branches/2.4/src/optional/python-bindings/function_class.py	2011-04-17 19:05:18 UTC (rev 20564)
@@ -52,7 +52,7 @@
         # use new to avoid creating new instances when existing instances
         # already exist with the same __instance value, or equivlent __instance
         # values, where this is desirable...
-        return super(ClassFromFunctions, cls).__new__(cls, *args, **kargs)
+        return super(ClassFromFunctions, cls).__new__(cls)
     
     def __init__(self, *args, **kargs):
         """Construct a new instance, using either the function



More information about the gnucash-changes mailing list