[docs] os.ftruncate documentation error

Richard Ipsum richardipsum at fastmail.co.uk
Sun Feb 12 08:53:11 EST 2017


Hi folks,

The documentation for os.ftruncate seems a little misleading,
for both 2.7[1] and 3.6[2] the docs for os.ftruncate say,

"Truncate the file corresponding to file descriptor fd, so that it is at
most length bytes in size."

os.ftruncate is implemented on Unix as a call to ftruncate(2), the man
page for which states:

"The truncate() and ftruncate() functions cause the regular file named
by path or referenced by fd to be truncated to a size of precisely
length bytes."

The distinction between 'at most' and 'precisely' is quite an important
one,
it's quite possible that there is some difference in behaviour on
certain platforms,
but if that is the case then I think the docs ought to make that clear.

I'll be quite happy to submit a patch to make the docs clearer,
if I can get a little direction on what sort of change would be best.

Hope this helps,
thanks,
Richard Ipsum

[1]:
https://docs.python.org/2.7/library/os.html?highlight=os.ftruncate#os.ftruncate
[2]:
https://docs.python.org/3.6/library/os.html?highlight=os.ftruncate#os.ftruncate


More information about the docs mailing list