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.

Title: Why do we have os.truncate() and os.ftruncate() whereas os.truncate() accepts a file descriptor?
Type: Stage: resolved
Components: Versions: Python 3.3
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, larry, vstinner
Priority: deferred blocker Keywords:

Created on 2012-08-03 12:13 by vstinner, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (4)
msg167311 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2012-08-03 12:13
posix_truncate() accepts a file descriptor, so os.ftruncate() can be removed from Python 3.3.

    memset(&path, 0, sizeof(path));
    path.function_name = "truncate";
    path.allow_fd = 1;
    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&O&:truncate", keywords,
                                     path_converter, &path,
                                     _parse_off_t, &length))
        return NULL;
msg167317 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2012-08-03 12:27
To check if os.truncate() supports file description, "os.truncate in os.supports_fd" checek can be used.
msg167342 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2012-08-03 18:57
Because both functions were available in 3.2, and we can't remove old functions without a full deprecation cycle.
msg167364 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2012-08-03 21:39
Oh, I see: os.ftruncate() is present in Python 3.2; but os.truncate()
was added to Python 3.3. Ok, it's an excellent reason to not remove
os.ftruncate() ;-)
Date User Action Args
2022-04-11 14:57:33adminsetgithub: 59752
2012-08-03 21:39:28vstinnersetmessages: + msg167364
2012-08-03 18:57:36larrysetstatus: open -> closed
resolution: wont fix
messages: + msg167342

stage: resolved
2012-08-03 12:27:08vstinnersetmessages: + msg167317
2012-08-03 12:26:11vstinnersetnosy: + georg.brandl
2012-08-03 12:13:03vstinnercreate