[issue23093] repr() on detached stream objects fails

Serhiy Storchaka report at bugs.python.org
Sat Dec 20 17:42:27 CET 2014


Serhiy Storchaka added the comment:

The issue is still here.

>>> f = open('/dev/null')
>>> f
<_io.TextIOWrapper name='/dev/null' mode='r' encoding='UTF-8'>
>>> f.buffer.detach()
<_io.FileIO name='/dev/null' mode='rb' closefd=True>
>>> f
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: raw stream has been detached

Python implementation works.

>>> import _pyio
>>> f = _pyio.open('/dev/null')
>>> f
<_pyio.TextIOWrapper name='/dev/null' mode='r' encoding='UTF-8'>
>>> f.buffer.detach()
<_io.FileIO name='/dev/null' mode='rb' closefd=True>
>>> f
<_pyio.TextIOWrapper mode='r' encoding='UTF-8'>
>>> f = _pyio.open('/dev/null')
>>> f.detach()
<_pyio.BufferedReader name='/dev/null'>
>>> f
<_pyio.TextIOWrapper mode='r' encoding='UTF-8'>
>>> f = _pyio.open('/dev/null', 'rb')
>>> f
<_pyio.BufferedReader name='/dev/null'>
>>> f.detach()
<_io.FileIO name='/dev/null' mode='rb' closefd=True>
>>> f
<_pyio.BufferedReader>

I would be good to make Python and C implementation match.

----------
nosy: +benjamin.peterson, hynek, pitrou, serhiy.storchaka, stutzbach
stage:  -> patch review
versions: +Python 2.7, Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23093>
_______________________________________


More information about the Python-bugs-list mailing list