exit()
or quit()
detected PYL-R1722 86 app.logger.error(
87 'SECRET_KEY must be set in .env or environment variables in production'
88 )
89 exit(1) 90 else:
91 random_secret = secrets.token_hex()
92 app.logger.warning(
The exit
or quit
functions don't exist at top-level if python is started with the -S
flag, and will raise an error. Use sys.exit()
instead.
The exit
and quit
functions are actually site.Quitter
objects and are loaded, at interpreter start up, from site.py
.
However, if the interpreter is started with the -S
flag, or a custom site.py
is used then exit
and quit
may not be present.
It is recommended to use sys.exit()
which is built into the interpreter and is guaranteed to be present.
try:
patch_diffs()
except Exception as exc:
print(exc)
exit(1)
Here, exit()
is used and will fail if the python is run with the -S
option.
import sys
try:
patch_diffs()
except Exception as exc:
print(exc)
sys.exit(1)
sys.exit()
is guaranteed to work, regardless of the interpreter options.