Skip to content

Commit 3f49e4d

Browse files
committed
Oops, repr didn't allocate the memory it used...
1 parent 8a38714 commit 3f49e4d

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

Mac/Modules/win/Winmodule.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2310,7 +2310,13 @@ static int WinObj_compare(self, other)
23102310
return 0;
23112311
}
23122312

2313-
#define WinObj_repr NULL
2313+
static PyObject * WinObj_repr(self)
2314+
WindowObject *self;
2315+
{
2316+
char buf[100];
2317+
sprintf(buf, "<Window object at 0x%08.8x for 0x%08.8x>", self, self->ob_itself);
2318+
return PyString_FromString(buf);
2319+
}
23142320

23152321
static int WinObj_hash(self)
23162322
WindowObject *self;

Mac/Modules/win/winsupport.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,18 @@ def outputHash(self):
156156
Output("return (int)self->ob_itself;")
157157
OutRbrace()
158158

159+
def outputRepr(self):
160+
Output()
161+
Output("static PyObject * %s_repr(self)", self.prefix)
162+
IndentLevel()
163+
Output("%s *self;", self.objecttype)
164+
DedentLevel()
165+
OutLbrace()
166+
Output("char buf[100];")
167+
Output("""sprintf(buf, "<Window object at 0x%%08.8x for 0x%%08.8x>", self, self->ob_itself);""")
168+
Output("return PyString_FromString(buf);")
169+
OutRbrace()
170+
159171
## def outputFreeIt(self, itselfname):
160172
## Output("DisposeWindow(%s);", itselfname)
161173
# From here on it's basically all boiler plate...

0 commit comments

Comments
 (0)