[New-bugs-announce] [issue31874] [feature] runpy.run_module should mimic script launch behavior for sys.path

Jason R. Coombs report at bugs.python.org
Thu Oct 26 10:01:14 EDT 2017


New submission from Jason R. Coombs <jaraco at jaraco.com>:

In [this comment](https://bugs.python.org/issue16737#msg282872) I describe an issue whereby launching an application via runpy.run_module (aka python -m) produces different and unexpected behavior than running the same app via an entry script.

In [this followup comment](https://bugs.python.org/issue16737#msg304662), I provide more detail on why a user might expect for run_module to mimic the behavior of launching a script.

[Nick suggests](https://bugs.python.org/issue16737#msg304707):

> Update sys.path[0] based on __main__.__spec__.origin after [resolving] __main__.__spec__. That way it will only stay as the current directory if the module being executed is in a subdirectory of the current directory, and will otherwise be updated appropriately for wherever we actually found the main module.

----------
messages: 305054
nosy: jason.coombs
priority: normal
severity: normal
status: open
title: [feature] runpy.run_module should mimic script launch behavior for sys.path
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31874>
_______________________________________


More information about the New-bugs-announce mailing list