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.

classification
Title: Embedded python doesn't recognize exit()
Type: behavior Stage: resolved
Components: Windows Versions: Python 3.10
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: paul.moore, steve.dower, thewh1teagle, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2021-11-19 22:50 by thewh1teagle, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg406624 - (view) Author: thewh1teagle (thewh1teagle) Date: 2021-11-19 22:50
C:\Users\user\Downloads\python-3.10.0-embed-win32>python
Python 3.10.0 (tags/v3.10.0:b494f59, Oct  4 2021, 18:46:30) [MSC v.1929 32 bit (Intel)] on win32
>>> exit
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'exit' is not defined
>>> exit()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'exit' is not defined
>>> import os;os._exit(0)

C:\Users\user\Downloads\python-3.10.0-embed-win32>


same error when running exit from file.
msg406628 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-11-19 23:24
This is expected. The top-level exit() command only exists when the site module is imported, which is not the default for embedded Python (you should specify all the import paths explicitly, since they're going to be in your app rather than found by searching the disk).

You probably want to use sys.exit() in your script.
History
Date User Action Args
2022-04-11 14:59:52adminsetgithub: 90007
2021-11-19 23:24:04steve.dowersetstatus: open -> closed
resolution: not a bug
messages: + msg406628

stage: resolved
2021-11-19 22:50:55thewh1teaglecreate