From: W. Trevor King Date: Thu, 3 Mar 2011 14:33:55 +0000 (-0500) Subject: Add Binding.visibility_string() for composing error messages. X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=01fe320c3ef9da3c015d9c010222419480792ccb;p=cython.git Add Binding.visibility_string() for composing error messages. --- diff --git a/Cython/Compiler/Binding.py b/Cython/Compiler/Binding.py index 12e078b1..0097c326 100644 --- a/Cython/Compiler/Binding.py +++ b/Cython/Compiler/Binding.py @@ -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) + diff --git a/Cython/Compiler/Parsing.py b/Cython/Compiler/Parsing.py index fe6dde20..5644a355 100644 --- a/Cython/Compiler/Parsing.py +++ b/Cython/Compiler/Parsing.py @@ -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,