-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
Fix for bugs relating to ntpath.expanduser() #40279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Attached is a patch for sf bug bpo-796219 that fixes I will comment with output from both the unpatched and |
Logged In: YES #test setup:
>>> import os
>>> os.environ['TESTING'] = '%TESTING1%'
>>> os.environ['TESTING1'] = '%TESTING2%'
>>> os.environ['TESTING2'] = 'Final\\Path'
#test standard ntpath
>>> import ntpath
>>> ntpath.expanduser('~')
'C:\\Documents and Settings\\jcarlson'
>>> ntpath.expanduser('~billy')
'~billy'
>>> ntpath.expanduser('~billy\\bob')
'~billy\\bob'
>>> ntpath.expanduser('~\\bob')
'C:\\Documents and Settings\\jcarlson\\bob'
>>>
ntpath.expanduser('~billy\\%TESTING%\\%TESTING1%\\%TESTING2%')
'~billy\\%TESTING%\\%TESTING1%\\%TESTING2%'
#test patched ntpath
>>> import ntpath_patched
>>> ntpath_patched.expanduser('~')
'C:Documents and Settings\\jcarlson'
>>> ntpath_patched.expanduser('~billy')
'C:Documents and Settings\\billy'
>>> ntpath_patched.expanduser('~billy\\bob')
'C:Documents and Settings\\billy\\bob'
>>> ntpath_patched.expanduser('~\\bob')
'C:Documents and Settings\\jcarlson\\bob'
>>>
ntpath_patched.expanduser('~billy\\%TESTING%\\%TESTING1%\\%TESTING2%')
'C:Documents and
Settings\\billy\\Final\\Path\\Final\\Path\\Final\\Path' |
Logged In: YES I uploaded the testing as text to alleviate text wrapping |
Logged In: YES this problem maybe is whats |
Logged In: YES What problem is needed? Perhaps you mean "this solution is desireable". |
Logged In: YES This looks much better to me! |
Logged In: YES bugger, wrong report :-/ |
Logged In: YES I've just attached an updated version of the patch to handle |
The patch looks good to me; documentation updates and new tests will be needed though. |
This fixes bpo-796219. |
I have just attached an updated patch (against trunk) for ntpath expandusers and expandvars that includes documentation and test updates. |
Thanks! Committed as rev. 54364. |
I just saw this bug entry in the whatsnew list. The os.path.expanduser() There is no way to get the path to a user's home directory w/o her Martin, do you concur? |
Not really. On my system, which is part of a domain, expanduser("~") Even if this doesn't work for all systems, I don't think we can |
Just ran into this myself, and would agree with Christian's comments. On This seems broken to me. It's surely better to have reliable functions Will this be considered for Python 2.7 now? I'd suggest opening a new |
In fact, wouldn't a very simple fix be to not return paths that don't |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: