From 01fe320c3ef9da3c015d9c010222419480792ccb Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 3 Mar 2011 09:33:55 -0500 Subject: [PATCH] Add Binding.visibility_string() for composing error messages. --- Cython/Compiler/Binding.py | 10 +++++++++- Cython/Compiler/Parsing.py | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) 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, -- 2.26.2