[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
Tue May 9 00:12:53 CEST 2006


M.-A. Lemburg wrote:
> I don't understand this part.
> 
> Couldn't we write a small tool that extracts the mapping
> from the Windows APIs ?

That would be possible, yes.

> 
> Or just use this mapping from ReactOS which was probably
> created by doing just that:
> 
> http://www.reactos.org/generated/doxygen/de/d02/doserrmap_8h-source.html

I don't know how this table was generated (although I doubt it was
generated that way); in any case, there are many such tables
to chose from, e.g. the MKS table:

http://www.mkssoftware.com/docs/man3/api_intro.3.asp

or the Microsoft table:

http://pool.cern.ch/coral/currentReleaseDoc/doxygen/dosmap_8cpp-source.html

or the Tcl table

http://www.openmash.org/lxr/source/win/tclWinError.c?c=tcl8.3

or the PostgreSQL table

http://projects.commandprompt.com/public/pgsql/browser/trunk/pgsql/src/backend/port/win32/error.c?rev=23279

I haven't checked how they differ, however, we have to create
one such table as the "official" Python table on how to map
Win32 errors to "DOS errors".

>> - code that currently catches WindowsError and looks into
>>   the errno value would break, as that would not contain
>>   Win32 error codes anymore.
> 
> I don't think that there is any such code, since the APIs
> you changed used to raise OSErrors.

WindowsError was added in r14422, with this:

r14422 | guido | 2000-02-17 16:12:01 +0100 (Do, 17 Feb 2000) | 2 lines
Geänderte Pfade:
   M /python/trunk/Lib/exceptions.py

Added WindowsError, for Mark Hammond's extensions.

It had been using this other definition of errno (i.e. Win32 error
codes) since day 1. Previous releases of Python had raised WindowsError
under various circumstances. For example, PC/_winreg.c raises
WindowsError since r14820 (when _winreg was imported into Python).

> What I'm after is that code relying on the usage of OSError
> will continue to work and at the same time improve the
> portability of code using e.g. os.mkdir().

That would be possible with my proposed change. The only breakage
would occur with code that catches WindowsError and expects errno
to contain Win32 error codes.

As something will break no matter what approach is taken, I think
that might be the solution that causes the least damage.

Regards,
Martin



More information about the Python-checkins mailing list