Add Binding.visibility_string() for composing error messages.
authorW. Trevor King <wking@drexel.edu>
Thu, 3 Mar 2011 14:33:55 +0000 (09:33 -0500)
committerW. Trevor King <wking@drexel.edu>
Thu, 3 Mar 2011 14:33:55 +0000 (09:33 -0500)
Cython/Compiler/Binding.py
Cython/Compiler/Parsing.py

index 12e078b1d7e21907e8535a06ed39a18a2682e906..0097c326960a389a71d6619f6210a75cab14c328 100644 (file)
@@ -104,4 +104,12 @@ class PythonBinding(_BindingAttributes):
 
 class Binding(CSource, CBinding, PythonBinding):
     "Combine all binding attributes in a single, flat namespace."
-    pass
+    def visibility_string(self):
+        "Summarize binding visibility in a single string"
+        if self.extern:
+            extern_string = ' (extern)'
+        else:
+            extern_string = ''
+        return 'C: %s%s, Python: %s' % (
+            self.c_visibility, extern_string, self.visibility)
+            
index fe6dde2019a692b84b63eee884f85cd0e111241c..5644a355bac20b94f61e1c6c4fcef64148909342 100644 (file)
@@ -2946,7 +2946,7 @@ def p_c_class_definition(s, pos,  ctx, decorators=None):
         if ctx.api:
             error(pos, "Only 'public' C class can be declared 'api'")
     else:
-        error(pos, "Invalid class visibility '%s'" % visibility)
+        error(pos, "Invalid class visibility '%s'" % ctx.visibility_string())
     return Nodes.CClassDefNode(pos,
         extern = ctx.extern,
         c_visibility = ctx.c_visibility,