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

[2.0 bugs] A lookup in numpy infinitely recurses due to an interaction between a C extension and Python module #262

Open
pylint-bot opened this issue Nov 22, 2015 · 2 comments
Labels

Comments

@pylint-bot
Copy link
Owner

Originally reported by: BitBucket: ceridwenv, GitHub: ceridwenv


test_numpy_crash fails (at least on Python 3) because, while trying to process an instance of ufunc, it looks up ufunc's type which has a declared module of numpy. It thus imports numpy's __init__.py, which contains from .core import *, and then tries to look up ufunc in that module. Eventually, it encounters a C extension, tries to analyze it using ast_from_object, and finds ufunc, only ufunc, being a type implemented in C, declares that its module is numpy, which sets off the infinite recursion because ast_from_object creates an ImportFrom node for it.

There are a number of possible fixes, I'm not immediately sure which would be best.


@pylint-bot
Copy link
Owner Author

Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: PCManticore):


What fixes do you have in mind?

@pylint-bot
Copy link
Owner Author

Original comment by BitBucket: ceridwenv, GitHub: ceridwenv:


I don't have any good ones, I'm afraid. One solution is to simply abandon all attempts to determine which module an object came from and, when building a mock AST for a live object, treat all objects as if they came from the same module. This definitely has its advantages, as handling imports is a major source of complexity in the ast_from_object code and the reason it needs to import manager and has to do shenanigans with lazy objects. However, this loses a lot of information and makes ast_from_object much less useful for analyzing dependencies involving C extensions. Another solution is to try to explicitly detect cycles like this, which will be complicated and hard to get right because the cycles involved can be arbitrarily complicated, and leaves open the question of, assuming it's found a cycle, how does it decide where to put the object?

@pylint-bot pylint-bot added the bug label Dec 7, 2015
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