[MERGE] Bugfix #68124: Allow import plugins from zip archives

Aaron Bentley aaron.bentley at utoronto.ca
Tue Jan 2 15:45:16 GMT 2007


Alexander Belchenko wrote:
>>Alexander Belchenko wrote:
>>
>>>No. Inside zip always used '/'.
>>
>>So then doing os.path.split is incorrect, because it depends on os.sep,
>>right?
> 
> 
> Actually, no:
> 
>  Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on win32
>  Type "help", "copyright", "credits" or "license" for more information.
>  >>> a = 'a\\b\\c'
>  >>> b = 'a/b/c'
>  >>> import os
>  >>> os.path.split(a)
>  ('a\\b', 'c')
>  >>> os.path.split(b)
>  ('a/b', 'c')
>  >>>
> 
> As you could see this function don't depends on os.sep.

When we're dealing with '/'-delimited paths, we use the functions in 
osutils.

I don't know why os.path.split('a/b/c') works on Windows, but I assume 
it's Windows-specific compatibility code.

Certainly, it behaves differently on Windows vs Unix:
 >>> a = 'a\\b\\c'
 >>> os.path.split(a)
('', 'a\\b\\c')

AFAIK, the only OSes that used something other than '/' are Windows, DOS 
and MacOS 1-9.  So it's unlikely that your code will run on a platform 
where '/' isn't supported as a separator.

But still, I think using osutils makes the code clearly correct, whereas 
os.path makes it suspect.

Aaron




More information about the bazaar mailing list