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

Analyzing an __init__.py in cwd crashes Pyan #9

Closed
Technologicat opened this issue Jun 25, 2019 · 4 comments
Closed

Analyzing an __init__.py in cwd crashes Pyan #9

Technologicat opened this issue Jun 25, 2019 · 4 comments
Labels

Comments

@Technologicat
Copy link
Owner

The scope naming internals of objects at the top level of a module seem to have changed somewhere between Python 3.4 and 3.6.

This code used to work in Python 3.4 (pyan/analyzer.py, method analyze_scopes):

ns = "%s.%s" % (parent_ns, sc.name) if len(sc.name) else parent_ns

but in Python 3.6.8, I'm now getting names like ".some_top_level_object" (note silly leading dot).

Now parent_ns is empty, and the object name is returned in sc.name. It used to be the other way around.

Seems this needs code to handle both cases...

@Technologicat
Copy link
Owner Author

...or maybe it's the fact I'm now trying to analyze a nontrivial __init__.py? Debugging...

@Technologicat
Copy link
Owner Author

...which is in the cwd (see anutils.py, function get_module_name).

@Technologicat
Copy link
Owner Author

Yep, analyzing an __init__.py in cwd was the actual culprit.

@Technologicat Technologicat changed the title Scope naming internals changed in Python 3.6? __init__.py in cwd crashes Pyan Jun 25, 2019
@Technologicat Technologicat changed the title __init__.py in cwd crashes Pyan Analyzing an __init__.py in cwd crashes Pyan Jun 25, 2019
@Technologicat
Copy link
Owner Author

Let's document also the fact that nontrivial here means that the __init__.py defines functions and/or classes, so something for Pyan to pick up.

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

No branches or pull requests

1 participant