Windows Python 2.4: Unbuffered flag causes SyntaxError on interactive sessions?

Discussion in 'Python' started by Lonnie Princehouse, Sep 13, 2005.

  1. >From the cmd shell on both Windows 2k and XP, I'm getting this weird
    syntax error in conjunction with the unbuffered flag. It works fine
    without -u. Has anyone else encountered it? This didn't happen with
    Python 2.2...

    C:\>python -u
    Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)]
    on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> print 'hello'

    File "<stdin>", line 1
    print 'hello'
    ^
    SyntaxError: invalid syntax


    (sorry if this is a known/fixed bug... I couldn't find anything about
    it)
     
    Lonnie Princehouse, Sep 13, 2005
    #1
    1. Advertising

  2. Re: Windows Python 2.4: Unbuffered flag causes SyntaxError on interactivesessions?

    Lonnie Princehouse wrote:
    > C:\>python -u
    > Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)]
    > on win32
    > Type "help", "copyright", "credits" or "license" for more information.
    >
    >>>>print 'hello'

    >
    > File "<stdin>", line 1
    > print 'hello'
    > ^
    > SyntaxError: invalid syntax


    Worksforme:

    C:\Python24>python.exe -u
    Python 2.4.1 (#65, May 24 2005, 13:43:04) [MSC v.1310 32 bit (Intel)] on
    win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> print 'hello'

    hello

    Strange that your python build is from 30 March and mine is from 24 May.
    --
    Michael Hoffman
     
    Michael Hoffman, Sep 13, 2005
    #2
    1. Advertising

  3. Re: Windows Python 2.4: Unbuffered flag causes SyntaxError on interactivesessions?

    Michael Hoffman wrote:
    > Lonnie Princehouse wrote:
    >
    >> C:\>python -u
    >> Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)]
    >> on win32
    >> Type "help", "copyright", "credits" or "license" for more information.
    >>
    >>>>> print 'hello'

    >>
    >>
    >> File "<stdin>", line 1
    >> print 'hello'
    >> ^
    >> SyntaxError: invalid syntax

    >
    >
    > Worksforme:
    >
    > C:\Python24>python.exe -u
    > Python 2.4.1 (#65, May 24 2005, 13:43:04) [MSC v.1310 32 bit (Intel)] on
    > win32
    > Type "help", "copyright", "credits" or "license" for more information.
    > >>> print 'hello'

    > hello
    >
    > Strange that your python build is from 30 March and mine is from 24 May.



    Problem also occurs on my machine using Win XP Home,
    Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32


    even just typing "print" at the interactive prompt causes a syntax error...

    --Irmen
     
    Irmen de Jong, Sep 13, 2005
    #3
  4. Weird. Did you build Python yourself? The 2.4.1 release on python.org
    is from March 30.
    I just tried ActiveState's 2.4.1... the same thing happens.
     
    Lonnie Princehouse, Sep 13, 2005
    #4
  5. Re: Windows Python 2.4: Unbuffered flag causes SyntaxError on interactivesessions?

    Lonnie Princehouse wrote:
    > Weird. Did you build Python yourself?


    No.
    --
    Michael Hoffman
     
    Michael Hoffman, Sep 13, 2005
    #5
  6. Lonnie Princehouse

    Terry Reedy Guest

    Re: Windows Python 2.4: Unbuffered flag causes SyntaxErroroninteractive sessions?

    "Lonnie Princehouse" <> wrote in message
    news:...
    > Weird. Did you build Python yourself? The 2.4.1 release on python.org
    > is from March 30.
    > I just tried ActiveState's 2.4.1... the same thing happens.


    Please report this on the SourceForge bug list, including the details of
    the two releases and de Jong's confirmation (and even Hoffman's
    non-confirmation). The 2.4.2 release process starts soon and it would be
    nice to have this fixed.

    Terry J. Reedy
     
    Terry Reedy, Sep 14, 2005
    #6
  7. Re: Windows Python 2.4: Unbuffered flag causes SyntaxError oninteractive sessions?

    Will do
     
    Lonnie Princehouse, Sep 14, 2005
    #7
  8. Re: Windows Python 2.4: Unbuffered flag causes SyntaxError on interactivesessions?

    Irmen de Jong wrote:
    > Michael Hoffman wrote:
    >> Lonnie Princehouse wrote:
    >>
    >>> C:\>python -u
    >>> Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)]
    >>> on win32
    >>> Type "help", "copyright", "credits" or "license" for more information.
    >>>
    >>>>>> print 'hello'
    >>>
    >>>
    >>> File "<stdin>", line 1
    >>> print 'hello'
    >>> ^
    >>> SyntaxError: invalid syntax

    >>
    >>
    >> Worksforme:
    >>
    >> C:\Python24>python.exe -u
    >> Python 2.4.1 (#65, May 24 2005, 13:43:04) [MSC v.1310 32 bit (Intel)] on
    >> win32
    >> Type "help", "copyright", "credits" or "license" for more information.
    >> >>> print 'hello'

    >> hello
    >>
    >> Strange that your python build is from 30 March and mine is from 24 May.

    >
    >
    > Problem also occurs on my machine using Win XP Home,
    > Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32
    >
    >
    > even just typing "print" at the interactive prompt causes a syntax error...


    It __may__ be that this is caused by an error in the codecs machinery which is already
    fixed in 2.4 CVS. Could you try this out?

    Reinhold
     
    Reinhold Birkenfeld, Sep 14, 2005
    #8
  9. Re: Windows Python 2.4: Unbuffered flag causes SyntaxError oninteractive sessions?

    After doing some more reading, I now think this isn't a bug.

    Evidently the unbuffered flag not only makes stdin unbuffered, but it
    also forces it into binary mode. I didn't realize that when I posted
    earlier.

    So the SyntaxErrors arise because the interpreter isn't converting \r\n
    into \n because stdin is binary. Not a bug, although it would be nice
    to have an "unbuffered text mode" flag too...

    D'oh.
     
    Lonnie Princehouse, Sep 14, 2005
    #9
  10. Re: Windows Python 2.4: Unbuffered flag causes SyntaxError oninteractivesessions?

    Lonnie Princehouse wrote:

    > Evidently the unbuffered flag not only makes stdin unbuffered, but it
    > also forces it into binary mode. I didn't realize that when I posted
    > earlier.
    >
    > So the SyntaxErrors arise because the interpreter isn't converting \r\n
    > into \n because stdin is binary. Not a bug, although it would be nice
    > to have an "unbuffered text mode" flag too...


    so if you do this:

    >>> z = raw_input()

    zzz

    Does z contain 'zzz\r'?

    For me, it just contains 'zzz'.
    --
    Michael Hoffman
     
    Michael Hoffman, Sep 14, 2005
    #10
  11. Re: Windows Python 2.4: Unbuffered flag causes SyntaxError oninteractive sessions?

    Yes. With the unbuffered flag, raw_input() strings on my box end in
    \r.
     
    Lonnie Princehouse, Sep 14, 2005
    #11
  12. Lonnie Princehouse

    Steve Holden Guest

    Re: Windows Python 2.4: Unbuffered flag causes SyntaxErroroninteractive sessions?

    Lonnie Princehouse wrote:
    > After doing some more reading, I now think this isn't a bug.
    >
    > Evidently the unbuffered flag not only makes stdin unbuffered, but it
    > also forces it into binary mode. I didn't realize that when I posted
    > earlier.
    >
    > So the SyntaxErrors arise because the interpreter isn't converting \r\n
    > into \n because stdin is binary. Not a bug, although it would be nice
    > to have an "unbuffered text mode" flag too...
    >
    > D'oh.
    >

    It seems a little bizarre to me that the compiler isn't prepared to
    treat carriage returns as whitespace during its tokenizations. The only
    area I would anticipate problems would be string literals containing
    end-of-line sequences embedded within triple-quotes.

    It would seem to make sense to program the compiler defensively to
    ignore embedded "\r" characters.

    regards
    Steve
    --
    Steve Holden +44 150 684 7255 +1 800 494 3119
    Holden Web LLC http://www.holdenweb.com/
     
    Steve Holden, Sep 15, 2005
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Xavier Osa
    Replies:
    0
    Views:
    667
    Xavier Osa
    Jan 9, 2004
  2. WJ
    Replies:
    2
    Views:
    544
  3. Python Newsgroup

    SyntaxError: invalid syntax (windows)

    Python Newsgroup, Mar 25, 2009, in forum: Python
    Replies:
    6
    Views:
    1,274
    Terry Reedy
    Mar 25, 2009
  4. Wes McKinney
    Replies:
    3
    Views:
    934
    Irmen de Jong
    Sep 17, 2009
  5. John Call
    Replies:
    1
    Views:
    91
Loading...

Share This Page