summaryrefslogtreecommitdiff
path: root/bottle.py
diff options
context:
space:
mode:
Diffstat (limited to 'bottle.py')
-rwxr-xr-xbottle.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/bottle.py b/bottle.py
index 23fff76..c32c7f3 100755
--- a/bottle.py
+++ b/bottle.py
@@ -3669,6 +3669,10 @@ def run(app=None,
os.close(fd) # We only need this file to exist. We never write to it
while os.path.exists(lockfile):
args = [sys.executable] + sys.argv
+ if getattr(sys.modules.get('__main__'), '__package__', None):
+ # If a package was loaded with `python -m`, then `sys.argv`
+ # is wrong and needs fixing in some cases. See #1336
+ args[1:1] = ["-m", sys.modules['__main__'].__package__]
environ = os.environ.copy()
environ['BOTTLE_CHILD'] = 'true'
environ['BOTTLE_LOCKFILE'] = lockfile