You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
assignee=Noneclosed_at=<Date2020-02-21.18:01:25.803>created_at=<Date2019-02-09.13:36:22.181>labels= ['3.9', 'expert-IO']
title='io.BufferedReader.writabe is False, but io.BufferedReader.truncate does not raise OSError'updated_at=<Date2020-02-22.07:19:05.846>user='https://github.com/steverpalmer'
An io.BUfferedReader object has an (inherited) writable method that returns False. io.IOBase states in the description of the writable method that "If False, write() and truncate() will raise OSError."
However, if the BufferedReader object is constructed from a writabe io.RawIOBase object, then the truncate does not raise the exception.
Looking at _pyio.py file, the truncate method in the _BufferedIOMixin wrapper class delegates the truncation to it's raw attribute. If the raw element permits the truncation, then it will proceed regardless of the writable state of the wrapper class. I'd suggest that modifying the truncate method in _BufferedIOMixin to raise OSError (or Unsupported) if not self.writable() could fix this problem.