I'm looking for some suggestions on how to detect exceptions raised during common types of file access (os, shutil, codecs, etc.) on a cross-platform basis. I'm looking for feedback relative to Python 2.6 and 2.7 but would also appreciate hearing of any Python 3.x specific behaviors.
Under Python 2.6 for Windows, we're trapping file activity exceptions via the following: except ( WindowsError, IOError ): According to the Exception Hierarchy on this page[1] (and snipped below), I suspect that most/all(?) of my file access exceptions "should" derive from EnvironmentErrors. In order to make our code more portable, should we trap EnvironmentError, IOError, OSError, AND WindowsErrors or is that too broad? | +-- EnvironmentError | | +-- IOError | | +-- OSError | | +-- WindowsError (Windows) | | +-- VMSError (VMS) Part of my confusion/discomfort is the fact that Windows errors are not mapped back to the OSError exception, but instead exist in their own subclass. I'm curious what makes Windows file access so special that it needs its own custom exception class? Thank you, Malcolm [1] http://docs.python.org/library/exceptions.html
-- http://mail.python.org/mailman/listinfo/python-list