[MERGE] Fix a regression on Windows which doesn't allow listing the empty list of files in a file

John Arbash Meinel john at arbash-meinel.com
Fri Aug 8 13:20:50 BST 2008


John Arbash Meinel has voted resubmit.
Status is now: Resubmit
Comment:
I think this is actually the wrong fix. There are comments and codepaths 
in the osutils.py code that make it clear "walkdirs(file)" should not be 
an error.

         try:
             names = sorted(_listdir(top))
         except OSError, e:
             if getattr(e, 'errno', None) == errno.ENOTDIR:
                 # We have been asked to examine a file, this is fine.
                 pass
             else:
                 raise

The problem is that we don't get OSError on Windows we get:
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "c:\Python25\Lib\site-packages\bzrlib\osutils.py", line 1162, in 
walkdirs
     for name in sorted(_listdir(top)):
WindowsError: [Error 267] The directory name is invalid: 
u'pygtk.pyc\\*.*'

according to pywin32,
ERROR_DIRECTORY = 267

I think we just need to add an

WIN32_ERROR_DIRECTORY = 267
...

>>> e
WindowsError(267, 'The directory name is invalid')
>>> e.errno
22
>>> e.winerror
267

Interestingly enough 22 == ENOTDIR

So we might be able to get away with:

except (OSError, WindowsError), e:

I believe some versions of python changed the meaning of 
WindowsError.errno, but the latest releases of 2.4 and 2.5 both use 
errno == POSIX errno, and winerrno = windows error code.

We are probably missing tests for this behavior in test_osutils.py, we 
should try to have them for the 'optimized' code paths as well. 
(_walkdirs_utf8 et al)

For details, see: 
http://bundlebuggy.aaronbentley.com/project/bzr/request/%3C489ACEB7.1010503%40gmail.com%3E
Project: Bazaar



More information about the bazaar mailing list