Skip to content

Commit 650ae20

Browse files
author
Kevin Pyle
committed
Set missing docstrings to NULL ptr, not (char*)"NULL"
Add a convenience function that knows not to quote the keyword NULL.
1 parent 3deef0a commit 650ae20

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cpybuilder.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ def nullable_ptr(ptr):
3232
else:
3333
return 'NULL'
3434

35+
def nullable_strptr(s,caststr='char*'):
36+
if s:
37+
return '(%s)"%s"' % (caststr,s)
38+
else:
39+
return 'NULL'
40+
3541
def simple_unaryfunc(identifier, typename, c_expression):
3642
"""Define a simple unaryfunc, using a specifc PyObject subclass"""
3743
self.add_defn("static PyObject *\n" +
@@ -97,7 +103,7 @@ def c_defn(self):
97103
result = ' {(char*)"%s",\n' % self.name
98104
result += ' (getter)%s,\n' % nullable_ptr(self.get)
99105
result += ' (setter)%s,\n' % nullable_ptr(self.set)
100-
result += ' (char*)"%s",\n' % nullable_ptr(self.doc)
106+
result += ' %s,\n' % nullable_strptr(self.doc)
101107
result += ' %s},\n' % nullable_ptr(self.closure)
102108
return result
103109

0 commit comments

Comments
 (0)