New submission from Ian Shields: Filespecs that start with ~ are not properly handled by os.path.realpath or os.path.abspath (and maybe other functions). Following console output from Fedora 17 using Puthon 3.2 illustrates the issue. Similar issue in 2.7 [ian@attic4 developerworks]$ cd .. [ian@attic4 ~]$ mkdir testpath [ian@attic4 ~]$ cd testpath [ian@attic4 testpath]$ pwd /home/ian/testpath [ian@attic4 testpath]$ python3 Python 3.2.3 (default, Jun 8 2012, 05:36:09) [GCC 4.7.0 20120507 (Red Hat 4.7.0-5)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.path.abspath("~") '/home/ian/testpath/~' >>> os.path.realpath("~/xxx/zzz") '/home/ian/testpath/~/xxx/zzz' >>> os.path.abspath("~/..") '/home/ian/testpath'
Function should probably use expanduser to determine if path is already absolute. Documentation at http://docs.python.org/3/library/os.path.html is also misleading as this is not how these functions work if given an absolute path to start with. ---------- components: None messages: 179170 nosy: ibshields priority: normal severity: normal status: open title: Odd behavior of ~ in os.path.abspath and os.path.realpath type: behavior versions: Python 3.2 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue16877> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com