[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
Sat Aug 9 15:07:59 BST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mark Hammond wrote:
> Ack - this is a dupe for the other thread I started (although I picked up
> one more error) - I should have made sure I caught up with mail before
> sending...
> 
> John writes:
> 
>>>>> e
>> WindowsError(267, 'The directory name is invalid')
>>>>> e.errno
>> 22
>>>>> e.winerror
>> 267
>>
>> Interestingly enough 22 == ENOTDIR
> 
> Not for me on Windows:
> 
>>>> errno.ENOTDIR
> 20
>>>> errno.EINVAL
> 22
> 
>> So we might be able to get away with:
>>
>> except (OSError, WindowsError), e:
> 
> Note that EnvironmentError is also suitable - it's a base for WindowsError,
> OSError and even IOError.
> 
>> 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.
> 
> subtly, I don't think they promise POXIS errnos, just the errno set by the
> CRT - so we are still at the whim of MS.  The CRT even documents errno is
> set to EINVAL in some cases.
> 
> Cheers,
> 
> Mark.

Sure, I didn't actually probe the errno.Exxxx values, and just guessed
from memory. Obviously, we are back into the same problem. :(

By the way +1 on an osutils.listdir() function rather than using
os.listdir().

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkidpL8ACgkQJdeBCYSNAAOhkQCdHd/TxVvOyok99z/ki+WkmTgG
2OEAn31MWuctN6ybZJSyS9MMKFHwuQCf
=GM+P
-----END PGP SIGNATURE-----



More information about the bazaar mailing list