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

Fix python block chunking #838

Merged
merged 2 commits into from
Jul 27, 2016

Conversation

ngeiswei
Copy link
Member

Partially revert commit 8dda9e4 so that code blocks with newlines in the middle don't get split.

Although the test is disabled because it seems impossible to test
given how the current python evaluator works.
@ngeiswei
Copy link
Member Author

ngeiswei commented Jul 26, 2016

@linas I let it to you to review and possibly merge.

@ngeiswei
Copy link
Member Author

I suggest to merge it. If something is wrong I should be able to fix today.

@ngeiswei ngeiswei merged commit 2ebc237 into opencog:master Jul 27, 2016
@ngeiswei ngeiswei deleted the fix-python-block-chunking branch July 27, 2016 07:18
@linas
Copy link
Member

linas commented Jul 27, 2016

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:

for i in range(10) :
    print "foo", i

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"
Copy link
Member

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
>>> 

Copy link
Member

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"

Copy link
Member Author

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.

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.

None yet

2 participants