From bf6f3c10bd906469154300d24fa4f57e85006b72 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Thu, 11 Nov 2010 22:13:47 +0100 Subject: [PATCH] Visitor cleanup: mark internal (cdef) methods with leading underscore in .py files --- Cython/Compiler/Visitor.pxd | 4 ++-- Cython/Compiler/Visitor.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cython/Compiler/Visitor.pxd b/Cython/Compiler/Visitor.pxd index d72acc16..00ddb177 100644 --- a/Cython/Compiler/Visitor.pxd +++ b/Cython/Compiler/Visitor.pxd @@ -4,11 +4,11 @@ cdef class BasicVisitor: cdef dict dispatch_table cpdef visit(self, obj) cdef _visit(self, obj) - cdef find_handler(self, obj) + cdef _find_handler(self, obj) cdef class TreeVisitor(BasicVisitor): cdef public list access_path - cdef visitchild(self, child, parent, attrname, idx) + cdef _visitchild(self, child, parent, attrname, idx) @cython.locals(idx=int) cdef dict _visitchildren(self, parent, attrs) cpdef visitchildren(self, parent, attrs=*) diff --git a/Cython/Compiler/Visitor.py b/Cython/Compiler/Visitor.py index 6b89cca9..545f855b 100644 --- a/Cython/Compiler/Visitor.py +++ b/Cython/Compiler/Visitor.py @@ -26,11 +26,11 @@ class BasicVisitor(object): try: handler_method = self.dispatch_table[type(obj)] except KeyError: - handler_method = self.find_handler(obj) + handler_method = self._find_handler(obj) self.dispatch_table[type(obj)] = handler_method return handler_method(obj) - def find_handler(self, obj): + def _find_handler(self, obj): cls = type(obj) #print "Cache miss for class %s in visitor %s" % ( # cls.__name__, type(self).__name__) @@ -176,7 +176,7 @@ class TreeVisitor(BasicVisitor): last_node.pos, self.__class__.__name__, u'\n'.join(trace), e, stacktrace) - def visitchild(self, child, parent, attrname, idx): + def _visitchild(self, child, parent, attrname, idx): self.access_path.append((parent, attrname, idx)) try: result = self._visit(child) @@ -209,9 +209,9 @@ class TreeVisitor(BasicVisitor): child = getattr(parent, attr) if child is not None: if type(child) is list: - childretval = [self.visitchild(x, parent, attr, idx) for idx, x in enumerate(child)] + childretval = [self._visitchild(x, parent, attr, idx) for idx, x in enumerate(child)] else: - childretval = self.visitchild(child, parent, attr, None) + childretval = self._visitchild(child, parent, attr, None) assert not isinstance(childretval, list), 'Cannot insert list here: %s in %r' % (attr, parent) result[attr] = childretval return result -- 2.26.2