classification
Title: shutil.which() should preserve path case
Type: behavior Stage: resolved
Components: Library (Lib), Windows Versions: Python 3.3, Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: Ramchandra Apte, hynek, pitrou, python-dev, serhiy.storchaka, skrah, tarek
Priority: normal Keywords: patch

Created on 2013-01-18 09:25 by serhiy.storchaka, last changed 2013-01-24 18:18 by serhiy.storchaka. This issue is now closed.

Files
File name Uploaded Description Edit
shutil_which_normcase.patch serhiy.storchaka, 2013-01-19 16:44 review
Messages (9)
msg180181 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-01-18 09:25
Now which lowercase found directory name and extension on Windows.

>>> shutil.which("python")
'c:\\python33\\python.exe'

Proposed patch preserve case.

>>> shutil.which("python")
'C:\\Python33\\python.exe'

Please test this on Windows.
msg180246 - (view) Author: Ramchandra Apte (Ramchandra Apte) * Date: 2013-01-19 13:56
Somehow the patch is not showing for me.
msg180248 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-01-19 16:44
Oh, sorry. Here is a patch.
msg180338 - (view) Author: Roundup Robot (python-dev) Date: 2013-01-21 13:04
New changeset d2db601a53b3 by Serhiy Storchaka in branch '3.3':
Issue #16993: shutil.which() now preserves the case of the path and extension
http://hg.python.org/cpython/rev/d2db601a53b3

New changeset 5faae2bdf1e0 by Serhiy Storchaka in branch 'default':
Issue #16993: shutil.which() now preserves the case of the path and extension
http://hg.python.org/cpython/rev/5faae2bdf1e0
msg180357 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-01-21 20:40
Test broken on Windows because PATHEXT contains uppercased extension ".EXT".

Proposed solutions:

1. Fix the test: expect uppercased extension, or do case-insensitive extension comparison, or get extension from PATHEXT.
2. Rollback the part of previous changes which preserve case of extensions from PATHEXT and always lowercase them.
3. Rollback the changes overall.
4. Use not used for now ntpath._getfinalpathname() to get a real file name (it resolves symlinks, though).
msg180371 - (view) Author: Roundup Robot (python-dev) Date: 2013-01-22 08:33
New changeset 28282e4e9d04 by Serhiy Storchaka in branch '3.3':
Fix shutil.which() test for issue #16993.
http://hg.python.org/cpython/rev/28282e4e9d04

New changeset e8f40d4f497c by Serhiy Storchaka in branch 'default':
Fix shutil.which() test for issue #16993.
http://hg.python.org/cpython/rev/e8f40d4f497c
msg180373 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-01-22 08:52
I chose the first simplest variant.
msg180534 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2013-01-24 17:06
Serhiy, test_pathext_checking still fails on many Windows buildbots:

http://buildbot.python.org/all/waterfall?category=3.x.stable&category=3.x.unstable
msg180539 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-01-24 18:18
Thank you, Stefan. This relates to issue16957.
History
Date User Action Args
2013-01-24 18:18:34serhiy.storchakasetstatus: open -> closed

messages: + msg180539
2013-01-24 17:06:14skrahsetstatus: closed -> open
nosy: + skrah
messages: + msg180534

2013-01-22 08:52:56serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg180373

stage: resolved
2013-01-22 08:33:23python-devsetmessages: + msg180371
2013-01-21 20:40:37serhiy.storchakasetstatus: closed -> open

nosy: + pitrou
messages: + msg180357

resolution: fixed -> (no value)
stage: resolved -> (no value)
2013-01-21 13:14:57serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2013-01-21 13:04:15python-devsetnosy: + python-dev
messages: + msg180338
2013-01-21 12:57:37serhiy.storchakasetassignee: serhiy.storchaka
2013-01-19 16:45:07serhiy.storchakasetfiles: + shutil_which_normcase.patch
keywords: + patch
messages: + msg180248
2013-01-19 13:56:28Ramchandra Aptesetnosy: + Ramchandra Apte
messages: + msg180246
2013-01-18 09:26:11serhiy.storchakasetcomponents: + Library (Lib), Windows
stage: patch review
2013-01-18 09:25:25serhiy.storchakacreate