Skip to content
This repository has been archived by the owner on Mar 20, 2021. It is now read-only.

with block: frame.f_local is read-only #1

Open
ep12 opened this issue Mar 27, 2020 · 2 comments
Open

with block: frame.f_local is read-only #1

ep12 opened this issue Mar 27, 2020 · 2 comments
Labels
help wanted Extra attention is needed more tests needed A feature can only be considered stable if there are lots of different tests

Comments

@ep12
Copy link
Owner

ep12 commented Mar 27, 2020

Describe the bug
Currently only global variables can be assigned new values. (status quo: see comments below)

To Reproduce

from pyopm.core import ObjectPattern
def myfunc():
    x = 5
    p = ObjectPattern({'obj': {'bind': {'x': None}}})
    m = p.match(dict())
    with m:
        print(x)

myfunc()

will print 5, because the locals cannot be updated (__enter__ -> _start_block).

Expected behavior
myfunc() should result in {} being printed.

Screenshots
None

Additional context
python 3.8.2

@ep12 ep12 added bug Something isn't working help wanted Extra attention is needed labels Mar 27, 2020
ep12 added a commit that referenced this issue Mar 28, 2020
ep12 added a commit that referenced this issue Mar 28, 2020
@ep12
Copy link
Owner Author

ep12 commented Mar 28, 2020

9cb5311 partially resolves this issue:

  • locals can now be created and updated from pyopm.core._start_block and pyopm.core._end_block
  • locals can not be deleted with cpython. It seems to work when using pypy.
    A fix for this would be a nice-to-have, however the main functionality to bind the matched values seems to work. A source of inspiration might be pdb, because pdb can delete locals using both cpython and pypy (but how?).

@ep12 ep12 removed the bug Something isn't working label Mar 28, 2020
@ep12
Copy link
Owner Author

ep12 commented Apr 12, 2020

2b2f142 adds support for variables that are used with *_DEREF and *_CLOSURE access modes.
More testing is needed: Maybe the implementation is not stable, maybe one or two branches are unnecessary (this and this branch?)

@ep12 ep12 added the more tests needed A feature can only be considered stable if there are lots of different tests label Apr 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Extra attention is needed more tests needed A feature can only be considered stable if there are lots of different tests
Projects
None yet
Development

No branches or pull requests

1 participant