Simplify flask.cli.main

Werkzeug>=0.15's reloader now properly detects `python -m module`.
Fixes #3022
This commit is contained in:
EtiennePelletier 2019-05-06 15:56:06 -04:00 committed by David Lord
parent 5a49b96d0e
commit e0afff0e92
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
2 changed files with 4 additions and 17 deletions

View file

@ -33,6 +33,9 @@ Unreleased
moved into Werkzeug. Use Werkzeug's version with Flask-specific
support. This bumps the Werkzeug dependency to >= 0.15.
:issue:`3125`
- The ``flask`` command entry point is simplified to take advantage
of Werkzeug 0.15's better reloader support. This bumps the Werkzeug
dependency to >= 0.15. :issue:`3022`
.. _#2935: https://github.com/pallets/flask/issues/2935
.. _#2957: https://github.com/pallets/flask/issues/2957

View file

@ -907,23 +907,7 @@ debug mode.
def main(as_module=False):
args = sys.argv[1:]
if as_module:
this_module = "flask"
if sys.version_info < (2, 7):
this_module += ".cli"
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:
name = None
cli.main(args=args, prog_name=name)
cli.main(prog_name="python -m flask" if as_module else None)
if __name__ == "__main__":