This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients geoffreyspear, ncoghlan, ned.deily, nedbat
Date 2018-04-01.05:25:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1522560314.68.0.467229070634.issue33185@psf.upfronthosting.co.za>
In-reply-to
Content
It turns out pydoc's CLI is looking specifically for '' in sys.path, but *not* looking for "os.getcwd()".

The resulting sys.path manipulation then goes completely wrong for "python -m pydoc", since it ends up removing "scriptdir" from sys.path, and that's the directory containing "pydoc" and the rest of the standard library.

It surprised me that you were getting the misbehaviour for the direct pydoc command though, as for me, that's a separate script living in `*/bin`, so the misbehaviour doesn't happen (only the bin directory gets removed from sys.path, which is the desired behaviour).

It turns out that behaviour is due to a difference between venv and virtualenv, where the latter defines a shell alias to hide the filesystem level pydoc scripts installed system wide:

```
$ which pydoc                                                                                                                                       
pydoc ()                                                                                                                                                                                                
{                                                                                                                                                                                                       
    python -m pydoc "$@"                                                                                                                                                                                
}
```

and hence will encounter the problem.

So I think there are two changes needed here:

1. Update pydoc.cli() to search sys.path for "os.getcwd()" in addition to searching for the empty string.
2. Rewording the note in the porting guide to explicitly call out checks for "'' in sys.path" in start-up code as potentially requiring updates
History
Date User Action Args
2018-04-01 05:25:14ncoghlansetrecipients: + ncoghlan, nedbat, ned.deily, geoffreyspear
2018-04-01 05:25:14ncoghlansetmessageid: <1522560314.68.0.467229070634.issue33185@psf.upfronthosting.co.za>
2018-04-01 05:25:14ncoghlanlinkissue33185 messages
2018-04-01 05:25:14ncoghlancreate