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

"Martin v. Löwis" martin at v.loewis.de
Sun May 7 18:19:21 CEST 2006


M.-A. Lemburg wrote:
> 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.

Can you please explain how such aliasing could work? errno can
only have one value: either 183, or 17, but not both.

> 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.

ERROR_ALREADY_EXISTS is defined in winerror.h, and it is possible
result of the GetLastError system call.

I don't understand the fragment "but since EEXIST doesn't have a
corresponding": A corresponding what?

You mean, I should define EEXIST to have the value of 183, instead
of having the value 17? That's certainly not a good idea. First,
EEXIST should map to either ERROR_FILE_EXISTS (80) or
ERROR_ALREADY_EXISTS (183), depending on context. Furthermore,
the C library will still put its own value (17) into errno.

>> 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.

Correct. It now raises WindowsError instead.

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

I still cannot see how this could work, at least not in a way
that wouldn't break something else.

Regards,
Martin



More information about the Python-checkins mailing list