Skip to content
Myr

shell calls sys.__interativehook__

Before adoption: this commit came in with the history the project adopted, so no landing records it.

This will set up readline tab and history completion by default.

authored by David Lord · committed by David Lord · parent 64213fc · Browse files · 2 files+20 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+20 added−0 removed

  • other:+20 added−0 removed

2 files+20 added−0 removed

modified:src/flask/cli.py+18 added
885 unmodified lines
886 eval(compile(f.read(), startup, "exec"), ctx)887888 ctx.update(app.make_shell_context())889890 # Site, customize, or startup script can set a hook to call when891 # entering interactive mode. The default one sets up readline with892 # tab and history completion.893 interactive_hook = getattr(sys, "__interactivehook__", None)894895 if interactive_hook is not None:896 try:897 import readline898 from rlcompleter import Completer899 except ImportError:900 pass901 else:902 # rlcompleter uses __main__.__dict__ by default, which is903 # flask.__main__. Use the shell context instead.904 readline.set_completer(Completer(ctx).complete)905906 interactive_hook()907908 code.interact(banner=banner, local=ctx)909910911@click.command("routes", short_help="Show the routes for the app.")
72 unmodified lines
modified:CHANGES.rst+2 added
68 unmodified lines
69 ``@app.route("/login", methods=["POST"])``. :pr:`3907`70- Support async views, error handlers, before and after request, and71 teardown functions. :pr:`3412`72- Support nesting blueprints. :issue:`593, 1548`, :pr:`3923`73- ``flask shell`` sets up tab and history completion like the default74 ``python`` shell if ``readline`` is installed. :issue:`3941`757677Version 1.1.278-------------
1011 unmodified lines