[issue23093] repr() on detached stream objects fails

2014-12-21 Thread Martin Panter

Martin Panter added the comment:

Here is patch v2, which ignores any exception derived from the Exception base 
class when reading the self.name etc properties. I’m interested what people 
think of this approach.

--
Added file: http://bugs.python.org/file37523/detach-indep.v2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23093
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23093] repr() on detached stream objects fails

2014-12-21 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

It looks reasonable to me.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23093
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23093] repr() on detached stream objects fails

2014-12-21 Thread Roundup Robot

Roundup Robot added the comment:

New changeset f3ff3e424b6f by Benjamin Peterson in branch '3.4':
allow more operations to work on detached streams (closes #23093)
https://hg.python.org/cpython/rev/f3ff3e424b6f

New changeset afa8d8ab0937 by Benjamin Peterson in branch '2.7':
allow more operations to work on detached streams (closes #23093)
https://hg.python.org/cpython/rev/afa8d8ab0937

New changeset f2cfa8a348dd by Benjamin Peterson in branch 'default':
merge 3.4 (#23093)
https://hg.python.org/cpython/rev/f2cfa8a348dd

--
nosy: +python-dev
resolution:  - fixed
stage: patch review - resolved
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23093
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23093] repr() on detached stream objects fails

2014-12-20 Thread Martin Panter

New submission from Martin Panter:

Patch to fix the underlying issue I mentioned in msg230955. After calling 
detach() on one of the BufferedIOBase wrappers or a TextIOWrapper, most 
operations will raise an exception. My patch ensures the following operations 
are still usable, because they are documented and it doesn’t make sense to 
disable them:

repr(stream)
stream.encoding
stream.errors
stream.line_buffering

--
components: IO
files: detach-indep.patch
keywords: patch
messages: 232971
nosy: vadmium
priority: normal
severity: normal
status: open
title: repr() on detached stream objects fails
type: behavior
versions: Python 3.4
Added file: http://bugs.python.org/file37516/detach-indep.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23093
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23093] repr() on detached stream objects fails

2014-12-20 Thread Serhiy Storchaka

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 rep...@bugs.python.org
http://bugs.python.org/issue23093
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23093] repr() on detached stream objects fails

2014-12-20 Thread Martin Panter

Martin Panter added the comment:

Damn, detaching the intermediate buffered stream is a bit more awkward. The 
difference between the “io” and “_pyio” implementations boils down to:

* io.BufferedReader/Writer/RWPair.name properties raise a ValueError if the 
stream is detached
* _pyio._BufferedIOMixin.name property returns “self.raw.name”. When detached, 
“self.raw” is None, so this causes an AttributeError.

This is significant because io.TextIOWrapper.__repr__() only handles 
AttributeError when accessing “self.buffer.name”. The best option that I can 
think of to fix this is to make all the repr() implementations handle this 
ValueError exception.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23093
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com