> > 2009/10/24 Manlio Perillo <manlio.peri...@gmail.com> > > Su molti run, a volte ottieni un eccezione. > L'eccezione è causata dal runtime di Python, che chiama il distruttore > di stdout/stderr, il quale a sua volta chiama close che fallisce. > > Il problema è che: > > * non sembra sia possibile evitare che il traceback venga scritto su > stderr. > Modificare sys.excepthook non funziona > > * non sembra sia possibile dire a Python che stdout/stderr va > considerato chiuso, e che quindi close non va chiamato > > > Credo che questo sia un problema interessante. >
c'è un bug "simile" già aperto: http://bugs.python.org/issue7111 msg93946 - (view)Author: Antoine Pitrou (pitrou)Date: 2009-10-13 23:13 > Please note that normally an error message is output, but of course it doesn't display since stderr is invalid :-) > It's clearer if you close stdout instead: > $ ./python -c 'pass' >&- Fatal Python error: Py_Initialize: can't initialize sys standard streams OSError: [Errno 9] Bad file descriptor Abandon > If we want to allow for closed {stdin, stdout, stderr}, I'm not sure what the semantics should be. Should sys.std{in, out, err} be None? Or a file object which always throws an error? > Under Python 2.x, you don't get a crash but the behaviour is quite unhelpful anyway: > $ python -c 'print 1' >&- close failed in file object destructor: Error in sys.excepthook: > Original exception was: >
_______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python