This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: os.ftruncate raises IOError instead of OSError
Type: behavior Stage:
Components: Interpreter Core Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, kristjan.jonsson
Priority: normal Keywords: patch

Created on 2009-01-15 23:01 by kristjan.jonsson, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
ftruncate.patch kristjan.jonsson, 2009-01-15 23:01
Messages (3)
msg79925 - (view) Author: Kristján Valur Jónsson (kristjan.jonsson) * (Python committer) Date: 2009-01-15 23:00
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.
msg79928 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-01-16 01:57
+1 for renaming. Although it looks like it has been this way since the
beginning, the examples of os.ftruncate I found didn't seem to rely on
this behavior. In addition, I think this is a small price to pay for
good consistency. [1]

[1] http://google.com/codesearch?hl=en&sa=N&q=lang:python+os.ftruncate
msg80165 - (view) Author: Kristján Valur Jónsson (kristjan.jonsson) * (Python committer) Date: 2009-01-19 13:10
submitted as r68763
History
Date User Action Args
2022-04-11 14:56:44adminsetgithub: 49207
2009-01-19 13:10:55kristjan.jonssonsetstatus: open -> closed
keywords: patch, patch
resolution: fixed
messages: + msg80165
2009-01-16 01:57:42benjamin.petersonsetkeywords: patch, patch
nosy: + benjamin.peterson
messages: + msg79928
2009-01-15 23:01:01kristjan.jonssoncreate