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

Class closures does not work #430

Open
kai3341 opened this issue Dec 20, 2022 · 0 comments · May be fixed by #431
Open

Class closures does not work #430

kai3341 opened this issue Dec 20, 2022 · 0 comments · May be fixed by #431

Comments

@kai3341
Copy link

kai3341 commented Dec 20, 2022

Python Version

3.9.0

Package Version

2.6.0

Description

Trying to patch Foo.__init__ in this case:

class Foo:
    ANY_VALUE = 42
    def __init__(self, any_value=ANY_VALUE): pass

Would cause an error:

Traceback (most recent call last):
  ...
  File "/home/kai/Projects/.../venv/lib/python3.9/site-packages/patchy/api.py", line 33, in patch
    _do_patch(func, patch_text, forwards=True)
  File "/home/kai/Projects/.../venv/lib/python3.9/site-packages/patchy/api.py", line 100, in _do_patch
    _set_source(func, new_source)
  File "/home/kai/Projects/.../venv/lib/python3.9/site-packages/patchy/api.py", line 321, in _set_source
    new_func = localz["__patchy_freevars__"]()
  File "<patchy>", line 4, in __patchy_freevars__
  File "<patchy>", line 6, in Client
NameError: name 'ANY_VALUE' is not defined
@kai3341 kai3341 linked a pull request Dec 20, 2022 that will close this issue
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 a pull request may close this issue.

1 participant