Mandeep Singh Grang added the comment:

Here is a testcase to reproduce the issue:

> cat test.py
import site, sys
site.addsitedir('/foo/bar')
print (sys.path)

This prints just a single instance of '/foo/bar':

['/local/mnt/workspace/python/tst', '/foo/bar', '/usr/local/lib/python36.zip', 
'/local/mnt/workspace/python/src/Lib', 
'/local/mnt/workspace/python/src/Lib/plat-linux', 
'/local/mnt/workspace/python/build/build/lib.linux-x86_64-3.6-pydebug']

Now if we explicitly set PYTHONPATH to include '/foo/bar'
> export PYTHONPATH=/foo/bar

and then run test.py here is the output:

['/local/mnt/workspace/python/tst', '/foo/bar', '/usr/local/lib/python36.zip', 
'/local/mnt/workspace/python/src/Lib', 
'/local/mnt/workspace/python/src/Lib/plat-linux', 
'/local/mnt/workspace/python/build/build/lib.linux-x86_64-3.6-pydebug', 
'/foo/bar']

We see that there are duplicate entries for '/foo/bar'.

As Wolfgang rightly said the issue comes from the check for
"if os.path.isdir(dir)" inside _init_pathinfo() in site.py.
On removing this check I no longer see the duplicate entry for '/foo/bar'.

But since this is the first bug I am looking at I am not sure of the 
implications of removing this check. Can someone please confirm that what I see 
is indeed a failing test case, or is this the intended behavior?

Thanks,
Mandeep

----------
nosy: +Mandeep Singh Grang

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26587>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to