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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lonnie Princehouse

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

    >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.[color=blue][color=green][color=darkred]
    >>> print 'hello'[/color][/color][/color]
    File "<stdin>", line 1
    print 'hello'
    ^
    SyntaxError: invalid syntax


    (sorry if this is a known/fixed bug... I couldn't find anything about
    it)

  • Michael Hoffman

    #2
    Re: Windows Python 2.4: Unbuffered flag causes SyntaxError on interactivesess ions?

    Lonnie Princehouse wrote:[color=blue]
    > 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.
    >[color=green][color=darkred]
    >>>>print 'hello'[/color][/color]
    >
    > File "<stdin>", line 1
    > print 'hello'
    > ^
    > SyntaxError: invalid syntax[/color]

    Worksforme:

    C:\Python24>pyt hon.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.[color=blue][color=green][color=darkred]
    >>> print 'hello'[/color][/color][/color]
    hello

    Strange that your python build is from 30 March and mine is from 24 May.
    --
    Michael Hoffman

    Comment

    • Irmen de Jong

      #3
      Re: Windows Python 2.4: Unbuffered flag causes SyntaxError on interactivesess ions?

      Michael Hoffman wrote:[color=blue]
      > Lonnie Princehouse wrote:
      >[color=green]
      >> 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.
      >>[color=darkred]
      >>>>> print 'hello'[/color]
      >>
      >>
      >> File "<stdin>", line 1
      >> print 'hello'
      >> ^
      >> SyntaxError: invalid syntax[/color]
      >
      >
      > Worksforme:
      >
      > C:\Python24>pyt hon.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.[color=green][color=darkred]
      > >>> print 'hello'[/color][/color]
      > hello
      >
      > Strange that your python build is from 30 March and mine is from 24 May.[/color]


      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

      Comment

      • Lonnie Princehouse

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

        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.

        Comment

        • Michael Hoffman

          #5
          Re: Windows Python 2.4: Unbuffered flag causes SyntaxError on interactivesess ions?

          Lonnie Princehouse wrote:[color=blue]
          > Weird. Did you build Python yourself?[/color]

          No.
          --
          Michael Hoffman

          Comment

          • Terry Reedy

            #6
            Re: Windows Python 2.4: Unbuffered flag causes SyntaxErroronin teractive sessions?


            "Lonnie Princehouse" <finite.automat on@gmail.com> wrote in message
            news:1126644810 .073493.201700@ g43g2000cwa.goo glegroups.com.. .[color=blue]
            > 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.[/color]

            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



            Comment

            • Lonnie Princehouse

              #7
              Re: Windows Python 2.4: Unbuffered flag causes SyntaxError oninteractive sessions?

              Will do

              Comment

              • Reinhold Birkenfeld

                #8
                Re: Windows Python 2.4: Unbuffered flag causes SyntaxError on interactivesess ions?

                Irmen de Jong wrote:[color=blue]
                > Michael Hoffman wrote:[color=green]
                >> Lonnie Princehouse wrote:
                >>[color=darkred]
                >>> 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[/color]
                >>
                >>
                >> Worksforme:
                >>
                >> C:\Python24>pyt hon.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.[color=darkred]
                >> >>> print 'hello'[/color]
                >> hello
                >>
                >> Strange that your python build is from 30 March and mine is from 24 May.[/color]
                >
                >
                > 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...[/color]

                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

                Comment

                • Lonnie Princehouse

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

                  Comment

                  • Michael Hoffman

                    #10
                    Re: Windows Python 2.4: Unbuffered flag causes SyntaxError oninteractivese ssions?

                    Lonnie Princehouse wrote:
                    [color=blue]
                    > 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...[/color]

                    so if you do this:
                    [color=blue][color=green][color=darkred]
                    >>> z = raw_input()[/color][/color][/color]
                    zzz

                    Does z contain 'zzz\r'?

                    For me, it just contains 'zzz'.
                    --
                    Michael Hoffman

                    Comment

                    • Lonnie Princehouse

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

                      Comment

                      • Steve Holden

                        #12
                        Re: Windows Python 2.4: Unbuffered flag causes SyntaxErroronin teractive sessions?

                        Lonnie Princehouse wrote:[color=blue]
                        > 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.
                        >[/color]
                        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/

                        Comment

                        Working...