[New-bugs-announce] [issue4654] os.path.realpath() get the wrong result

dirlt report at bugs.python.org
Sat Dec 13 09:47:40 CET 2008

New submission from dirlt <zhang_yan at baidu.com>:

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')

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')

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

components: Library (Lib)
messages: 77719
nosy: dirlt
severity: normal
status: open
title: os.path.realpath() get the wrong result
type: behavior
versions: Python 2.3

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list