From a1e603a7b34d4016050bcfb6a8248a04e752f120 Mon Sep 17 00:00:00 2001 From: Marcel Hellkamp Date: Sat, 27 Mar 2021 15:15:25 +0100 Subject: fix #1226: Reloading fails for packages started with `python -m` --- bottle.py | 4 ++++ 1 file changed, 4 insertions(+) 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 -- cgit v1.2.1