[Python-checkins] r45925 - in python/trunk: Lib/tempfile.py Lib/test/test_os.py Misc/NEWS Modules/posixmodule.c

M.-A. Lemburg mal at egenix.com
Sun May 7 15:30:00 CEST 2006


Martin v. Löwis wrote:
> M.-A. Lemburg wrote:
>>> +        except WindowsError, e:
>>> +            if e.errno == 183: # ERROR_ALREADY_EXISTS
>>> +                continue # try again
>>> +            raise
>>>          except OSError, e:
>>>              if e.errno == _errno.EEXIST:
>>>                  continue # try again
>> Rather than adding new cases for the changed error codes,
>> wouldn't it be better and more backwards compatible to
>> add aliases to the errno module for e.g. ERROR_ALREADY_EXISTS ?!
> 
> It might be better for some reason, but I cannot see how
> it would be more backwards compatible to define symbolic
> constant ERROR_ALREADY_EXISTS, with the value 183.

That's not what I meant: in errno, many WSA windows error codes
are aliased to their corresponding Unix error codes to
enhance portability across platforms.

I don't know where ERROR_ALREADY_EXISTS is defined and
how it relates to the WSA codes, but since EEXIST doesn't
have a corresponding, it's probably a good idea to alias
EEXIST to ERROR_ALREADY_EXISTS and use that in tempfile.py
for both Windows and Unix instead of adding another except
clause.

> In what sense would the backwards compatibility be improved ?!

I suppose that the code used to raise an OSError with
EEXIST error code before the change to use Win32 APIs
on Windows.

With the alias, existing code looking for EEXIST on Windows
will continue to work without change.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, May 07 2006)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::


More information about the Python-checkins mailing list