New submission from Avihu Turzion <av...@turzion.com>:

When I have the following code:

blah.py
=======

import getpass
nothing = getpass.getpass("blah:")

And I run it like so:

>>> sleep 5
./blah.py <return>
<return>

(I write the ./blah.py and returns while the sleep occurs)

I get the following stack-trace:

Traceback (most recent call last):
  File "./xuy.py", line 5, in <module>
    nothing = getpass.getpass("XUY:")
  File "/usr/local/lib/python2.6/getpass.py", line 81, in unix_getpass
    stream.write('\n')
IOError: [Errno 29] Illegal seek
close failed in file object destructor:
IOError: [Errno 29] Illegal seek

This error occurs only when getpass is called with 2 or more returns in 
the buffer. One return will not reveal the problem.

Running this code with strace shows clearly that the seek problem is 
because that for return in the buffer it tries to seek back. 2 returns 
will cause it to seek -2. 7 returns will cause it to seek -7.

This problem was introduced in python 2.6, and is maintained throughout 
the minor releases of python 2.6 - 2.6.4. It doesn't appear in python 
2.5 and before, and it doesn't appear in python 3.

Doing sys.stdin.flush() doesn't resolve this issue.

----------
components: IO
messages: 94791
nosy: avihu
severity: normal
status: open
title: getpass crashes when several returns are in stdin before getpass was 
called
type: crash
versions: Python 2.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue7246>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to