New issue 36 by james.ke...@gmail.com: [patch] find parent module before
calling .check_private()
http://code.google.com/p/f2py/issues/detail?id=36
This patch walks up the parse tree from a Variable to find the containing
module, rather than assuming all Variables are two levels below the module,
which breaks for module-level variables.
diff -r c5b88e996b11 -r 732d6b540026 fparser/base_classes.py
--- a/fparser/base_classes.py Fri Jan 27 14:26:10 2012 +0000
+++ b/fparser/base_classes.py Fri Jan 27 14:29:58 2012 +0000
@@ -282,7 +282,11 @@
def is_private(self):
if 'PUBLIC' in self.attributes: return False
if 'PRIVATE' in self.attributes: return True
- return self.parent.parent.check_private(self.name)
+
+ mod = self.parent
+ while not hasattr(mod, 'check_private'):
+ mod = mod.parent
+ return mod.check_private(self.name)
def is_public(self): return not self.is_private()
def is_allocatable(self): return 'ALLOCATABLE' in self.attributes