Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue7315] os.path.normpath doesn't normalize ../path/something.py

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Nov 13, 2009, 9:05 AM

Post #1 of 4 (207 views)
Permalink
[issue7315] os.path.normpath doesn't normalize ../path/something.py

New submission from James <purpleidea [at] gmail>:

os.path.normpath doesn't normalize paths that start with ../
you would expect the final output line in the secpnd run to read:
"normpath: badnormpath.py" instead of: "normpath: ../tmp/badnormpath.py"

example:

james [at] hom:~$ cd tmp/
james [at] hom:~/tmp$ cat badnormpath.py
#!/usr/bin/python

import os.path

print '__file__: %s' % __file__
print 'normpath: %s' % os.path.normpath(__file__)

james [at] hom:~/tmp$ ./badnormpath.py
__file__: ./badnormpath.py
normpath: badnormpath.py
james [at] hom:~/tmp$ ./../tmp/badnormpath.py
__file__: ./../tmp/badnormpath.py
normpath: ../tmp/badnormpath.py
james [at] hom:~/tmp$

----------
components: Library (Lib)
messages: 95189
nosy: purpleidea
severity: normal
status: open
title: os.path.normpath doesn't normalize ../path/something.py
type: behavior
versions: Python 2.6, Python 2.7, Python 3.0

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7315>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 13, 2009, 12:27 PM

Post #2 of 4 (186 views)
Permalink
[issue7315] os.path.normpath doesn't normalize ../path/something.py [In reply to]

Georg Brandl <georg [at] python> added the comment:

normpath() doesn't look at the file system. It cannot know that your
current directory is ~/tmp, so it cannot know that . and ../tmp are the
same directory.

----------
nosy: +georg.brandl
resolution: -> wont fix
status: open -> closed

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7315>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 13, 2009, 1:44 PM

Post #3 of 4 (186 views)
Permalink
[issue7315] os.path.normpath doesn't normalize ../path/something.py [In reply to]

James <purpleidea [at] gmail> added the comment:

i looked at the source for normpath.
i know that it doesn't look at the filesystem.
assuming you're not currently sitting at the root directory, in all?
cases ../xyz brings you back to where you started. we expect normpath to
clean up a path string, collapsing '../' (as documented), perhaps either
the docs should state otherwise, or this should collapse dirs as long as
they are present in the path given to it ?

as an aside is there any reason why normpath shouldn't look at the
filesystem and decide if it makes sense to collapse a leading '../' when
this case arises ?

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7315>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 14, 2009, 3:45 AM

Post #4 of 4 (180 views)
Permalink
[issue7315] os.path.normpath doesn't normalize ../path/something.py [In reply to]

Georg Brandl <georg [at] python> added the comment:

If your current directory is (e.g.) /home/user, then ../xyz will not
"bring you back" to it. (xyz/.. would.)

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7315>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.