I'm not talking about the documentation for sys.exit() I'm talking about the documentation for Py_Main(int argc, char **argv)
http://docs.python.org/c-api/veryhigh.html?highlight=py_main#Py_Main This C function never returns anything whether in the interpreter I type "exit(123)" or "sys.exit(123)". I cannot call any of my C cleanup code because of this. On Sun, Mar 27, 2011 at 1:55 PM, Jerry Hill <malaclyp...@gmail.com> wrote: > On Sun, Mar 27, 2011 at 9:33 AM, Eric Frederich > <eric.freder...@gmail.com> wrote: >> This is behavior contradicts the documentation which says the value >> passed to sys.exit will be returned from Py_Main. >> Py_Main doesn't return anything, it just exits. >> This is a bug. > > Are you sure that calling the builtin exit() function is the same as > calling sys.exit()? > > You keep talking about the documentation for sys.exit(), but that's > not the function you're calling. I played around in the interactive > interpreter a bit, and the two functions do seem to behave a bit > differently from each other. I can't seem to find any detailed > documentation for the builtin exit() function though, so I'm not sure > exactly what the differences are. > > A little more digging reveals that the builtin exit() function is > getting set up by site.py, and it does more than sys.exit() does. > Particularly, in 3.1 it tries to close stdin then raises SystemExit(). > Does that maybe explain the behavior you're seeing? I didn't go > digging in 2.7, which appears to be what you're using, but I think you > need to explore the differences between sys.exit() and the builtin > exit() functions. > > -- > Jerry > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list