#32363 closed New feature (fixed)
Django shell does not read ~/.python_history
Reported by: | Peter Inglesby | Owned by: | Peter Inglesby |
---|---|---|---|
Component: | Core (Management commands) | Version: | 4.0 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The Django shell does not read ~/.python_history.
This is because sys.__interactivehook__()
is not called in shell.py.
Adding
try: sys.__interactivehook__() except Exception: print("Failed calling sys.__interactivehook__") traceback.print_exc()
just before the call to code.interpret()
in shell.py fixes this, and makes the Django shell nearly match the behaviour of the Python shell.
I'll create a PR.
Change History (10)
comment:1 by , 4 years ago
comment:2 by , 4 years ago
Has patch: | set |
---|
comment:3 by , 4 years ago
Component: | Uncategorized → Core (Management commands) |
---|---|
Type: | Uncategorized → Bug |
comment:4 by , 4 years ago
Triage Stage: | Unreviewed → Accepted |
---|---|
Type: | Bug → New feature |
The fix is possibly a little more complex than that...
OK, thanks for the report. If we can get it in without issue then it would be a nice addition.
comment:5 by , 4 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:6 by , 3 years ago
Patch needs improvement: | set |
---|
There's unresolved debate on the PR about whether the current proposal is acceptable. Marking PNI whilst that's concluded (either way).
comment:7 by , 3 years ago
Patch needs improvement: | unset |
---|
comment:8 by , 3 years ago
Triage Stage: | Accepted → Ready for checkin |
---|---|
Version: | 3.1 → 4.0 |
The fix is possibly a little more complex than that, since Django already runs some of the code in the default code in
sys.__interactivehook()__
in site.py, and I'm not sure what would happen if that was duplicated.