mirror of
https://github.com/django/django.git
synced 2025-05-06 06:56:30 +00:00
Refs #32363 -- Made shell ignore a missing sys.___interactivehook__.
Thanks Tim Graham for the report. Follow up to 1bbb98d9a4b7d83e422b14ae2429cb368eff5a13.
This commit is contained in:
parent
a7f27fca52
commit
3921b1c6d2
@ -66,11 +66,19 @@ class Command(BaseCommand):
|
|||||||
# write history to the .python_history file, but this can be overridden by
|
# write history to the .python_history file, but this can be overridden by
|
||||||
# $PYTHONSTARTUP or ~/.pythonrc.py.
|
# $PYTHONSTARTUP or ~/.pythonrc.py.
|
||||||
try:
|
try:
|
||||||
sys.__interactivehook__()
|
hook = sys.__interactivehook__
|
||||||
|
except AttributeError:
|
||||||
|
# Match the behavior of the cpython shell where a missing
|
||||||
|
# sys.__interactivehook__ is ignored.
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
hook()
|
||||||
except Exception:
|
except Exception:
|
||||||
# Match the behavior of the cpython shell where an error in
|
# Match the behavior of the cpython shell where an error in
|
||||||
# sys.__interactivehook__ prints a warning and the exception and continues.
|
# sys.__interactivehook__ prints a warning and the exception
|
||||||
print("Failed calling sys.__interactivehook__")
|
# and continues.
|
||||||
|
print('Failed calling sys.__interactivehook__')
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
# Set up tab completion for objects imported by $PYTHONSTARTUP or
|
# Set up tab completion for objects imported by $PYTHONSTARTUP or
|
||||||
|
Loading…
x
Reference in New Issue
Block a user