IronLanguages / main

Work for this repo has moved to https://github.com/IronLanguages/ironpython2
1.16k stars 347 forks source link

Ctl-Z doesn't throw EOF error in raw_input() #454

Open ironpythonbot opened 9 years ago

ironpythonbot commented 9 years ago

Ctl-Z throws an EOFError in raw_input under CPython but simply returns the empty string under IronPython. Error occurs with both 2.0.1 and 2.6 A1

CPython:
Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

raw_input()
^Z
Traceback (most recent call last):
File "", line 1, in
EOFError

IronPython:
IronPython 2.6 Alpha 1 (2.6.0.1) on .NET 2.0.50727.4918
Type "help", "copyright", "credits" or "license" for more information.
raw_input()
^Z
''

Work Item Details

Original CodePlex Issue: Issue 22140 Status: Active Reason Closed: Unassigned Assigned to: Unassigned Reported on: Apr 22, 2009 at 12:27 AM Reported by: harrypierson Updated on: Feb 22, 2013 at 2:13 AM Updated by: jdhardy

ironpythonbot commented 9 years ago

On 2010-02-05 00:18:41 UTC, jdhardy commented:

This breaks the code module, which expects EOFError to terminate its interact loop.

ironpythonbot commented 9 years ago

On 2012-02-11 01:12:53 UTC, slide_o_mix commented:

The issue is in PythonFile::ReadLine

// Read characters up to and including a '\r\n', converted to '\n' (or until EOF or the given size, in // which case the string will not be newline terminated). public override String ReadLine(int size) { StringBuilder sb = null; // start off w/ some text if (_bufPos >= _bufLen) ReadBuffer(); if (_bufLen == 0) return String.Empty;

That last item should probably be:

if(_bufLen == 0) throw PythonOps.EofError(string.Empty);