diff options
author | Marcel Hellkamp <marc@gsites.de> | 2021-03-27 15:15:25 +0100 |
---|---|---|
committer | Marcel Hellkamp <marc@gsites.de> | 2021-03-27 15:15:25 +0100 |
commit | a1e603a7b34d4016050bcfb6a8248a04e752f120 (patch) | |
tree | db2dc79c69ce12d12e8975c5f42bbf69464ec7bf | |
parent | f9b1849db4dd724e36a93a1032be592193fba581 (diff) | |
download | bottle-a1e603a7b34d4016050bcfb6a8248a04e752f120.tar.gz |
fix #1226: Reloading fails for packages started with `python -m`
-rwxr-xr-x | bottle.py | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -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 |