Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue7246] getpass crashes when several returns are in stdin before getpass was called

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Nov 1, 2009, 8:46 AM

Post #1 of 1 (48 views)
Permalink
[issue7246] getpass crashes when several returns are in stdin before getpass was called

New submission from Avihu Turzion <avihu[at]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 <report[at]bugs.python.org>
<http://bugs.python.org/issue7246>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.