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