[MERGE][0.15] handle ERROR_DIRECTORY for win32 "bzr status filename"

Alexander Belchenko bialix at ukr.net
Tue Mar 20 06:29:57 GMT 2007


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

John Arbash Meinel пишет:
> Andrew Bennetts wrote:
>> John Arbash Meinel wrote:
>> [...]
>>> We are fortunate that WindowsError is a child of OSError. I'm also not
>>> sure how Wouter's patch was working, since I can't find an e.winerror
>>> member. Maybe it is a python2.5 versus 2.4 thing.
>> Yes, the winerror attribute is new in 2.5 (but has the same value as the errno
>> attribute in 2.4, and errno in 2.5 now has a value corresponding to errno.h).
>> This is likely to mean that working with both 2.5 and 2.4 is a little awkward.
> 
> Well, if 2.5 has a value from errno.h (like ENOTDIR) it will work just
> fine. If it has something like None, then we have to worry.
> 
> The other possibility is to use
> 
> e_errno = getattr(e, 'errno', None)
> e_winerror = getattr(e, 'winerror', None)
> 
> if e_errno in (...) or e_winerror in (...)
> 
> Something like that should make it reasonably easy, but I would need
> someone to test a bit to see what actual errors python 2.5 is raising.

Python 2.5 @ Windows XP

C:\work\Bazaar\sandbox\bzr.dev>type test_winerror.py
import os
try:
    os.listdir('bzr')
except OSError, e:
    print 'e:', e
    print 'dir:', dir(e)
    print 'errno:', e.errno
    print 'winerror:', e.winerror

C:\work\Bazaar\sandbox\bzr.dev>test_winerror.py
e: [Error 22] : 'bzr/*.*'
dir: ['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', '__getitem__',
'__hash__', '__init__',
'__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__str__',
'args', 'errno', 'filename', 'message', 'strerror', 'winerror']
errno: 22
winerror: 267


[µ]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF/39lzYr338mxwCURAmMSAJ4ivmWMa+JMohfmLMXXU9ImjpT99gCfYG8O
bEjWwoiOu+zxoBUEhmnnzrw=
=HhGd
-----END PGP SIGNATURE-----



More information about the bazaar mailing list