[issue7111] abort when stderr is closed

2011-11-28 Thread Charles-François Natali
Charles-François Natali neolo...@free.fr added the comment: Updated patch. LGTM. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7111 ___ ___

[issue7111] abort when stderr is closed

2011-11-28 Thread Roundup Robot
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset f15943505db0 by Antoine Pitrou in branch '3.2': Issue #7111: Python can now be run without a stdin, stdout or stderr stream. http://hg.python.org/cpython/rev/f15943505db0 New changeset c86fb10eaf68 by Antoine Pitrou

[issue7111] abort when stderr is closed

2011-11-28 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Thanks, committed. -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7111

[issue7111] abort when stderr is closed

2011-11-27 Thread Charles-François Natali
Charles-François Natali neolo...@free.fr added the comment: (No Rietveld link): +is_valid_fd(int fd) [...] +dummy_fd = dup(fd); +if (dummy_fd 0) +return 0; +close(dummy_fd); Why not use fstat() instead (does Windows have fstat()? And dup()?). +@unittest.skipIf(os.name

[issue7111] abort when stderr is closed

2011-11-27 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: +is_valid_fd(int fd) [...] +dummy_fd = dup(fd); +if (dummy_fd 0) +return 0; +close(dummy_fd); Why not use fstat() instead (does Windows have fstat()? And dup()?). Windows has dup(), but no fstat(). +

[issue7111] abort when stderr is closed

2011-11-27 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Updated patch. -- Added file: http://bugs.python.org/file23794/nostdio2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7111 ___

[issue7111] abort when stderr is closed

2011-11-26 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Attached patch allows Python to run even if no standard stream is available. I use dup() to detect whether a fd is valid. -- keywords: +patch nosy: +neologix stage: - patch review versions: +Python 3.3 -Python 3.1 Added file:

[issue7111] abort when stderr is closed

2011-11-26 Thread Arfrever Frehtes Taifersar Arahesis
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com: -- nosy: +Arfrever ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7111 ___

[issue7111] abort when stderr is closed

2011-02-03 Thread Daniel Stutzbach
Daniel Stutzbach stutzb...@google.com added the comment: That's an interesting point. Do you know of places where we use fd 2 instead of sys.stderr? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7111

[issue7111] abort when stderr is closed

2011-02-03 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: That's an interesting point. Do you know of places where we use fd 2 instead of sys.stderr? We normally don't. One reason is that buffering inside sys.stderr can make ordering of output incorrect. There are some places in C code where we do

[issue7111] abort when stderr is closed

2011-02-03 Thread Alexander Belopolsky
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: On Thu, Feb 3, 2011 at 2:44 PM, Antoine Pitrou rep...@bugs.python.org wrote: .. Do you know of places where we use fd 2 instead of sys.stderr? We normally don't. One reason is that buffering inside sys.stderr can make

[issue7111] abort when stderr is closed

2011-02-03 Thread Alexander Belopolsky
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: On Thu, Feb 3, 2011 at 2:44 PM, Antoine Pitrou rep...@bugs.python.org wrote: .. Do you know of places where we use fd 2 instead of sys.stderr? We normally don't. Hmm, grep fprintf(stderr, returned 122 hits in the py3k

[issue7111] abort when stderr is closed

2011-02-03 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +exarkun, loewis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7111 ___ ___ Python-bugs-list

[issue7111] abort when stderr is closed

2011-02-03 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: We normally don't. One reason is that buffering inside sys.stderr can make ordering of output incorrect. There are some places in C code where we do fprintf(stderr, ...) but that's for specialized debugging (disabled in normal builds) or

[issue7111] abort when stderr is closed

2011-02-03 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Le jeudi 03 février 2011 à 19:59 +, Alexander Belopolsky a écrit : Alexander Belopolsky belopol...@users.sourceforge.net added the comment: On Thu, Feb 3, 2011 at 2:44 PM, Antoine Pitrou rep...@bugs.python.org wrote: .. Do you know

[issue7111] abort when stderr is closed

2011-02-03 Thread Daniel Stutzbach
Daniel Stutzbach stutzb...@google.com added the comment: On Thu, Feb 3, 2011 at 11:56 AM, Alexander Belopolsky rep...@bugs.python.org wrote: 3rd party extensions.    What is the use case for python -?    Is it important enough to justify the risk of accidental data loss? I don't think closing

[issue7111] abort when stderr is closed

2011-02-03 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: I don't think so. One more important use case is when running a Unix daemon, which has (AFAIK) to close all std handles. I just took a look at http://pypi.python.org/pypi/python-daemon/, and it uses dup2() to redirect standard streams, which is

[issue7111] abort when stderr is closed

2011-02-03 Thread Daniel Stutzbach
Daniel Stutzbach stutzb...@google.com added the comment: On Thu, Feb 3, 2011 at 12:18 PM, Antoine Pitrou rep...@bugs.python.org wrote: I just took a look at http://pypi.python.org/pypi/python-daemon/, and it uses dup2() to redirect standard streams, which is far nicer. I'm more worried about

[issue7111] abort when stderr is closed

2011-02-02 Thread Alexander Belopolsky
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: On the second thought, as long as python used fd 2 as the message stream of last resort, we should probably not allow it to run with fd 2 closed. The problem is that in this case fd 2 may become associated with a very