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

Problems using reexported values #393

Closed
msullivan opened this issue Aug 17, 2018 · 0 comments · Fixed by python/mypy#7496
Closed

Problems using reexported values #393

msullivan opened this issue Aug 17, 2018 · 0 comments · Fixed by python/mypy#7496

Comments

@msullivan
Copy link
Collaborator

With the following test:

[case testReexport]
import a
def f(x: int) -> int:
    return a.g(x)

[file a.py]
from b import g

[file b.py]
def g(x: int) -> int:
    return x + 1

we fail to compile during C compilation with the failure:

/tmp/mypy-test-_hn916r6/tmp/native.c: In function ‘CPyDef_f’:
/tmp/mypy-test-_hn916r6/tmp/native.c:78:16: error: ‘CPyStatic_b_module’ undeclared (first use in this function); did you mean ‘CPyStatic_a_module’?

The problem here is that the name of the def a.g is resolved to is b.g, and b isn't imported.

It is easy to hack around, though.

msullivan added a commit to python/mypy that referenced this issue Sep 11, 2019
There are a couple parts to this:
 * Compile module attribute accesses by compiling the LHS on its own
   instead of by loading its fullname (which will be what mypy thinks
   its source is)
 * Only use the static modules if they have actually been imported

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

Successfully merging a pull request may close this issue.

1 participant