classification
Title: Avoid raising OverflowError in truncate() if possible
Type: enhancement Stage: needs patch
Components: IO, Library (Lib) Versions: Python 3.7
process
Status: open Resolution:
Dependencies: 29852 Superseder:
Assigned To: Nosy List: Oren Milman, benjamin.peterson, haypo, serhiy.storchaka, stutzbach
Priority: normal Keywords:

Created on 2017-03-15 15:11 by serhiy.storchaka, last changed 2017-03-19 11:35 by serhiy.storchaka.

Messages (2)
msg289677 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-15 15:11
os.truncate(), os.ftruncate() and truncate() methods of file-like objects raise OverflowError when the argument is out of ranger of certain C type. It would be better to extend the behavior of small integers to large integers. ValueError is raised for negative integers and it should be raised for negative integers out of range. Values larger than the current size should be ignored in BytesIO.truncate() and StringIO.truncate(). BytesIO.truncate() and StringIO.truncate() should never raise OverflowError. Since the behavior of underlying OS functions is OS and FS depended, OverflowError can be raised for large integers in os.truncate(), os.ftruncate() and FileIO.truncate().
msg289848 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-19 11:35
Issue29852 is not strict dependency, but it may make the solution of this issue simpler.
History
Date User Action Args
2017-03-19 11:35:57serhiy.storchakasetdependencies: + Argument Clinic: add common converter to Py_ssize_t that accepts None
messages: + msg289848
2017-03-17 08:36:16serhiy.storchakalinkissue29833 dependencies
2017-03-15 15:12:46hayposetnosy: + haypo
2017-03-15 15:12:27serhiy.storchakasetnosy: + Oren Milman
2017-03-15 15:11:06serhiy.storchakacreate