[Python-Dev] Should I/O object wrappers close their underlying buffer when deleted? (original) (raw)
Alexandre Vassalotti alexandre at peadrop.com
Sun Apr 5 08:28:52 CEST 2009
- Previous message: [Python-Dev] BufferedReader.peek() ignores its argument
- Next message: [Python-Dev] Generator methods - "what's next" ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello,
I would like to call to your attention the following behavior of TextIOWrapper:
import io def test(buf): textio = io.TextIOWrapper(buf) buf = io.BytesIO() test(buf) print(buf.closed) # This prints True currently
The problem here is TextIOWrapper closes its buffer when deleted. BufferedRWPair behalves similarly. The solution is simply to override the del method of TextIOWrapper inherited from IOBase.
-- Alexandre
- Previous message: [Python-Dev] BufferedReader.peek() ignores its argument
- Next message: [Python-Dev] Generator methods - "what's next" ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]