UNC paths support broken on Windows98
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Bazaar |
Fix Released
|
Low
|
Alexander Belchenko |
Bug Description
Despite the fact I've added support for Windows 98 today I found the bug with UNC path handling.
Running any command om Windows 98 that use UNC path location as argument (e.g. branch or checkout command) and there is problem:
bzr arguments: [u'branch', u'\\\\HOST\
looking for plugins in D:\USER\
Plugin name __init__ already loaded
Plugin name __init__ already loaded
looking for plugins in C:/WINDOWS/
encoding stdout as sys.stdout encoding 'cp866'
Traceback (most recent call last):
File "D:\USER\
return run_bzr(argv)
File "D:\USER\
ret = run(*run_argv)
File "D:\USER\
return self.run(
File "D:\USER\
br_from = Branch.
File "D:\USER\
return control.
File "D:\USER\
format = BranchFormat.
File "D:\USER\
raise NotBranchError(
NotBranchError: Not a branch: D:/HOST/
The problem itself in the python, in nt._getfullpathname function. This function used in implementation of os.path.abspath() that used by bzr during converting localpath to URL.
Illustration of problem:
D:\USER\
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> platform.platform()
'Windows-
>>> import os
>>> os.path.
'\\\\HOST\\path'
>>> os.path.
'D:\\HOST\\path'
>>>
I.e. on Windows98 abspath don't like forward slashes.
Changed in bzr: | |
status: | Confirmed → Fix Released |
Actually os.path.abspath is broken on Windows 98, because it rely on native Win32 API function GetFullPathName. And this function not only don't like '/' in UNC path but also don't support unicode filenames properly. So the best solution so far is to switch to alternate implementation of abspath on win98.
Excerpt from ntpath.py:
# Return an absolute path.
try:
from nt import _getfullpathname
except ImportError: # not running on Windows - mock up something sensible
def abspath(path):
"""Return the absolute version of a path."""
if not isabs(path):
path = join(os.getcwd(), path)
return normpath(path)
else: # use native Windows method on Windows
def abspath(path):
"""Return the absolute version of a path."""
if path: # Empty path must return current working directory.
path = _getfullpathnam e(path)
pass # Bad path - return unchanged.
try:
except WindowsError:
else:
path = os.getcwd()
return normpath(path)
The branch when ImportError occurs should be used on Windows 98 instead of native methods.