UNC paths support broken on Windows98

Bug #84728 reported by Alexander Belchenko
2
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\\D\\Bazaar\\sandbox\\integration\\']
looking for plugins in D:\USER\python\bzr\bzr.dev\bzrlib\plugins
Plugin name __init__ already loaded
Plugin name __init__ already loaded
looking for plugins in C:/WINDOWS/Application Data/bazaar/2.0/plugins
encoding stdout as sys.stdout encoding 'cp866'
Traceback (most recent call last):
  File "D:\USER\python\bzr\bzr.dev\bzrlib\commands.py", line 650, in run_bzr_catch_errors
    return run_bzr(argv)
  File "D:\USER\python\bzr\bzr.dev\bzrlib\commands.py", line 612, in run_bzr
    ret = run(*run_argv)
  File "D:\USER\python\bzr\bzr.dev\bzrlib\commands.py", line 304, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "D:\USER\python\bzr\bzr.dev\bzrlib\builtins.py", line 750, in run
    br_from = Branch.open(from_location)
  File "D:\USER\python\bzr\bzr.dev\bzrlib\branch.py", line 122, in open
    return control.open_branch(_unsupported)
  File "D:\USER\python\bzr\bzr.dev\bzrlib\bzrdir.py", line 1021, in open_branch
    format = BranchFormat.find_format(self)
  File "D:\USER\python\bzr\bzr.dev\bzrlib\branch.py", line 685, in find_format
    raise NotBranchError(path=transport.base)
NotBranchError: Not a branch: D:/HOST/D/Bazaar/sandbox/integration/.bzr/branch/

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\bzr>python
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-98-4.10.2222-A'
>>> import os
>>> os.path.abspath('\\\\HOST\path')
'\\\\HOST\\path'
>>> os.path.abspath('//HOST/path')
'D:\\HOST\\path'
>>>

I.e. on Windows98 abspath don't like forward slashes.

Tags: win32 win98
Revision history for this message
Alexander Belchenko (bialix) wrote :

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.
            try:
                path = _getfullpathname(path)
            except WindowsError:
                pass # Bad path - return unchanged.
        else:
            path = os.getcwd()
        return normpath(path)

The branch when ImportError occurs should be used on Windows 98 instead of native methods.

Changed in bzr:
assignee: nobody → bialix
importance: Undecided → Low
status: Unconfirmed → Confirmed
Changed in bzr:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.