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

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Gabriel Genellina
En Sat, 21 Mar 2009 23:58:07 -0300, lamber...@corning.com 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

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Benjamin Peterson
lambertdw at 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 R. David Murray
Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Sat, 21 Mar 2009 23:58:07 -0300, lamber...@corning.com escribió: import re import io 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

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Gabriel Genellina
En Sun, 22 Mar 2009 15:11:37 -0300, R. David Murray rdmur...@bitdance.com escribió: Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Sat, 21 Mar 2009 23:58:07 -0300, lamber...@corning.com escribió: class file(io.TextIOWrapper): ''' Enhance TextIO. Streams have many sources,

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Benjamin Peterson
Gabriel Genellina gagsl-py2 at 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

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread R. David Murray
Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Sun, 22 Mar 2009 15:11:37 -0300, R. David Murray rdmur...@bitdance.com escribió: Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Sat, 21 Mar 2009 23:58:07 -0300, lamber...@corning.com escribió: class file(io.TextIOWrapper):

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Gabriel Genellina
En Sun, 22 Mar 2009 16:37:31 -0300, Benjamin Peterson benja...@python.org escribió: Gabriel Genellina gagsl-py2 at 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

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Benjamin Peterson
Gabriel Genellina gagsl-py2 at 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. --

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Gabriel Genellina
En Sun, 22 Mar 2009 19:12:13 -0300, Benjamin Peterson benja...@python.org escribió: Gabriel Genellina gagsl-py2 at 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

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Benjamin Peterson
Gabriel Genellina gagsl-py2 at 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

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 Scott David Daniels
Gabriel Genellina wrote: En Sun, 22 Mar 2009 19:12:13 -0300, Benjamin Peterson benja...@python.org escribió: Gabriel Genellina gagsl-py2 at 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.

Re: python 3, subclassing TextIOWrapper.

2009-03-22 Thread Gabriel Genellina
En Sun, 22 Mar 2009 21:03:38 -0300, Scott David Daniels scott.dani...@acm.org escribió: Gabriel Genellina wrote: En Sun, 22 Mar 2009 19:12:13 -0300, Benjamin Peterson benja...@python.org escribió: Gabriel Genellina gagsl-py2 at yahoo.com.ar writes: The undocumented behavior is relying on

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