[issue18116] getpass.getpass() triggers ResourceWarning

2013-06-06 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: getpass.getpass('Password: ', sys.stdout) Traceback (most recent call last): File stdin, line 1, in module File /home/serhiy/py/cpython/Lib/getpass.py, line 72, in unix_getpass passwd = _raw_input(prompt, stream, input=input) File

[issue18116] getpass.getpass() triggers ResourceWarning

2013-06-06 Thread Serhiy Storchaka
Changes by Serhiy Storchaka storch...@gmail.com: -- components: +IO nosy: +hynek, pitrou, stutzbach ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18116 ___

[issue18116] getpass.getpass() triggers ResourceWarning

2013-06-06 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: The problem is in io.open, not in getpass. Here is a test script. $ ./python buffered_open_fd_leak.py buffered_open_fd_leak.py:7: ResourceWarning: unclosed file _io.FileIO name=3 mode='rb+' tty = io.open(fd, 'w+', 1) -- versions: +Python 3.4

[issue18116] getpass.getpass() triggers ResourceWarning

2013-06-06 Thread Vajrasky Kok
Vajrasky Kok added the comment: So the correct fix should be: 1. Make sure we can open /dev/tty in non-binary mode, 2. We can write string to /dev/tty, 3. Close the leak if we can not open /dev/tty. Is it? -- ___ Python tracker

[issue18116] getpass.getpass() triggers ResourceWarning

2013-06-06 Thread Vajrasky Kok
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',

[issue18116] getpass.getpass() triggers ResourceWarning

2013-06-06 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: getpass.getpass('Password: ', open('/dev/stdout', 'w')) Traceback (most recent call last): File stdin, line 1, in module File /home/serhiy/py/cpython/Lib/getpass.py, line 72, in unix_getpass passwd = _raw_input(prompt, stream, input=input) File

[issue18116] getpass.getpass() triggers ResourceWarning

2013-06-04 Thread Vajrasky Kok
Vajrasky Kok added the comment: Based on the input from Benjamin Peterson, I grab encoding from the os module in the getpass module. I put some test as well. Until the whole function is rewritten, I hope this patch will suffice and do the job properly. -- Added file:

[issue18116] getpass.getpass() triggers ResourceWarning

2013-06-03 Thread Benjamin Peterson
Benjamin Peterson added the comment: This code is pretty broken. I don't think ttys are ever seekable, so the os.fdopen has probably been always failing since 3.0. It thus always leaks an fd to '/dev/tty' if the first os.open succeeds. The whole function should probably be rewriten to work

[issue18116] getpass.getpass() triggers ResourceWarning

2013-06-02 Thread Vajrasky Kok
Vajrasky Kok added the comment: I isolate the bug. It happens in these lines: # Always try reading and writing directly on the tty first. fd = os.open('/dev/tty', os.O_RDWR|os.O_NOCTTY) tty = os.fdopen(fd, 'w+', 1) So to produce the bug more specifically, you can try

[issue18116] getpass.getpass() triggers ResourceWarning

2013-06-02 Thread Vajrasky Kok
Vajrasky Kok added the comment: I have investigated this problem and come up with the patch to fix the problem. This patch does the job. Caution: only for Python 3.4. But translating this patch to Python 3.3 should be straightforward. I hope this patch could be the foundation for better

[issue18116] getpass.getpass() triggers ResourceWarning

2013-06-02 Thread Vajrasky Kok
Vajrasky Kok added the comment: Sorry, My previous patch breaks the test. This one should pass the test and fix the bug. Still, there are ugly code in the patch that I hope better programmers could fix. -- Added file:

[issue18116] getpass.getpass() triggers ResourceWarning

2013-06-01 Thread Nikolaus Rath
New submission from Nikolaus Rath: [0] nikratio@vostro:~/tmp$ cat bugme.py #!python import getpass import warnings warnings.simplefilter('default') getpass.getpass(What's up?) [0] nikratio@vostro:~/tmp$ python3 --version Python 3.3.2 [0] nikratio@vostro:~/tmp$ python3 bugme.py

[issue18116] getpass.getpass() triggers ResourceWarning

2013-06-01 Thread Alex Gaynor
Alex Gaynor added the comment: Attached patch should fix this issue. -- keywords: +patch nosy: +alex Added file: http://bugs.python.org/file30442/issue18116.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18116

[issue18116] getpass.getpass() triggers ResourceWarning

2013-06-01 Thread Nikolaus Rath
Nikolaus Rath added the comment: No, it doesn't. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18116 ___ ___ Python-bugs-list mailing list

[issue18116] getpass.getpass() triggers ResourceWarning

2013-06-01 Thread Alex Gaynor
Alex Gaynor added the comment: Are you sure you applied it correctly? With and without: Alexanders-MacBook-Pro:cpython alex_gaynor$ ./python.exe x.py What's up? Alexanders-MacBook-Pro:cpython alex_gaynor$ hg revert --all --no-backup reverting Lib/getpass.py Alexanders-MacBook-Pro:cpython

[issue18116] getpass.getpass() triggers ResourceWarning

2013-06-01 Thread Nikolaus Rath
Nikolaus Rath added the comment: Yes, I'm pretty sure: [0] nikratio@vostro:~/tmp$ cp /usr/lib/python3.3/getpass.py . [0] nikratio@vostro:~/tmp$ patch -p2 issue18116.diff patching file getpass.py Hunk #1 succeeded at 57 (offset -1 lines). [0] nikratio@vostro:~/tmp$ python3 bugme.py

[issue18116] getpass.getpass() triggers ResourceWarning

2013-06-01 Thread Vajrasky Kok
Vajrasky Kok added the comment: This bug happens in Python 3.4 as well. [sky@localhost cpython]$ ./python --version Python 3.4.0a0 [sky@localhost cpython]$ ./python /tmp/bugme.py /home/sky/Code/python/programming_language/cpython/Lib/os.py:1025: ResourceWarning: unclosed file _io.FileIO name=3