Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[mypyc] Fix using package imported inside a function - #9782

Merged
JukkaL merged 3 commits into
masterfrom
fix-local-import
Dec 8, 2020
Merged

[mypyc] Fix using package imported inside a function#9782
JukkaL merged 3 commits into
masterfrom
fix-local-import

Conversation

@JukkaL

@JukkaL JukkaL commented Dec 6, 2020

Copy link
Copy Markdown
Collaborator

Fix an issue where this code resulted in an unbound local p
error:

def f() -> None:
    import p.submodule
    print(p.x)  # Runtime error here

We now look up p from the global modules dictionary instead
of trying to use an undefined local variable.

This fixes an issue where this code resulted in an unbound local `p`
error:

```
def f() -> None:
    import p.submodule
    print(p.x)  # Runtime error here
```

We now look up `p` from the global modules dictionary instead
of trying to use an undefined local variable.
@JukkaL
JukkaL merged commit eac1897 into master Dec 8, 2020
@JukkaL
JukkaL deleted the fix-local-import branch December 8, 2020 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants