Akima added the comment:

As eryksun pointed out, I created this bug report to report on one issue; that 
\\server\share isn't being consider absolute by os.path.isabs when it should be 
considered absolute.

I found this bug when I was writing a basic config file parsing module.  One of 
the options in the config (named log_dir) required an absolute path to a 
directory where my program could dump log files.  It has to be absolute because 
the working directory of the program changes.  A user entered a path 
\\pollux\logs as the log_dir value in their config file and my program rejected 
it informing the user that it wasn't absolute (because I checked the path using 
isabs).  I've worked around this bug in my program, but it is clearly a problem 
that needs fixing.

Steve: with regard to what isabs should return when given the string 
r"\\server": does it really matter whether it returns True or False?  As you 
said; \\server isn't a real path.  It's invalid.  If you ask python if it's 
absolute (using os.path.isabs) and you expect a boolean response, no matter 
whether the response is True or False, the response will be meaningless.  
Consider this:

Python 3.2.3 (default, Feb 27 2014, 21:31:18) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os.path
>>> os.path.isabs("&monkeyfart!££")
False
>>> 

I just asked isabs if "&monkeyfart!££" was absolute and it told me it's not an 
absolute path, it's relative!  It's infact, not even a path.  There is no 
"os.path.isrelative" function.  If we want to know if a path is relative we use 
the isabs function and decide the path is relative if the result is False.  If 
you give the function a junk-string which isn't even a path (eg \\server  or  
&monkeyfart!££ ) then you can only expect a junk response.  If we decide that 
all invalid paths provide to isabs should return False then what we are saying 
is all invalid paths provided to isabs should be considered relative paths.  
What use is that to anyone?  Really, the programmer should ensure that the path 
is valid before trying to find out if it's relative or absolute.

To summarize: I think it's important that isabs works correctly when given a 
*valid* path (like \\server\share).  When it's given a string which is an 
invalid path (like \\server), its behaviour should be undefined.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22302>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to