This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2008年12月13日 08:47 by dirlt, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Messages (7) | |||
|---|---|---|---|
| msg77719 - (view) | Author: dirlt (dirlt) | Date: 2008年12月13日 08:47 | |
I found the problem when i install a small tool which I wrote on the each machine in the company.the problem is simplified as follows: there are three files 1./home/share/temp/a a regular file 2./home/share/a.lnk which is symbolic link to the /home/share/temp/a 3./home/share/temp/test.py whose contents are #!/usr/bin/env python import os import sys print sys.version print os.uname() print os.path.realpath("/home/share/temp/../a.lnk") print os.path.abspath("/home/share/temp/../a.lnk") and I ran the python script on two different machines,but the version of python interpreters are the same,and both of them are 64 bits machine, but the result of os.path.realpath is different,one is -------------------------------------------------------- 2.3.4 (#1, Feb 2 2005, 11:44:13) [GCC 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)] ('Linux', 'tc-com-test00.tc.baidu.com', '2.6.9-52bs', '#2 SMP Fri Jan 26 13:34:38 CST 2007', 'x86_64') /home/share/a.lnk /home/share/a.lnk another is ----------------------------------------------------------- 2.3.4 (#1, Dec 11 2007, 05:28:55) [GCC 3.4.6 20060404 (Red Hat 3.4.6-9)] ('Linux', 'tc-ecom-dev00.tc.baidu.com', '2.6.9-52bs', '#2 SMP Fri Jan 26 13:34:38 CST 2007', 'x86_64') /home/share/temp/temp/a /home/share/a.lnk But obviously the first one os.path.realpath(...) should be /home/share/temp/a instead of /home/share/a.lnk and the second on os.path.realpath(...) should also be /home/share/temp/a instaed of /home/share/temp/temp/a |
|||
| msg108202 - (view) | Author: Mark Lawrence (BreamoreBoy) * | Date: 2010年06月19日 18:38 | |
An issue with Python 2.3, can this be closed or is it still a problem with Python 2.7 or any of the Python 3 versions? |
|||
| msg108205 - (view) | Author: Shashwat Anand (l0nwlf) | Date: 2010年06月19日 18:58 | |
No such issue on python 2.6, 2.7, 3.2.
>>> print(os.path.realpath('/Users/l0nwlf/Desktop/tmp/../decotest.lnk'))
/Users/l0nwlf/Desktop/decotest.lnk
I think this issue can be closed.
However, I came with a different issue while testing on 2.6, trunk and 3.2.
>>> print(os.path.realpath('~/Desktop/tmp/../decotest.lnk'))
/Volumes/CoreHD/py3k/~/Desktop/decotest.lnk
|
|||
| msg108215 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2010年06月19日 22:54 | |
Your different issue looks like a correct result to me. ~ is not automatically expanded. |
|||
| msg108217 - (view) | Author: Shashwat Anand (l0nwlf) | Date: 2010年06月19日 23:17 | |
By different issue I meant expected but non-useful output. Although it does exactly what it is supposed to do, but expanding tilde (~) to $HOME could have been the default behavior(more user-friendly I should say). Don't know if that is worth it but the scale seems more on the negative side. |
|||
| msg108218 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2010年06月19日 23:32 | |
I can confirm this works correctly on 32 bit Linux under 2.6.4. Since it is unlikely the width matters to this issue I'm going to close it. If anyone has a case where it fails we can reopen. |
|||
| msg108219 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2010年06月19日 23:35 | |
Somebody long ago made the decision that ~ is only expanded if you call expanduser. I don't think this decision is likely to get changed. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:42 | admin | set | github: 48904 |
| 2010年06月19日 23:36:03 | r.david.murray | set | status: open -> closed |
| 2010年06月19日 23:35:08 | r.david.murray | set | messages: + msg108219 |
| 2010年06月19日 23:32:44 | r.david.murray | set | resolution: out of date messages: + msg108218 stage: resolved |
| 2010年06月19日 23:17:35 | l0nwlf | set | messages: + msg108217 |
| 2010年06月19日 22:54:46 | r.david.murray | set | nosy:
+ r.david.murray messages: + msg108215 |
| 2010年06月19日 18:58:33 | l0nwlf | set | messages: + msg108205 |
| 2010年06月19日 18:46:17 | ezio.melotti | set | nosy:
+ ezio.melotti |
| 2010年06月19日 18:42:03 | l0nwlf | set | nosy:
+ loewis, l0nwlf |
| 2010年06月19日 18:38:18 | BreamoreBoy | set | nosy:
+ BreamoreBoy messages: + msg108202 |
| 2008年12月13日 08:47:38 | dirlt | create | |