SerializableConfigParser: Make Loads class indep
authorGuido Trotter <ultrotter@google.com>
Wed, 24 Mar 2010 15:42:39 +0000 (15:42 +0000)
committerGuido Trotter <ultrotter@google.com>
Thu, 25 Mar 2010 12:47:03 +0000 (12:47 +0000)
Currently SerializableConfigParser.Loads is a static method that returns
a SerializableConfigParser. With this patch we change it to a class
method that returns a member of the class. This way a subclass calling
Loads on itself will get its own member, rather than a bare
SerializableConfigParser.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Balazs Lecz <leczb@google.com>

lib/objects.py

index b2d8672..5ee6ddf 100644 (file)
@@ -1034,10 +1034,10 @@ class SerializableConfigParser(ConfigParser.SafeConfigParser):
     self.write(buf)
     return buf.getvalue()
 
-  @staticmethod
-  def Loads(data):
+  @classmethod
+  def Loads(cls, data):
     """Load data from a string."""
     buf = StringIO(data)
-    cfp = SerializableConfigParser()
+    cfp = cls()
     cfp.readfp(buf)
     return cfp