This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: license() does not process keyboard input correctly
Type: behavior Stage:
Components: Documentation Versions: Python 3.0
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: JosephArmbruster, gvanrossum, python-dev
Priority: normal Keywords:

Created on 2007-12-20 05:36 by JosephArmbruster, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
licensepatch.patch JosephArmbruster, 2007-12-20 05:36
Messages (12)
msg58857 - (view) Author: Joseph Armbruster (JosephArmbruster) Date: 2007-12-20 05:36
url: http://svn.python.org/projects/python/branches/py3k
rev: 59577

The license() function does not appear to process keyboard input
correctly.  Symptoms:
- Carriage returns do not move license pages downwards
- q option did not quit

Patch to site.py attached.
msg58898 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-12-20 16:10
I think you misunderstand raw_input().  It just returns
sys.stdin.readline().rstrip("\n").  I don't think it's worth fixing. 
The 'q' processing works fine as long as you didn't type \r first. :-)
msg58899 - (view) Author: Joseph Armbruster (JosephArmbruster) Date: 2007-12-20 16:18
Here are two examples of why I created this issue:

example 1: that is the output I received when pressing Return 5 times
using license()

python
Python 3.0a2 (py3k:59579M, Dec 20 2007, 08:46:46) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> license()
A. HISTORY OF THE SOFTWARE
==========================

Python was created in the early 1990s by Guido van Rossum at Stichting
Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands
as a successor of a language called ABC.  Guido remains Python's
principal author, although it includes many contributions from others.

In 1995, Guido continued his work on Python at the Corporation for
National Research Initiatives (CNRI, see http://www.cnri.reston.va.us)
in Reston, Virginia where he released several versions of the
software.

In May 2000, Guido and the Python core development team moved to
BeOpen.com to form the BeOpen PythonLabs team.  In October of the same
year, the PythonLabs team moved to Digital Creations (now Zope
Corporation, see http://www.zope.com).  In 2001, the Python Software
Foundation (PSF, see http://www.python.org/psf/) was formed, a
non-profit organization created specifically to own Python-related
Intellectual Property.  Zope Corporation is a sponsoring member of
the PSF.

All Python releases are Open Source (see http://www.opensource.org for
Hit Return for more, or q (and Return) to quit:
Hit Return for more, or q (and Return) to quit:
Hit Return for more, or q (and Return) to quit:
Hit Return for more, or q (and Return) to quit:
Hit Return for more, or q (and Return) to quit:


example 2: this is the output i received when pressing return two times,
q then return two times

D:\work\py3ktrunk\PCbuild9>python
Python 3.0a2 (py3k:59579M, Dec 20 2007, 08:46:46) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> license()
A. HISTORY OF THE SOFTWARE
==========================

Python was created in the early 1990s by Guido van Rossum at Stichting
Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands
as a successor of a language called ABC.  Guido remains Python's
principal author, although it includes many contributions from others.

In 1995, Guido continued his work on Python at the Corporation for
National Research Initiatives (CNRI, see http://www.cnri.reston.va.us)
in Reston, Virginia where he released several versions of the
software.

In May 2000, Guido and the Python core development team moved to
BeOpen.com to form the BeOpen PythonLabs team.  In October of the same
year, the PythonLabs team moved to Digital Creations (now Zope
Corporation, see http://www.zope.com).  In 2001, the Python Software
Foundation (PSF, see http://www.python.org/psf/) was formed, a
non-profit organization created specifically to own Python-related
Intellectual Property.  Zope Corporation is a sponsoring member of
the PSF.

All Python releases are Open Source (see http://www.opensource.org for
Hit Return for more, or q (and Return) to quit:
Hit Return for more, or q (and Return) to quit:
Hit Return for more, or q (and Return) to quit: q
Hit Return for more, or q (and Return) to quit:
Hit Return for more, or q (and Return) to quit:
msg58907 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-12-20 17:32
Very odd.  Can you experiment with input() and sys.stdin.readline() to
see what exactly gets returned? It seems that somehow the CRLF -> LF
translation isn't working, and that should be fixed somewhere else,
not in license().

I imagine you could just do this:

Hi: <hit Return here>
'\r'
>>>

It should return '' but I think you will see '\r'. I'd like to see
someone else with access to Windows confirm this though.
msg58909 - (view) Author: Joseph Armbruster (JosephArmbruster) Date: 2007-12-20 18:11
Here's the results, i'll look into it briefly.

>>> import sys
>>> x = input()
Hi:
>>> len(x)
3
>>> x = sys.stdin.readline()
Hi:
>>> len(x)
4
msg58910 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-12-20 18:15
> >>> len(x)

Please print repr(x). That should be safe even if it contains control
characters.
msg58911 - (view) Author: Joseph Armbruster (JosephArmbruster) Date: 2007-12-20 18:17
>>> import sys
>>> x = input()
Hi:
>>> repr(x)
"'Hi:'"
>>> x = sys.stdin.readline()
Hi:
>>> repr(x)
"'Hi:\\n'"
msg58912 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-12-20 18:23
> >>> import sys
> >>> x = input()
> Hi:
> >>> repr(x)
> "'Hi:'"
> >>> x = sys.stdin.readline()
> Hi:
> >>> repr(x)
> "'Hi:\\n'"

Hm, that works as expected (except I meant "Hi:" to be the prompt, but
that's okay :-). Why doesn't it inside license()? Can you put a "print
repr(key)" in the site.py code right after the input() call?
msg58913 - (view) Author: Joseph Armbruster (JosephArmbruster) Date: 2007-12-20 18:28
Ok, just did as so:

sys.stdout.write(prompt)
sys.stdout.flush()
key = sys.stdin.readline()
print(repr(key))
print(len(key))
if key not in ('', 'q'):

Results:

All Python releases are Open Source (see http://www.opensource.org for
Hit Return for more, or q (and Return) to quit:
'\n'
1
Hit Return for more, or q (and Return) to quit: q
'q\n'
2
msg58916 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-12-20 18:43
Ah d'oh!

The 3.0 code was wrong.  I've fixed it now in SVN by going back to input()

Committed revision 59583.
msg58917 - (view) Author: Joseph Armbruster (JosephArmbruster) Date: 2007-12-20 18:47
Looks good :-)

Python 3.0a2 (py3k:59579M, Dec 20 2007, 08:46:46) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> license()
A. HISTORY OF THE SOFTWARE
==========================

Python was created in the early 1990s by Guido van Rossum at Stichting
Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands
as a successor of a language called ABC.  Guido remains Python's
principal author, although it includes many contributions from others.

In 1995, Guido continued his work on Python at the Corporation for
National Research Initiatives (CNRI, see http://www.cnri.reston.va.us)
in Reston, Virginia where he released several versions of the
software.

In May 2000, Guido and the Python core development team moved to
BeOpen.com to form the BeOpen PythonLabs team.  In October of the same
year, the PythonLabs team moved to Digital Creations (now Zope
Corporation, see http://www.zope.com).  In 2001, the Python Software
Foundation (PSF, see http://www.python.org/psf/) was formed, a
non-profit organization created specifically to own Python-related
Intellectual Property.  Zope Corporation is a sponsoring member of
the PSF.

All Python releases are Open Source (see http://www.opensource.org for
Hit Return for more, or q (and Return) to quit:
the Open Source Definition).  Historically, most, but not all, Python
releases have also been GPL-compatible; the table below summarizes
the various releases.

    Release         Derived     Year        Owner       GPL-
                    from                                compatible? (1)

    0.9.0 thru 1.2              1991-1995   CWI         yes
    1.3 thru 1.5.2  1.2         1995-1999   CNRI        yes
    1.6             1.5.2       2000        CNRI        no
    2.0             1.6         2000        BeOpen.com  no
    1.6.1           1.6         2001        CNRI        yes (2)
    2.1             2.0+1.6.1   2001        PSF         no
    2.0.1           2.0+1.6.1   2001        PSF         yes
    2.1.1           2.1+2.0.1   2001        PSF         yes
    2.2             2.1.1       2001        PSF         yes
    2.1.2           2.1.1       2002        PSF         yes
    2.1.3           2.1.2       2002        PSF         yes
    2.2.1           2.2         2002        PSF         yes
    2.2.2           2.2.1       2002        PSF         yes
    2.2.3           2.2.2       2003        PSF         yes
    2.3             2.2.2       2002-2003   PSF         yes
    2.3.1           2.3         2002-2003   PSF         yes
Hit Return for more, or q (and Return) to quit: yay
Hit Return for more, or q (and Return) to quit: q
>>>
msg164591 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-07-03 11:05
New changeset 7ccc2cea6969 by Jesus Cea in branch '2.7':
Issue #1667: Unused variable warning in Non-Windows
http://hg.python.org/cpython/rev/7ccc2cea6969
History
Date User Action Args
2022-04-11 14:56:29adminsetgithub: 46008
2012-07-03 11:05:09python-devsetnosy: + python-dev
messages: + msg164591
2007-12-20 18:47:38JosephArmbrustersetmessages: + msg58917
2007-12-20 18:43:38gvanrossumsetmessages: + msg58916
2007-12-20 18:28:08JosephArmbrustersetmessages: + msg58913
2007-12-20 18:23:48gvanrossumsetmessages: + msg58912
2007-12-20 18:17:35JosephArmbrustersetmessages: + msg58911
2007-12-20 18:15:32gvanrossumsetmessages: + msg58910
2007-12-20 18:11:09JosephArmbrustersetmessages: + msg58909
2007-12-20 17:32:03gvanrossumsetmessages: + msg58907
2007-12-20 16:18:07JosephArmbrustersetmessages: + msg58899
2007-12-20 16:10:50gvanrossumsetstatus: open -> closed
resolution: wont fix
messages: + msg58898
nosy: + gvanrossum
2007-12-20 05:36:58JosephArmbrustercreate