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

Improve function handling and name resolution in local Python executor #695

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aremeis
Copy link

@aremeis aremeis commented Feb 18, 2025

The following tests for the local Python executor fail and IMHO they should not:

def test__name__():
    code = dedent("""\
        def foo(): return 0
        foo.__name__
        """)
    result, _ = evaluate_python_code(code, {}, {})
    assert result == "foo"

def test_function_returning_function():
    code = dedent("""\
        def f(): 
            return lambda x: x + 1
        f()(1)
        """)
    result, _ = evaluate_python_code(code, {}, {})
    assert result == 2

This PR fixes the issues by:

  • Setting __name__ attribute on functions
  • Generalising the resolution of function calls

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 this pull request may close these issues.

1 participant