From 221ef93e503928bbc23a7b793088d8ca5f58c215 Mon Sep 17 00:00:00 2001 From: Dag Sverre Seljebotn Date: Thu, 15 Oct 2009 21:28:41 +0200 Subject: [PATCH] Incomplete hack for autotestdict, see #387 --- Cython/Compiler/AnalysedTreeTransforms.py | 4 ++++ tests/run/autotestdict.pyx | 20 +++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Cython/Compiler/AnalysedTreeTransforms.py b/Cython/Compiler/AnalysedTreeTransforms.py index 3f01e20d..bf57cf16 100644 --- a/Cython/Compiler/AnalysedTreeTransforms.py +++ b/Cython/Compiler/AnalysedTreeTransforms.py @@ -10,6 +10,8 @@ import Naming class AutoTestDictTransform(ScopeTrackingTransform): # Handles autotestdict directive + blacklist = ['__cinit__', '__dealloc__'] + def visit_ModuleNode(self, node): self.scope_type = 'module' self.scope_node = node @@ -62,6 +64,8 @@ class AutoTestDictTransform(ScopeTrackingTransform): parent = ModuleRefNode(pos) name = node.entry.name elif self.scope_type in ('pyclass', 'cclass'): + if self.scope_type == 'cclass' and node.name in self.blacklist: + return node mod = ModuleRefNode(pos) if self.scope_type == 'pyclass': clsname = self.scope_node.name diff --git a/tests/run/autotestdict.pyx b/tests/run/autotestdict.pyx index 32e90b51..8b2d824d 100644 --- a/tests/run/autotestdict.pyx +++ b/tests/run/autotestdict.pyx @@ -61,7 +61,7 @@ class MyClass: >>> True True """ - + def method(self): """>>> add_log("class method")""" @@ -75,3 +75,21 @@ cdef class MyCdefClass: def method(self): """>>> add_log("cdef class method")""" + def __cinit__(self): + """ + Should not be included, as it can't be looked up with getattr + + >>> True + False + """ + + def __dealloc__(self): + """ + Should not be included, as it can't be looked up with getattr + + >>> True + False + """ + + + -- 2.26.2