Re: python 3, subclassing TextIOWrapper.

2009-03-23 Thread lambertdw
For D. Murray's suggestion---I think that we programmers have to learn the idiom. We don't always control open, such as subprocess.Popen(). Thank you. I hope these thoughts help with issue 5513 and the related questions to follow about complete removal of file in python3. Opening the file in bin

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Gabriel Genellina
En Sun, 22 Mar 2009 21:03:38 -0300, Scott David Daniels escribió: Gabriel Genellina wrote: En Sun, 22 Mar 2009 19:12:13 -0300, Benjamin Peterson escribió: Gabriel Genellina yahoo.com.ar> writes: The undocumented behavior is relying on the open() builtin to return a BufferedReader for a bi

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Scott David Daniels
Gabriel Genellina wrote: En Sun, 22 Mar 2009 19:12:13 -0300, Benjamin Peterson escribió: Gabriel Genellina yahoo.com.ar> writes: The undocumented behavior is relying on the open() builtin to return a BufferedReader for a binary file. I don't see the problem. open() will return some Buffered

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread lambertdw
Return value of open undocumented? The return value of open() is a "stream", according to http://docs.python.org/dev/py3k/library/io.html#module-io Seems like time for a bug report. -- http://mail.python.org/mailman/listinfo/python-list

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Benjamin Peterson
Gabriel Genellina yahoo.com.ar> schrieb: > > How do you know? AFAIK, the return value of open() is completely > undocumented: > http://docs.python.org/3.0/library/functions.html#open > And if you open the file in text mode, the return value isn't a > BufferedIOBase. Oh, I see. I should chan

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Gabriel Genellina
En Sun, 22 Mar 2009 19:12:13 -0300, Benjamin Peterson escribió: Gabriel Genellina yahoo.com.ar> writes: The undocumented behavior is relying on the open() builtin to return a BufferedReader for a binary file. I don't see the problem. open() will return some BufferedIOBase implmentor, and

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Benjamin Peterson
Gabriel Genellina yahoo.com.ar> writes: > > The undocumented behavior is relying on the open() builtin to return a > BufferedReader for a binary file. I don't see the problem. open() will return some BufferedIOBase implmentor, and that's all that TextIOWrapper needs. -- http://mail.python.

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Gabriel Genellina
En Sun, 22 Mar 2009 16:37:31 -0300, Benjamin Peterson escribió: Gabriel Genellina yahoo.com.ar> writes: There is another alternative that relies on undocumented behaviour: use open to create a *binary* file and wrap the resulting BufferedReader object in your own TextIOWrapper. How is that

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread R. David Murray
"Gabriel Genellina" wrote: > En Sun, 22 Mar 2009 15:11:37 -0300, R. David Murray > escribió: > > "Gabriel Genellina" wrote: > >> En Sat, 21 Mar 2009 23:58:07 -0300, escribió: > >> > > >> > class file(io.TextIOWrapper): > >> > > >> > ''' > >> > Enhance TextIO. Streams have many so

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Benjamin Peterson
Gabriel Genellina yahoo.com.ar> writes: > > There is another alternative that relies on undocumented behaviour: use > open to create a *binary* file and wrap the resulting BufferedReader > object in your own TextIOWrapper. How is that undocumented behavior? TextIOWrapper can wrap any buffer

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Gabriel Genellina
En Sun, 22 Mar 2009 15:11:37 -0300, R. David Murray escribió: "Gabriel Genellina" wrote: En Sat, 21 Mar 2009 23:58:07 -0300, escribió: > > class file(io.TextIOWrapper): > > ''' > Enhance TextIO. Streams have many sources, > a file name is insufficient. > ''' > >

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Scott David Daniels
lamber...@corning.com wrote: ... Removing the comment character to increase the stream reference count fixes the program, at the expense of an extra TextIOWrapper object. But you do create that extra TextIOWrapper, so there should be no crying about its existence. If you rely on the d

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread R. David Murray
"Gabriel Genellina" wrote: > En Sat, 21 Mar 2009 23:58:07 -0300, escribió: > > import re > > import io > > > > class file(io.TextIOWrapper): > > > > ''' > > Enhance TextIO. Streams have many sources, > > a file name is insufficient. > > ''' > > > > def __init__(self,s

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Benjamin Peterson
corning.com> writes: > Please, what is a better way to write the class with > regard to this issue? Set the original TextIOWrapper's buffer to None. -- http://mail.python.org/mailman/listinfo/python-list

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Gabriel Genellina
En Sat, 21 Mar 2009 23:58:07 -0300, escribió: ''' A python 3 question. Presume this code is in file p.py. The program fails. $ python3 p.py ... ValueError: I/O operation on closed file. Removing the comment character to increase the stream reference

python 3, subclassing TextIOWrapper.

2009-03-21 Thread lambertdw
''' A python 3 question. Presume this code is in file p.py. The program fails. $ python3 p.py ... ValueError: I/O operation on closed file. Removing the comment character to increase the stream reference count fixes the program, at the expense of an