embedding interactive python interpreter

Jerry Hill malaclypse2 at gmail.com
Sun Mar 27 13:55:23 EDT 2011


On Sun, Mar 27, 2011 at 9:33 AM, Eric Frederich
<eric.frederich at 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



More information about the Python-list mailing list