Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[patch] find parent module before calling .check_private() #36

Open
GoogleCodeExporter opened this issue Aug 5, 2015 · 0 comments
Open

Comments

@GoogleCodeExporter
Copy link

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

Original issue reported on code.google.com by [email protected] on 27 Jan 2012 at 2:43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant