[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

Nick Coghlan report at bugs.python.org
Thu Mar 22 08:16:39 EDT 2018


Nick Coghlan <ncoghlan at gmail.com> added the comment:

Brett or Eric, any chance one of you could run with this for 3.7b3? I already have a startup refactoring related regression that I'm aiming to have fixed before then.

Thanks to Victor's refactoring work, there's at least a clear interception point now where we can treat the empty string differently depending on whether the command line option was `-c`, `-m`, or not specified at all: https://github.com/python/cpython/blob/master/Python/pathconfig.c#L259

As an initial attempt, I think the necessary fix will be along the lines of checking for 'n == 0 && argc > 1 && wcscmp(argv0, L"-m") == 0', and resolving the current working directory in that case.

----------

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


More information about the Python-bugs-list mailing list