Skip to content

locals() dict share actual local variable #1356

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

Closed
HyeockJinKim opened this issue Sep 8, 2019 · 1 comment · Fixed by #1508
Closed

locals() dict share actual local variable #1356

HyeockJinKim opened this issue Sep 8, 2019 · 1 comment · Fixed by #1508
Labels
C-compat A discrepancy between RustPython and CPython

Comments

@HyeockJinKim
Copy link
Contributor

Feature

def a(d):
    locals()['d'] = 3
    b = 3 + d
    print(b)

a(21)

The code above generates the following error:
(locals dict share actual local variable)

Actual Result

Finished dev [unoptimized + debuginfo] target(s) in 0.11s
Running `target/debug/rustpython c.py`
6

Expected Result

24
@HyeockJinKim HyeockJinKim added the C-compat A discrepancy between RustPython and CPython label Sep 8, 2019
@HyeockJinKim
Copy link
Contributor Author

If this issue is valid, can I take it?

HyeockJinKim added a commit to HyeockJinKim/RustPython that referenced this issue Oct 10, 2019
Return copy of locals so that local variables
does not change even if locals() values is changed

Fixes RustPython#1356
HyeockJinKim added a commit to HyeockJinKim/RustPython that referenced this issue Oct 10, 2019
Return copy of locals so that local variables
does not change even if locals() values is changed

Fixes RustPython#1356
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-compat A discrepancy between RustPython and CPython
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant