Skip to content

Commit

Permalink
Merge pull request #2694 from pallets/backport-2359-cli-warning
Browse files Browse the repository at this point in the history
backport #2359 fix python -m import warning
  • Loading branch information
davidism authored Apr 10, 2018
2 parents c52e1b7 + 18c9db4 commit aab4c8c
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions flask/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,19 +494,19 @@ def shell_command():


def main(as_module=False):
this_module = __package__ + '.cli'
args = sys.argv[1:]

if as_module:
if sys.version_info >= (2, 7):
name = 'python -m ' + this_module.rsplit('.', 1)[0]
else:
name = 'python -m ' + this_module
this_module = 'flask'

if sys.version_info < (2, 7):
this_module += '.cli'

name = 'python -m ' + this_module

# This module is always executed as "python -m flask.run" and as such
# we need to ensure that we restore the actual command line so that
# the reloader can properly operate.
sys.argv = ['-m', this_module] + sys.argv[1:]
# 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:
name = None

Expand Down

0 comments on commit aab4c8c

Please sign in to comment.