[issue40592] `Shutil.which` incosistent with windows's `where`

2020-05-11 Thread Dawid Gosławski

New submission from Dawid Gosławski :

Shutil's which implementation does not work correctly when someone set's empty 
item in `PATHEXT` environment variable. Example:

set PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.RB;.RBW;

I'm not 100% sure how I got this in my PATHEXT config, I wasn't changing that 
so maybe some bugged uninstaller not removed it's extension correctly.

This makes things confusing as Windows will find correctly binary, but Python 
will return nothing, due to this part:

```
if any(cmd.lower().endswith(ext.lower()) for ext in pathext):
files = [cmd]
```

pathext is initialized as `pathext = os.environ.get("PATHEXT", 
"").split(os.pathsep)`, which ends producing '' as last element

Because any string ends with empty string (''), files list will have plain 
version added like `git`, which will then fail executable check.

Workaround is to use full name `git.exe`

Filtering out empty strings would fix that.

--
components: Library (Lib)
messages: 368620
nosy: alkuzad
priority: normal
severity: normal
status: open
title: `Shutil.which` incosistent with windows's `where`

___
Python tracker 
<https://bugs.python.org/issue40592>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31353] Implement PEP 553 - built-in debug()

2017-09-13 Thread Dawid Gosławski

Dawid Gosławski added the comment:

Will that be backported also to Python2.7 ? I personally do not see a reason to 
teach old dog new tricks but it seems appropriate in such core things. New 
users could transition easier, otherwise this would be next py2<->py3 
difference to explain every time someone uses new code.

--
nosy: +alkuzad

___
Python tracker 
<https://bugs.python.org/issue31353>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com