]> granicus.if.org Git - python/commitdiff
Oops, repr didn't allocate the memory it used...
authorJack Jansen <jack.jansen@cwi.nl>
Sun, 11 Feb 2001 01:12:53 +0000 (01:12 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Sun, 11 Feb 2001 01:12:53 +0000 (01:12 +0000)
Mac/Modules/win/Winmodule.c
Mac/Modules/win/winsupport.py

index 0ff5733e23cbe0de4856ee3f6f44cbf9226b84ca..0aa6e11c4571768c3f4059620a5bcf9f78beb2d7 100644 (file)
@@ -2310,7 +2310,13 @@ static int WinObj_compare(self, other)
        return 0;
 }
 
-#define WinObj_repr NULL
+static PyObject * WinObj_repr(self)
+       WindowObject *self;
+{
+       char buf[100];
+       sprintf(buf, "<Window object at 0x%08.8x for 0x%08.8x>", self, self->ob_itself);
+       return PyString_FromString(buf);
+}
 
 static int WinObj_hash(self)
        WindowObject *self;
index 6b67db1fc1929403f3e828b99214b99e773748e2..6054e263d39b3c73db19d75dffa0da69ebe8fa29 100644 (file)
@@ -156,6 +156,18 @@ class MyObjectDefinition(GlobalObjectDefinition):
                Output("return (int)self->ob_itself;")
                OutRbrace()
                
+       def outputRepr(self):
+               Output()
+               Output("static PyObject * %s_repr(self)", self.prefix)
+               IndentLevel()
+               Output("%s *self;", self.objecttype)
+               DedentLevel()
+               OutLbrace()
+               Output("char buf[100];")
+               Output("""sprintf(buf, "<Window object at 0x%%08.8x for 0x%%08.8x>", self, self->ob_itself);""")
+               Output("return PyString_FromString(buf);")
+               OutRbrace()
+               
 ##     def outputFreeIt(self, itselfname):
 ##             Output("DisposeWindow(%s);", itselfname)
 # From here on it's basically all boiler plate...