python-shell-send-buffer fails on simple file #17

Closed
cschol opened this Issue Feb 23, 2011 · 5 comments

Projects

None yet

2 participants

@cschol
cschol commented Feb 23, 2011

In commit 6e46a01 sending simple files to the shell seems to be broken.

print "Hello World!"

works fine.

def foo():
    print "Hello World!"

fails, as does

class Foo():
    def __init__(self):
        print "Hello World!"

The error is always something like:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "d:/devel/python/test.py", line 1
    def foo():
              ^
  SyntaxError: invalid syntax
  >>> 

pointing to the end of the first line.

@fgallina
Owner

Hi cschol,

That's Probably because you are running a python 3 interpreter instead of python 2 and in python 3 print is not a statement anymore, it is a function.

Perphaps an update of your system made the change without having you noticing the version replacement. What I'd recommend you is to try with print("Hello world!") or to check if you can run python 2x code with an interpreter named python2, python2.7 or similar (that's the way it is on Arch GNU/Linux)

Feel free to reopen this ticket what I say below is not the case.

@cschol
cschol commented Feb 23, 2011

Hi Fabian,

No. I am running Python 2.6.5. It's not a problem with the print since it occurs always on the first line. In the last script I tried, it failed on

import sys

with the same error.

I bet it has to do with me being on Windows. I assume you are not?

@cschol
cschol commented Feb 23, 2011

Update: This only seems to be a problem on my Windows 7 machine. On my XP machine it works fine. I will try to troubleshoot this tonight.

Christoph

@cschol
cschol commented Feb 24, 2011

Update: I looks like emacs was using the Python interpreter from cygwin, which fails with the above error. Forcing it to use the native Windows version (which I use on my XP machine) works fine. I will check in the cygwin thing when I have some more time.

Christoph

@fgallina
Owner
fgallina commented Mar 4, 2011

cschol can you confirm if the Python interpreter from cygwin uses forward or backward slashes in the filenames? that should help me understand what's wrong with it.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment