Issue 4957: os.ftruncate raises IOError instead of OSError (original) (raw)

I stumbled upon this. Of all the errors in the posixmodule.c, ftruncate alone raises an IOError upon failure. All the others raise OSError.
This behaviour is not documented. However, the os module documentation says>

Note All functions in this module raise OSError in the case of invalid or inaccessible file names and paths, or other arguments that have the correct type, but are not accepted by the operating system.

This came to light when I added tests to verify that exceptions were being raised by invalid file descriptors.

I propose to fix this to comply with the docs.