On 28/01/2009 6:52 PM, Glenn Linderman wrote:
open("c:\abc","rb")This simple one-line script, produces errno 22 on Python 2.6, but errno 2 on Python 2.5.2 Is this an unintentional regression? Or is this an intentional bug fix? The file doesn't exist (errno 2) but I guess on Windows it is also somewhat an invalid file name (errno 22). Yes, I'm aware that \a is ASCII 007. Using a valid, non-existent file name produces errno 2 on both versions.
I think you will find that in Python 2.6, the exception object has both 'errno' and 'winerror' attributes, which more accurately reflect the source of the 2 different error numbers, where Python 2.5 would often store the windows error number in the errno field, leading to what you see.
I tend to use something like "winerror = getattr(e, 'winerror', e.errno)" to handle both cases...
Cheers, Mark -- http://mail.python.org/mailman/listinfo/python-list
