be smarter about adding ".cli" to reloader command
python -m flask.cli raises an import warning on > 2.6 it's only needed on 2.6, "flask" works otherwise
This commit is contained in:
parent
c52e1b7388
commit
18c9db4794
1 changed files with 9 additions and 9 deletions
18
flask/cli.py
18
flask/cli.py
|
|
@ -494,19 +494,19 @@ Example usage:
|
||||||
|
|
||||||
|
|
||||||
def main(as_module=False):
|
def main(as_module=False):
|
||||||
this_module = __package__ + '.cli'
|
|
||||||
args = sys.argv[1:]
|
args = sys.argv[1:]
|
||||||
|
|
||||||
if as_module:
|
if as_module:
|
||||||
if sys.version_info >= (2, 7):
|
this_module = 'flask'
|
||||||
name = 'python -m ' + this_module.rsplit('.', 1)[0]
|
|
||||||
else:
|
|
||||||
name = 'python -m ' + this_module
|
|
||||||
|
|
||||||
# This module is always executed as "python -m flask.run" and as such
|
if sys.version_info < (2, 7):
|
||||||
# we need to ensure that we restore the actual command line so that
|
this_module += '.cli'
|
||||||
# the reloader can properly operate.
|
|
||||||
sys.argv = ['-m', this_module] + sys.argv[1:]
|
name = 'python -m ' + this_module
|
||||||
|
|
||||||
|
# Python rewrites "python -m flask" to the path to the file in argv.
|
||||||
|
# Restore the original command so that the reloader works.
|
||||||
|
sys.argv = ['-m', this_module] + args
|
||||||
else:
|
else:
|
||||||
name = None
|
name = None
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue