Fix invisible special methods.
authorRobert Bradshaw <robertwb@math.washington.edu>
Sun, 15 Aug 2010 08:06:51 +0000 (01:06 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Sun, 15 Aug 2010 08:06:51 +0000 (01:06 -0700)
Cython/Compiler/ModuleNode.py
Cython/Compiler/Nodes.py
Cython/Compiler/TypeSlots.py

index cfc04096daf7efba351d866db096a5c45cc8daac..204dd8e30bdf998fe144b3112fa9fd1adda30fe8 100644 (file)
@@ -2045,7 +2045,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
                 # unless we let PyType_Ready create the slot wrappers we have
                 # a significant performance hit. (See trac #561.) 
                 for func in entry.type.scope.pyfunc_entries:
-                    if func.is_special and func.doc:
+                    if func.is_special and func.wrapperbase_cname:
                         code.putln("{");
                         code.putln(
                             'PyObject *wrapper = PyObject_GetAttrString((PyObject *)&%s, "%s"); %s' % (
index 5c0d273b3cdc5b5b91cc562598cc5e5e8f4d790f..349c9b86233040957f89a1b875f55802ae2d6b49 100644 (file)
@@ -2111,7 +2111,10 @@ class DefNode(FuncDefNode):
             entry.doc_cname = \
                 Naming.funcdoc_prefix + prefix + name
             if entry.is_special:
-                entry.wrapperbase_cname = Naming.wrapperbase_prefix + prefix + name
+                if entry.name in TypeSlots.invisible or not entry.doc:
+                    entry.wrapperbase_cname = None
+                else:
+                    entry.wrapperbase_cname = Naming.wrapperbase_prefix + prefix + name
         else:
             entry.doc = None
 
@@ -2226,7 +2229,8 @@ class DefNode(FuncDefNode):
         if proto_only:
             return
         if (Options.docstrings and self.entry.doc and
-                not self.entry.scope.is_property_scope):
+                not self.entry.scope.is_property_scope and
+                (not self.entry.is_special or self.entry.wrapperbase_cname)):
             docstr = self.entry.doc
             if docstr.is_unicode:
                 docstr = docstr.utf8encode()
index 9b35ec881110ec0ad9f7ae4d6dc9aa6e48a16e0b..1745e6641e2685d4d8cb0a33b814ffd08ea12f71 100644 (file)
@@ -8,6 +8,9 @@ import PyrexTypes
 import StringEncoding
 import sys
 
+invisible = ['__cinit__', '__dealloc__', '__richcmp__', 
+             '__nonzero__', '__bool__']
+
 class Signature(object):
     #  Method slot signature descriptor.
     #