This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ralph.corderoy
Recipients ralph.corderoy
Date 2010-03-24.14:52:35
SpamBayes Score 2.5558806e-05
Marked as misclassified No
Message-id <1269442357.88.0.102314417571.issue8220@psf.upfronthosting.co.za>
In-reply-to
Content
A friend wrote "exit(0)" in a script without an import of sys.  I
pointed out the error and he said "But it works".  He was right.

    $ lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description:    Ubuntu 9.10
    Release:        9.10
    Codename:       karmic
    $ python --version
    Python 2.6.4
    $ python -c 'quit("foo")'
    foo
    $ echo $?
    1
    $ python -Sc 'quit("foo")'
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    NameError: name 'quit' is not defined
    $ python -c 'print quit.__class__, exit.__class__'
    <class 'site.Quitter'> <class 'site.Quitter'>
    $

site.py is polluting, to my mind, the builtin namespace with `exit' and 
`quit'.  Surely this should only happen for interactive use of python?

http://docs.python.org/library/constants.html#exit says "They are useful
for the interactive interpreter shell and should not be used in
programs." but it seems to easy for exit, especially, to be used by
mistake.

Could the pollution only happen if the Python interpreter is an
interactive one?  Or, not as good, when called, could they tell this
isn't an interactive session and error?
History
Date User Action Args
2010-03-24 14:52:38ralph.corderoysetrecipients: + ralph.corderoy
2010-03-24 14:52:37ralph.corderoysetmessageid: <1269442357.88.0.102314417571.issue8220@psf.upfronthosting.co.za>
2010-03-24 14:52:36ralph.corderoylinkissue8220 messages
2010-03-24 14:52:35ralph.corderoycreate