5b8aa9
From 18c9db47940c1195809a0c82fcb85601c3f4df46 Mon Sep 17 00:00:00 2001
5b8aa9
From: David Lord <davidism@gmail.com>
5b8aa9
Date: Sun, 4 Jun 2017 12:26:21 -0700
5b8aa9
Subject: [PATCH 3/3] be smarter about adding ".cli" to reloader command python
5b8aa9
 -m flask.cli raises an import warning on > 2.6 it's only needed on 2.6,
5b8aa9
 "flask" works otherwise
5b8aa9
5b8aa9
---
5b8aa9
 flask/cli.py | 18 +++++++++---------
5b8aa9
 1 file changed, 9 insertions(+), 9 deletions(-)
5b8aa9
5b8aa9
diff --git a/flask/cli.py b/flask/cli.py
5b8aa9
index 074ee768..ca455671 100644
5b8aa9
--- a/flask/cli.py
5b8aa9
+++ b/flask/cli.py
5b8aa9
@@ -494,19 +494,19 @@ Example usage:
5b8aa9
 
5b8aa9
 
5b8aa9
 def main(as_module=False):
5b8aa9
-    this_module = __package__ + '.cli'
5b8aa9
     args = sys.argv[1:]
5b8aa9
 
5b8aa9
     if as_module:
5b8aa9
-        if sys.version_info >= (2, 7):
5b8aa9
-            name = 'python -m ' + this_module.rsplit('.', 1)[0]
5b8aa9
-        else:
5b8aa9
-            name = 'python -m ' + this_module
5b8aa9
+        this_module = 'flask'
5b8aa9
+
5b8aa9
+        if sys.version_info < (2, 7):
5b8aa9
+            this_module += '.cli'
5b8aa9
+
5b8aa9
+        name = 'python -m ' + this_module
5b8aa9
 
5b8aa9
-        # This module is always executed as "python -m flask.run" and as such
5b8aa9
-        # we need to ensure that we restore the actual command line so that
5b8aa9
-        # the reloader can properly operate.
5b8aa9
-        sys.argv = ['-m', this_module] + sys.argv[1:]
5b8aa9
+        # Python rewrites "python -m flask" to the path to the file in argv.
5b8aa9
+        # Restore the original command so that the reloader works.
5b8aa9
+        sys.argv = ['-m', this_module] + args
5b8aa9
     else:
5b8aa9
         name = None
5b8aa9
 
5b8aa9
-- 
5b8aa9
2.21.0
5b8aa9