Skip to content
Myr

Merge pull request #2694 from pallets/backport-2359-cli-warning

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

backport #2359 fix python -m import warning

authored by David Lord · committed by GitHub · parents c52e1b7, 18c9db4 · Browse files · 1 file+9 added−9 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+9 added−9 removed

  • other:+9 added−9 removed

1 file+9 added−9 removed

modified:flask/cli.py+9 added-9 removed
492 unmodified lines
493})494495496def main(as_module=False):497 this_module = __package__ + '.cli'497 args = sys.argv[1:]498499 if as_module:501 if sys.version_info >= (2, 7):502 name = 'python -m ' + this_module.rsplit('.', 1)[0]503 else:504 name = 'python -m ' + this_module500 this_module = 'flask'501506 # This module is always executed as "python -m flask.run" and as such507 # we need to ensure that we restore the actual command line so that508 # the reloader can properly operate.509 sys.argv = ['-m', this_module] + sys.argv[1:]502 if sys.version_info < (2, 7):503 this_module += '.cli'504505 name = 'python -m ' + this_module506507 # Python rewrites "python -m flask" to the path to the file in argv.508 # Restore the original command so that the reloader works.509 sys.argv = ['-m', this_module] + args510 else:511 name = None512513 cli.main(args=args, prog_name=name)
4 unmodified lines