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
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
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
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.
'''
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
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,
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
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):
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
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.
--
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
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
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
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.
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
'''
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
16 matches
Mail list logo