main icon indicating copy to clipboard operation
main copied to clipboard

input() throws SyntaxError

Open ironpythonbot opened this issue 10 years ago • 0 comments

Input() throws an EOFError when stdin is StringIO() in CPython2.5, but IronPython throws a SyntaxError. like below code:
import sys
import cStringIO
sys.stdin = cStringIO.StringIO()
input()

CPython result :"Traceback (most recent call last):
File "C:\Documents and Settings\v-juwa\Desktop\test_input.py", line 5, in
input()
EOFError: EOF when reading a line"

IronPython result: "  File "", line 1
^
SyntaxError: invalid syntax"

And input() throws RuntimeError when delete stdin or stdout module in CPython2.5, IronPython throws a SyntaxError. like below code:
del sys.stdout
input('Prompt')

Cpython result:"Traceback (most recent call last):
File "C:\Documents and Settings\v-juwa\Desktop\getattr.py", line 3, in
input('Prompt')
RuntimeError: [raw_]input: lost sys.stdout"

IronPython result:"Prompt
File "", line 1
^
SyntaxError: invalid syntax"

import sys
import cStringIO
sys.stdin = cStringIO.StringIO()
input()

del sys.stdout
input('Prompt')

del sys.stdin
input('Prompt')

Work Item Details

Original CodePlex Issue: Issue 23728 Status: Active Reason Closed: Unassigned Assigned to: Unassigned Reported on: Jul 27, 2009 at 11:44 PM Reported by: dfugate Updated on: Feb 22, 2013 at 2:12 AM Updated by: jdhardy Custom value: Reported internally at Microsoft. Test: test_builtin.py CreatedDate: 9/13/2007 NewInternalID: 409520 OldInternalID: 302176 AreaPath: IronPython\Python25

ironpythonbot avatar Dec 09 '14 17:12 ironpythonbot