raw_input bug only in cygwin python
Tim Roberts
timr at probo.com
Fri Apr 19 01:34:43 EDT 2002
davidccarson at hotmail.com (David Carson) wrote:
>Here is a snippet of code:
>
>01: #!/usr/bin/env python
>02:
>03: list = []
>04: while 1:
>05: try:
>06: stuff = raw_input("[^D to exit]: ")
>07: except EOFError:
>08: print "got EOF"
>09: break
>10: list.append(stuff)
>11:
>12: raw_input("bang! ")
>
>
>This works on every Python environment I've tried but cygwin (Win2000
>-- I haven't got NT to try it):
> Python 2.2 (#1, Dec 31 2001, 15:21:18)
> [GCC 2.95.3-5 (cygwin special)] on cygwin
>
>In this environment, the EOFError is caught. Then the "bang! " prompt
>for the raw_input() outside the loop is printed, but immediately the
>program exits with an uncaught EOFError.
>
>This code works with:
>- ActiveState Python, 2.1 on Win2000
>- python 2.2 on Mandrake
>- python 1.5.2 on RedHat
>and everywhere else, I'm sure.
>
>Is this a known problem with cygwin?
I wouldn't call it a problem with cygwin, I'd call it "relying on
unspecified behavior". Ctrl-D is end of file; the ability to read past EOF
is not promised anywhere in the docs.
--
- Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list
mailing list