New submission from Andre Roberge:

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

----------
components: Library (Lib)
messages: 59030
nosy: aroberge
severity: normal
status: open
title: probable bug in code.py with Python 3.0a2
versions: Python 3.0

__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1707>
__________________________________
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to