473,508 Members | 2,384 Online
Bytes | Software Development & Data Engineering Community
+ 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 3227
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
18803
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
4929
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
3841
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
2215
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
2336
by: Steven Fox | last post by:
============================================================ About DB2 Administration Tools Environment ============================================================ DB2 administration tools level:...
7
8640
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
6582
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
1833
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
1764
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
7223
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
7377
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...
1
7036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7489
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
5624
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4705
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
414
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.