Closed 44e76c4e-f397-45e7-8e63-ae88bc35aef5 closed 11 years ago
I'm fine with it changing. Hopefully it won't introduce subtle bugs in anyone's programs :)
New changeset 9d2fe615a400 by Antoine Pitrou in branch 'default': Issue bpo-444582: shutil.which() respects relative paths. http://hg.python.org/cpython/rev/9d2fe615a400
There is another small issue: it returns the normcase'd dir, which means that the case is lost under Windows. Not very serious, but cosmetically imperfect I suppose.
From 3.2, os has a function get_exec_path -- shouldn't which() use it instead of rolling its own query of $PATH?
I don't think the Windows example in the reST documentation is correct:
>>> print(shutil.which("python"))
'c:\\python33\\python.exe'
It should be either
>>> shutil.which("python")
'c:\\python33\\python.exe'
or
>>> print(shutil.which("python"))
c:\python33\python.exe
New changeset 84b48551cd13 by Georg Brandl in branch 'default': bpo-444582: fix example and rewrap docs a bit. http://hg.python.org/cpython/rev/84b48551cd13
The 'short circuit' appears to do what I'd consider the wrong thing when an executable file of the same name exists in the working directory. i.e. which('setup.py') can return 'setup.py', even though running 'setup.py' in a shell doesn't work (you need ./setup.py).
This is on UNIX-y systems, I see from the comments that the cwd is implicitly on the path in Windows.
Is this in scope for which() to deal with? Should I open a bug for it? Apologies if it's been discussed already.
Please open a separate issue.
Was a separate issue opened? Is anything outstanding here or can this issue be closed?
Yes, I opened that as bpo-16957, and it has been dealt with. So no objection from me to closing this.
It’s probably too late to address Georg’s comment about reusing os.get_exec_path, so everything is done.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields: ```python assignee = 'https://github.com/briancurtin' closed_at =
created_at =
labels = ['type-feature', 'library']
title = 'Finding programs in PATH, adding shutil.which'
updated_at =
user = 'https://bugs.python.org/edemaine'
```
bugs.python.org fields:
```python
activity =
actor = 'eric.araujo'
assignee = 'brian.curtin'
closed = True
closed_date =
closer = 'eric.araujo'
components = ['Library (Lib)']
creation =
creator = 'edemaine'
dependencies = []
files = ['8185', '15381', '16441', '16447', '16459', '17957', '17958', '17962', '17963', '18000', '18001', '23797', '26054', '26059', '26078', '26090']
hgrepos = []
issue_num = 444582
keywords = ['patch']
message_count = 61.0
messages = ['53174', '53175', '53176', '55402', '57774', '83484', '95614', '100444', '100460', '100469', '106046', '106055', '109234', '109554', '109583', '109587', '109764', '110033', '110034', '110049', '110068', '110073', '110084', '110085', '110291', '113241', '113285', '113944', '115016', '121398', '121424', '124996', '125222', '125233', '134306', '148475', '163201', '163242', '163253', '163376', '163454', '163466', '163479', '163481', '163482', '163483', '163484', '163485', '163487', '163488', '163490', '163492', '163493', '163764', '163800', '163802', '179889', '179891', '185218', '185220', '185221']
nosy_count = 31.0
nosy_names = ['loewis', 'tmick', 'georg.brandl', 'edemaine', 'belopolsky', 'pitrou', 'vstinner', 'wrstlprmpft', 'giampaolo.rodola', 'christian.heimes', 'ajaksu2', 'sfllaw', 'schmir', 'tarek', 'eric.araujo', 'Christophe Simonis', 'andybuckley', 'weeble', 'r.david.murray', 'tleeuwenburg@gmail.com', 'michael.foord', 'brian.curtin', 'meatballhat', 'petere', 'sandro.tosi', 'iki', 'BreamoreBoy', 'Iztok.Kavkler', 'python-dev', 'takluyver', 'Omega_Weapon']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue444582'
versions = ['Python 3.3']
```