-
Notifications
You must be signed in to change notification settings - Fork 225
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
Fix python block chunking #838
Conversation
Although the test is disabled because it seems impossible to test given how the current python evaluator works.
@linas I let it to you to review and possibly merge. |
I suggest to merge it. If something is wrong I should be able to fix today. |
OK, well, additional fixes are needed: at this time, starting the cogserver, telnetting to port 17001, and entering the python shell there produces no output, either at the shell, or at the cogserver, for this:
Before your change, the above worked. I am not sure that anyone is acutally using the python shell for anything at this time, so maybe fixing this is low-priority. |
" y = x + 1\n" | ||
"\n" | ||
" return y\n" | ||
"\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not valid python. When I run this by hand, in python, I get an error:
>>> def fun(x):
... y = x + 1
...
>>> return y
File "<stdin>", line 1
return y
^
IndentationError: unexpected indent
>>>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, if I copy the above into a file, and run it from a file i.e. python f.py
then it runs without any errors. So it seems that python is inconsistent with itself, as to what it accepts as valid syntax.
Contents of f.py:
def fun(x):
y = x + 1
print "foo", y
return y
fun(1)
print "bar"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, since opencog python interpreter is supposed to work in non-interactive/script mode as well (as is the case now) we want to support newlines within blocks.
Partially revert commit 8dda9e4 so that code blocks with newlines in the middle don't get split.