- Notifications
You must be signed in to change notification settings - Fork1.4k
Proper construction of scope for exec/eval.#590
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
codecov-io commentedMar 3, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Codecov Report
@@ Coverage Diff @@## master #590 +/- ##==========================================+ Coverage 41.61% 43.75% +2.14%========================================== Files 74 74 Lines 16762 17228 +466 Branches 4406 4671 +265 ==========================================+ Hits 6975 7538 +563+ Misses 7781 7594 -187- Partials 2006 2096 +90
Continue to review full report at Codecov.
|
adrian17 commentedMar 3, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Looks like CPython doesn't do "automatic" dict type checking there, and just allows any type, then checks for None, then manually typechecks for dict. |
cthulahoops commentedMar 3, 2019
In that case I've added a macro to do the extra checking. This leads me to run into the limitations of our definitions of scope. We consider local scope to be the nearest scope to us so top level statements execute with local and global scope being the same thing. In python though this means there is no local scope, creating one doesn't replace the current local==global scope. This should work, but doesn't: We'll need to sort this out to implement the |
cthulahoops commentedMar 3, 2019
Uh... the above is wrong. It looks like creating a new local scope never replaces the existing local scope. (Ie. that code still works even in a function.) This is all wrong. :( |
cthulahoops commentedMar 3, 2019
I was right the first time! :) |
cthulahoops commentedMar 3, 2019
Interesting example: |
Uh oh!
There was an error while loading.Please reload this page.
| locals:Option<&PyObjectRef>, | ||
| ) ->ScopeRef{ | ||
| let current_scope = vm.current_scope(); | ||
| let parent =match globals{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Check here if globals is passed at all, None or an actual dictionary.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
One case I couldn't handle is that the following is valid in CPython.
arg_check!needs to allow None and treat it as if the optional argument wasn't passed. I don't know what other builtins have this behaviour.