[issue11432] webbrowser.open on unix fails.
Terry J. Reedy tjre...@udel.edu added the comment: With fix, test, and news in 3.2 and 3.3, is anything left to do? -- nosy: +terry.reedy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11432 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11432] webbrowser.open on unix fails.
Roundup Robot devnull@devnull added the comment: New changeset 08daf3ef6509 by Gregory P. Smith in branch 'default': Add unittests demonstrating issue #11432. http://hg.python.org/cpython/rev/08daf3ef6509 New changeset adcf03b074b7 by Gregory P. Smith in branch 'default': Fix issue #11432. if the stdin pipe is the same file descriptor as either stdout or stderr http://hg.python.org/cpython/rev/adcf03b074b7 New changeset ead52adcd0c8 by Gregory P. Smith in branch '3.2': Fix issue #11432. if the stdin pipe is the same file descriptor as either stdout or stderr http://hg.python.org/cpython/rev/ead52adcd0c8 New changeset ad2bd8d338b0 by Gregory P. Smith in branch '3.2': Add unittests demonstrating issue #11432. http://hg.python.org/cpython/rev/ad2bd8d338b0 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11432 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11432] webbrowser.open on unix fails.
Roundup Robot devnull@devnull added the comment: New changeset 82e010943c68 by Gregory P. Smith in branch '3.2': issue 11432 news entry. http://hg.python.org/cpython/rev/82e010943c68 New changeset 8d3bcf57977b by Gregory P. Smith in branch 'default': Misc/NEWS entry for issue 11432 http://hg.python.org/cpython/rev/8d3bcf57977b -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11432 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11432] webbrowser.open on unix fails.
Changes by Gregory P. Smith g...@krypto.org: -- resolution: - fixed status: open - closed versions: -Python 2.7, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11432 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11432] webbrowser.open on unix fails.
Éric Araujo mer...@netwok.org added the comment: Is this a webbrowser or subprocess bug? Please add the corresponding expert from http://docs.python.org/devguide/experts to the nosy list. -- nosy: +eric.araujo versions: +Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11432 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11432] webbrowser.open on unix fails.
Gregory P. Smith g...@krypto.org added the comment: subprocess in 3.2 bug from the looks of it. not sure if 2.7 or 3.1 are impacted at all, i'll remove them from the list after confirming. -- assignee: - gregory.p.smith ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11432 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11432] webbrowser.open on unix fails.
Charles-Francois Natali neolo...@free.fr added the comment: The problem lies here: /* Close pipe fds. Make sure we don't close the same fd more than */ /* once, or standard fds. */ if (p2cread 2) { POSIX_CALL(close(p2cread)); } (c2pwrite 2) { POSIX_CALL(close(c2pwrite)); } if (errwrite != c2pwrite errwrite 2) { POSIX_CALL(close(errwrite)); } If p2cread == c2pwrite (which is the case here since /dev/null is passed as stdin and stderr), we end up closing the same FD twice, hence the EBADF. Just passing -(c2pwrite 2) { +(c2pwrite 2 c2pwrite != p2cread) { POSIX_CALL(close(c2pwrite)); } Solves this (but you probably also want to check for (errwrite != p2cread) when closing c2pwrite). Note that the Python implementation uses a set to avoid closing the same FD twice: # Close pipe fds. Make sure we don't close the # same fd more than once, or standard fds. closed = set() for fd in [p2cread, c2pwrite, errwrite]: if fd 2 and fd not in closed: os.close(fd) closed.add(fd) It might be cleaner to use a fd_set, i.e.: fd_set set; FD_ZERO(set); FD_SET(0, set); FD_SET(1, set); FD_SET(2, set); if (!FD_ISSET(p2cread, set)) { POSIX_CALL(close(p2cread)); FD_SET(p2cread, fd); } if (!FD_ISSET(c2pwrite, set)) { POSIX_CALL(close(c2pwrite)); FD_SET(c2pwrite, fd); } if (!FD_ISSET(errwrite, set)) { POSIX_CALL(close(errwrite)); FD_SET(errwrite, fd); } But maybe it's just too much (and also, fd_set can be defined in different header files, and while I'm sure it's async-safe on Linux, I don't know if it's required as part of a standard...). -- nosy: +neologix ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11432 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11432] webbrowser.open on unix fails.
Charles-Francois Natali neolo...@free.fr added the comment: Attached is a patch checking that no FD is closed more once when closing pipe FDs, along with an update for test_subprocess. -- keywords: +patch Added file: http://bugs.python.org/file21053/subprocess_same_fd.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11432 ___Index: Lib/test/test_subprocess.py === --- Lib/test/test_subprocess.py (révision 88766) +++ Lib/test/test_subprocess.py (copie de travail) @@ -292,6 +292,32 @@ tf.seek(0) self.assertStderrEqual(tf.read(), bappleorange) +def test_stdin_stdout_filedes(self): +# capture stdin and stdout to the same open file +tf = tempfile.TemporaryFile() +self.addCleanup(tf.close) +p = subprocess.Popen([sys.executable, -c, + 'import sys;' + 'sys.stdout.write(apple);'], + stdin=tf, + stdout=tf) +p.wait() +tf.seek(0) +self.assertEqual(tf.read(), bapple) + +def test_stdin_stderr_filedes(self): +# capture stdin and stderr to the same open file +tf = tempfile.TemporaryFile() +self.addCleanup(tf.close) +p = subprocess.Popen([sys.executable, -c, + 'import sys;' + 'sys.stderr.write(apple);'], + stdin=tf, + stderr=tf) +p.wait() +tf.seek(0) +self.assertEqual(tf.read(), bapple) + def test_stdout_filedes_of_stdout(self): # stdout is set to 1 (#1531862). cmd = rimport sys, os; sys.exit(os.write(sys.stdout.fileno(), b'.\n')) Index: Modules/_posixsubprocess.c === --- Modules/_posixsubprocess.c (révision 88766) +++ Modules/_posixsubprocess.c (copie de travail) @@ -99,10 +99,10 @@ if (p2cread 2) { POSIX_CALL(close(p2cread)); } -if (c2pwrite 2) { +if (c2pwrite 2 c2pwrite != p2cread) { POSIX_CALL(close(c2pwrite)); } -if (errwrite != c2pwrite errwrite 2) { +if (errwrite 2 errwrite != c2pwrite errwrite != p2cread) { POSIX_CALL(close(errwrite)); } ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11432] webbrowser.open on unix fails.
Antoine Pitrou pit...@free.fr added the comment: That probably won't make a difference here, but be aware that we switched to Mercurial and the SVN repo won't get updates anymore. See http://docs.python.org/devguide/ and http://docs.python.org/devguide/setup.html#getting-the-source-code for details. -- nosy: +pitrou stage: - patch review versions: +Python 2.7, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11432 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11432] webbrowser.open on unix fails.
New submission from Campbell Barton ideasma...@gmail.com: On Linux - tested on: Arch linux @ Debian Squeeze, this fails python -c __import__('webbrowser').open('http://python.org') The exception thats raised is: Traceback (most recent call last): File string, line 1, in module File /usr/lib/python3.2/webbrowser.py, line 70, in open_new_tab return open(url, 2) File /usr/lib/python3.2/webbrowser.py, line 62, in open if browser.open(url, new, autoraise): File /usr/lib/python3.2/webbrowser.py, line 276, in open success = self._invoke(args, True, autoraise) File /usr/lib/python3.2/webbrowser.py, line 239, in _invoke stderr=inout, preexec_fn=setsid) File /usr/lib/python3.2/subprocess.py, line 736, in __init__ restore_signals, start_new_session) File /usr/lib/python3.2/subprocess.py, line 1330, in _execute_child raise child_exception_type(errno_num, err_msg) OSError: [Errno 9] Bad file descriptor Noticed that this wont raise an error when stdin arg isn't passed to Popen: line 237: p = subprocess.Popen(cmdline, close_fds=True, stdin=inout, Removing tdin=inout makes firefox load ok, however this is there for a reason so its not a useful fix ofcourse. -- components: Extension Modules messages: 130245 nosy: ideasman42 priority: normal severity: normal status: open title: webbrowser.open on unix fails. versions: Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11432 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11432] webbrowser.open on unix fails.
Changes by Ezio Melotti ezio.melo...@gmail.com: -- components: +Library (Lib) -Extension Modules nosy: +ezio.melotti, georg.brandl type: - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11432 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11432] webbrowser.open on unix fails.
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +gregory.p.smith ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11432 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com