Skip to content

Add co_nlocals to code object #4546

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
DimitrisJim opened this issue Feb 22, 2023 · 0 comments · Fixed by #4553
Closed

Add co_nlocals to code object #4546

DimitrisJim opened this issue Feb 22, 2023 · 0 comments · Fixed by #4553
Labels

Comments

@DimitrisJim
Copy link
Member

Opening this separately from #1838 since it also seems like a good first issue.

Currently, code objects are missing the co_freevars attribute:

def foo(a, b, c): pass

In RustPython:

>>>>> foo.__code__.co_nlocals
AttributeError: 'code' object has no attribute 'co_nlocals'

While in Python:

>>> foo.__code__.co_nlocals
3

looking at the other methods on PyCode should help, the implementation should be similar to others there.

As the linked issue states, this does indeed appear to be len(self.varnames) (see this invariant in the CPython source)

@DimitrisJim DimitrisJim added the good first issue Good for newcomers label Feb 22, 2023
howjmay added a commit to howjmay/RustPython that referenced this issue Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants