saulpw / aipl

Array-Inspired Pipeline Language
MIT License
119 stars 7 forks source link

`!python` #45

Closed dovinmu closed 1 year ago

dovinmu commented 1 year ago

!python no longer seems to be working on latest develop:

!python
print('hi')

adding a debug line in python.py:

def inner_exec(obj, *args, **kwargs):
    print('this', obj)
...

Just prints "this"

Dhru1001 commented 1 year ago

def inner_exec(obj, *args, **kwargs): print('this', obj) exec(obj, globals(), locals()) # Execute the provided Python code

code = ''' print('hi') ''' inner_exec(code)

anjakefala commented 1 year ago

Same with !literal. My current hypothesis is that the prompt argument stopped being passed into it since 4d531b7373c2e007548486b717b57a9741b6bd9e.

anjakefala commented 1 year ago

The bug is that when the arity is 0 (e.g. !python !literal) then we go directly into call_cmd, and do not pass in the operands.

The prompt is then lost, because the prompt is now carried in operands. It otherwise seems to be set correctly.

anjakefala commented 1 year ago

Execution of ops with arity 0: https://github.com/saulpw/aipl/blob/develop/aipl/interpreter.py#L209

Where the prompot gets set: https://github.com/saulpw/aipl/blob/develop/aipl/interpreter.py#L146