Skip to content

code.co_names leaks a __doc__ entry #4505

@DimitrisJim

Description

@DimitrisJim

when it shouldn't.

I was able to repro this in cases where a nested function is defined, i.e:

def foo():
    def inner():
        pass

In RustPython:

>>>>> foo.__code__.co_names
('__doc__',)

while in Python:

>>> foo.__code__.co_names
()

and also when compiling a module from a source string:

stmts = """
import blah
 
def foo():
    pass
"""
code = compile(stmts, "<test>", "exec")

In RustPython:

>>>>> code.co_names
('blah', '__doc__', 'foo')

while in Python:

>>> code.co_names
('blah', 'foo')

not entirely sure how easy the fix might be.

Metadata

Metadata

Labels

C-bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions