[issue18116] getpass.getpass() triggers ResourceWarning
Vajrasky Kok
report at bugs.python.org
Thu Jun 6 15:48:39 CEST 2013
Vajrasky Kok added the comment:
Fixing IO leak resource would fix this bug but leave another bug opened which I try to fix as well.
These statements with Python3 under Linux will always fail because we need to open /dev/tty file in binary mode (for whatever reason).
fd = os.open('/dev/tty', os.O_RDWR|os.O_NOCTTY)
tty = os.fdopen(fd, 'w+', 1)
So I guess the correct fix would be to open /dev/tty in binary mode (and set buffering off) and go on from there.
Of course, one can argue whether this bug should be separated from the original bug (resource warning). I am not sure either.
Anyway, here is the patch that will work with stream StringIO and stdout.
Thank you for Serhiy for pointing out my mistakes.
----------
Added file: http://bugs.python.org/file30483/getpass_fix_works_with_stringio_and_stdout_stream.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18116>
_______________________________________
More information about the Python-bugs-list
mailing list