473,471 Members | 1,729 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

Sep 13 '05 #1
11 3224
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
Sep 13 '05 #2
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
Sep 13 '05 #3
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.

Sep 13 '05 #4
Lonnie Princehouse wrote:
Weird. Did you build Python yourself?


No.
--
Michael Hoffman
Sep 13 '05 #5

"Lonnie Princehouse" <fi**************@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
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

Sep 13 '05 #6
Will do

Sep 14 '05 #7
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
Sep 14 '05 #8
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.

Sep 14 '05 #9
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
Sep 14 '05 #10
Yes. With the unbuffered flag, raw_input() strings on my box end in
\r.

Sep 14 '05 #11
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/

Sep 15 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
2
by: leroybt.rm | last post by:
I don't understand why this does not work: <FILE1> test1.py #Import Packages import string # data=0 data=data+1
17
by: Paul Rubin | last post by:
Dumb question from a Windows ignoramus: I find myself needing to write a Python app (call it myapp.py) that uses tkinter, which as it happens has to be used under (ugh) Windows. That's Windows...
1
by: JDF | last post by:
I am fairly new to python and seem to have gotten ahead of myself. I am trying to write a Windows service that will return the current number of Citrix sessions to a client. This service will run...
3
by: Steven Fox | last post by:
============================================================ About DB2 Administration Tools Environment ============================================================ DB2 administration tools level:...
7
by: Mullin Yu | last post by:
if i put the same code at the windows application or console, i can logon to the computer. but, if i put the same code at the windows service and start it, i still can't logon to the machine. ...
118
by: 63q2o4i02 | last post by:
Hi, I've been thinking about Python vs. Lisp. I've been learning Python the past few months and like it very much. A few years ago I had an AI class where we had to use Lisp, and I absolutely...
1
by: Cameron Walsh | last post by:
Hi all, Using a python cgi script such as the one below to handle uploaded binary files will end up with a truncated file (truncates when it hits ^Z) on Windows systems. On linux systems the...
1
by: Tim Rowe | last post by:
I have Python 2.5 working just fine on my system. I've tried downloading and installing the MS Windows Python extensions, but can't get pythonw.exe (that's the windows executable, right?) to do...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.