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: probable bug in code.py with Python 3.0a2
Type: Stage:
Components: Library (Lib) Versions: Python 3.0
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: aroberge, gvanrossum
Priority: normal Keywords:

Created on 2007-12-29 04:10 by aroberge, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg59030 - (view) Author: Andre Roberge (aroberge) * Date: 2007-12-29 04:10
There appears to be a bug in code.py in Python 3.0a2/a1.

I believe that the body of
InteractiveConsole().raw_input()
should be changed from

       sys.stdout.write(prompt)
       sys.stdout.flush()
       return sys.stdin.readline()

to
      return input(prompt)

Here's a sample session.

Python 3.0a1 (py3k, Nov 27 2007, 07:40:26)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import code
>>> console = code.InteractiveConsole()
>>> console.interact()
Python 3.0a1 (py3k, Nov 27 2007, 07:40:26)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> for i in range(3):
...   print(i)
0
1
2
>>>  # Notice how I could only enter one line inside the loop.
>>>  # Let's try again, with a different definition of raw_input()
>>> import code
>>> console = code.InteractiveConsole()
>>> console.raw_input = input
>>> console.interact()
Python 3.0a1 (py3k, Nov 27 2007, 07:40:26)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> for i in range(3):
...   print(i)
...
0
1
2
>>>  # Notice how I had to enter an empty line to end the loop - as it
should be.

The same problem affects function definitions - it is impossible to
define a function body with more than one line when running code.interact()
msg59082 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2008-01-02 02:55
Good catch!
Committed revision 59659.
I wonder how many other places have the same problem...
msg59083 - (view) Author: Andre Roberge (aroberge) * Date: 2008-01-02 03:24
I did a quick search on the *.py files in the distribution.  I only
found two questionable places.

1. site.py has "raw_input" (python 2.5, line 311) replaced by the more
complicated 3 lines (python 3.0a2, lines 313-315) rather than the
simpler one-liner replacement.  However, I do not see any reason why
this could cause problems.

2. pydoc.py: raw_input is still present in 3.0a2 on line 1711; it should
be replaced by input imo.
msg59085 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2008-01-02 03:54
site.py is already fixed in svn; it actually did cause problems, see
issue #1667.

I fixed pydoc.py.
Committed revision 59660.
History
Date User Action Args
2022-04-11 14:56:29adminsetgithub: 46048
2008-01-02 03:54:02gvanrossumsetmessages: + msg59085
2008-01-02 03:24:03arobergesetmessages: + msg59083
2008-01-02 02:55:56gvanrossumsetstatus: open -> closed
resolution: fixed
messages: + msg59082
nosy: + gvanrossum
2007-12-29 04:10:25arobergecreate