[New-bugs-announce] [issue21946] 'python -u' yields trailing carriage return '\r' (Python2 for Windows)

Matthias St.Pierre report at bugs.python.org
Wed Jul 9 14:51:58 CEST 2014


New submission from Matthias St.Pierre:

raw_input yields trailing carriage return ('\r') when C:\Python27\python.exe is called using the -u option

How to reproduce the error: save the attached file 'input.py' which contains the following lines

-- begin input.py --

i = raw_input("enter y or n: ")
print(repr(i))
print([ord(c) for c in i])

-- end input.py --

then run the two following commands from a windows command shell
	python input.py
	python -u input.py
and compare the output. (see transcript 1 below)

The same bug affects also the interactive mode: start 'python -u' and enter an arbitrary command. You will get a syntax error at the end of line. (see transcript 2 below)


-- begin transcript 1 of cmd session --

C:\Temp>where python
C:\Python27\python.exe

C:\Temp>python --version
Python 2.7.8

C:\Temp>type input.py

i = raw_input("enter y or n: ")
print(repr(i))
print([ord(c) for c in i])

C:\Temp>python input.py
enter y or n: y
'y'
[121]
-- end transcript 1 of cmd session --


-- begin transcript 2 of cmd session --

C:\Temp>python -u input.py
enter y or n: y
'y\r'
[121, 13]

C:\Temp>python -u
Python 2.7.8 (default, Jun 30 2014, 16:08:48) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print "hello world"
  File "<stdin>", line 1
    print "hello world"
                       ^
SyntaxError: invalid syntax
>>>

-- end transcript 2 of cmd session --

----------
components: Interpreter Core, Windows
files: input.py
messages: 222613
nosy: msp
priority: normal
severity: normal
status: open
title: 'python -u' yields trailing carriage return '\r'  (Python2 for Windows)
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file35913/input.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21946>
_______________________________________


More information about the New-bugs-announce mailing list