This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author avihu
Recipients avihu
Date 2009-11-01.16:46:25
SpamBayes Score 2.9254377e-14
Marked as misclassified No
Message-id <1257093988.16.0.063739997235.issue7246@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2009-11-01 16:46:28avihusetrecipients: + avihu
2009-11-01 16:46:28avihusetmessageid: <1257093988.16.0.063739997235.issue7246@psf.upfronthosting.co.za>
2009-11-01 16:46:26avihulinkissue7246 messages
2009-11-01 16:46:26avihucreate