Skip to content
Myr

be smarter about adding ".cli" to reloader command

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

python -m flask.cli raises an import warning on > 2.6 it's only needed on 2.6, "flask" works otherwise closes #2357

authored by David Lord · committed by David Lord · parent 63129e8 · Browse files · 1 file+10 added−10 removed
This commit

State

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

Diff stats

1 file+10 added−10 removed

  • other:+10 added−10 removed

1 file+10 added−10 removed

modified:flask/cli.py+10 added-10 removed
20 unmodified lines
2122import click2324from . import __version__25from ._compat import iteritems, reraise25from ._compat import iteritems, reraise, PY226from .globals import current_app27from .helpers import get_debug_flag28from ._compat import getargspec29
616 unmodified lines
646})647648649def main(as_module=False):650 this_module = __package__ + '.cli'650 args = sys.argv[1:]651652 if as_module:654 if sys.version_info >= (2, 7):655 name = 'python -m ' + this_module.rsplit('.', 1)[0]656 else:657 name = 'python -m ' + this_module653 this_module = 'flask'654659 # This module is always executed as "python -m flask.run" and as such660 # we need to ensure that we restore the actual command line so that661 # the reloader can properly operate.662 sys.argv = ['-m', this_module] + sys.argv[1:]655 if sys.version_info < (2, 7):656 this_module += '.cli'657658 name = 'python -m ' + this_module659660 # Python rewrites "python -m flask" to the path to the file in argv.661 # Restore the original command so that the reloader works.662 sys.argv = ['-m', this_module] + args663 else:664 name = None665666 cli.main(args=args, prog_name=name)
4 unmodified lines