[issue10791] Wrapping TextIOWrapper around gzip files

2011-04-07 Thread Jesús Cea Avión
Changes by Jesús Cea Avión j...@jcea.es: -- nosy: +jcea ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10791 ___ ___ Python-bugs-list mailing list

[issue10791] Wrapping TextIOWrapper around gzip files

2011-04-04 Thread Nadeem Vawda
Nadeem Vawda nadeem.va...@gmail.com added the comment: Here's an implementation of read1() that satisfies that condition, along with some relevant unit tests. -- keywords: +patch Added file: http://bugs.python.org/file21531/gzipfile_read1.diff ___

[issue10791] Wrapping TextIOWrapper around gzip files

2011-04-04 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Here's an implementation of read1() that satisfies that condition, along with some relevant unit tests. Something looks fishy: what happens if size is -1 and EOFError is not raised? -- ___ Python

[issue10791] Wrapping TextIOWrapper around gzip files

2011-04-04 Thread Nadeem Vawda
Nadeem Vawda nadeem.va...@gmail.com added the comment: Something looks fishy: what happens if size is -1 and EOFError is not raised? You're right - I missed that possibility. In that case, extrasize and offset get updated incorrectly, which will break subsequent calls to seek() and tell().

[issue10791] Wrapping TextIOWrapper around gzip files

2011-04-04 Thread Roundup Robot
Roundup Robot devnull@devnull added the comment: New changeset 9775d67c9af9 by Antoine Pitrou in branch 'default': Issue #10791: Implement missing method GzipFile.read1(), allowing GzipFile http://hg.python.org/cpython/rev/9775d67c9af9 -- nosy: +python-dev

[issue10791] Wrapping TextIOWrapper around gzip files

2011-04-04 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Patch now committed, thank you! Since the patch adds a new API (GzipFile.read1()), I think it's better not to backport it. -- resolution: - fixed stage: needs patch - committed/rejected status: open - closed type: behavior - feature

[issue10791] Wrapping TextIOWrapper around gzip files

2011-04-03 Thread Nadeem Vawda
Nadeem Vawda nadeem.va...@gmail.com added the comment: Is following change in GzipFile class enough: def read1(self, n): return self.read(n) ? This satisfies TextIOWrapper to run readline correctly. Looks good to me. By the way, BZ2File now works correctly - the fix for

[issue10791] Wrapping TextIOWrapper around gzip files

2011-04-03 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Nadeem Vawda nadeem.va...@gmail.com added the comment: Is following change in GzipFile class enough: def read1(self, n): return self.read(n) ? This satisfies TextIOWrapper to run readline correctly. Looks good to

[issue10791] Wrapping TextIOWrapper around gzip files

2011-04-02 Thread Nadeem Vawda
Changes by Nadeem Vawda nadeem.va...@gmail.com: -- nosy: +nvawda ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10791 ___ ___ Python-bugs-list

[issue10791] Wrapping TextIOWrapper around gzip files

2011-04-01 Thread Filip Gruszczyński
Filip Gruszczyński grusz...@gmail.com added the comment: Is following change in GzipFile class enough: def read1(self, n): return self.read(n) ? This satisfies TextIOWrapper to run readline correctly. -- nosy: +gruszczy ___ Python

[issue10791] Wrapping TextIOWrapper around gzip files

2011-02-23 Thread David Beazley
David Beazley d...@dabeaz.com added the comment: Bump. This is still broken in Python 3.2. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10791 ___

[issue10791] Wrapping TextIOWrapper around gzip files

2011-02-23 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: If a patch had been proposed it probably would have gotten in to 3.2. Maybe someone (perhaps you?) will find the time before 3.2.1. Someone has decided to work on the bz2 rewrite, by the way (issue 5863). --

[issue10791] Wrapping TextIOWrapper around gzip files

2011-02-23 Thread David Beazley
David Beazley d...@dabeaz.com added the comment: If I can find some time, I may took a look at this. I just noticed that similar problems arise trying to wrap TextIOWrapper around the file-like objects returned by urllib.request.urlopen as well. In the big picture, some discussion of what

[issue10791] Wrapping TextIOWrapper around gzip files

2011-02-23 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: What is the problem with Python 3.2? It works correctly here: $ cat bla.txt bli blo bla $ gzip bla.txt $ ./python Python 3.3a0 (unknown, Feb 23 2011, 13:03:50) import gzip, io f =

[issue10791] Wrapping TextIOWrapper around gzip files

2011-02-23 Thread David Beazley
David Beazley d...@dabeaz.com added the comment: Python 3.2 (r32:88445, Feb 20 2011, 21:51:21) [GCC 4.2.1 (Apple Inc. build 5664)] on darwin Type help, copyright, credits or license for more information. import gzip import io f = io.TextIOWrapper(gzip.open(file.gz),encoding='latin-1')

[issue10791] Wrapping TextIOWrapper around gzip files

2011-02-23 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: Yes, a clear definition of the minimum requirements for being wrapped by TextIOWrapper sounds like a necessary thing to have (and I'd be inclined to agree with your assertion, but I didn't work on the IO library :). It would be best to

[issue10791] Wrapping TextIOWrapper around gzip files

2011-02-23 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: Yes, a clear definition of the minimum requirements for being wrapped by TextIOWrapper sounds like a necessary thing to have About that: is read1() argument mandatory or not? In _pyio, BufferedIOBase.read1() argument is optional

[issue10791] Wrapping TextIOWrapper around gzip files

2011-02-23 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: It would probably be ok to fallback on read() when read1() isn't implemented. read1() is supposed to be implemented by all BufferedIO-compliant classes, but in all honesty I don't think it's very useful in practice. It's supposed to be an

[issue10791] Wrapping TextIOWrapper around gzip files

2011-02-23 Thread Alex
Changes by Alex alex.gay...@gmail.com: -- nosy: +alex ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10791 ___ ___ Python-bugs-list mailing list

[issue10791] Wrapping TextIOWrapper around gzip files

2011-01-02 Thread Éric Araujo
Changes by Éric Araujo mer...@netwok.org: -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10791 ___ ___ Python-bugs-list

[issue10791] Wrapping TextIOWrapper around gzip files

2010-12-29 Thread David Beazley
New submission from David Beazley d...@dabeaz.com: Is something like this supposed to work: import gzip import io f = io.TextIOWrapper(gzip.open(foo.gz),encoding='ascii')) Traceback (most recent call last): File stdin, line 1, in module AttributeError: readable In a nutshell--reading a

[issue10791] Wrapping TextIOWrapper around gzip files

2010-12-29 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: Since GZipFile inherits from BufferedIOBase, and TextIOWrapper is supposed to be designed to wrap a BufferedIOBase object, I would say yes it ought to work. On the other hand there may also be a doc error there, since it may be that

[issue10791] Wrapping TextIOWrapper around gzip files

2010-12-29 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: Oops. It only has that inheritance in 3.2. -- versions: -Python 2.7, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10791

[issue10791] Wrapping TextIOWrapper around gzip files

2010-12-29 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: Heh, and 2.7. Fixing versions yet again. -- versions: +Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10791 ___

[issue10791] Wrapping TextIOWrapper around gzip files

2010-12-29 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: This should be easy to fix, if only the readable and writable methods are needed. Do you want to try writing a patch? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10791

[issue10791] Wrapping TextIOWrapper around gzip files

2010-12-29 Thread David Beazley
David Beazley d...@dabeaz.com added the comment: It goes without saying that this also needs to be checked with the bz2 module. A quick check seems to indicate that it has the same problem. While you're at it, maybe someone could add an 'open' function to bz2 to make it symmetrical with gzip

[issue10791] Wrapping TextIOWrapper around gzip files

2010-12-29 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: bz2 is a pure C module, so that's a very different situation. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10791 ___

[issue10791] Wrapping TextIOWrapper around gzip files

2010-12-29 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: While you're at it, maybe someone could add an 'open' function to bz2 to make it symmetrical with gzip as well :-). That's a nice idea, but quite orthogonal to this issue. -- ___ Python tracker

[issue10791] Wrapping TextIOWrapper around gzip files

2010-12-29 Thread David Beazley
David Beazley d...@dabeaz.com added the comment: C or not, wrapping a BZ2File instance with a TextIOWrapper to get text still seems like something that someone might want to do. I doubt it would take much modification to give BZ2File instances the required set of methods. --

[issue10791] Wrapping TextIOWrapper around gzip files

2010-12-29 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: Right, but in the bz2 case I think it is a feature request rather than a bugfix. In any case it should be a separate issue. -- ___ Python tracker rep...@bugs.python.org

[issue10791] Wrapping TextIOWrapper around gzip files

2010-12-29 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: C or not, wrapping a BZ2File instance with a TextIOWrapper to get text still seems like something that someone might want to do. I doubt it would take much modification to give BZ2File instances the required set of methods. BZ2File uses FILE

[issue10791] Wrapping TextIOWrapper around gzip files

2010-12-29 Thread David Beazley
David Beazley d...@dabeaz.com added the comment: Do Python devs really view gzip and bz2 as two totally completely different animals? They both have the same functionality and would be used for the same kinds of things. Maybe I'm missing something. --

[issue10791] Wrapping TextIOWrapper around gzip files

2010-12-29 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Do Python devs really view gzip and bz2 as two totally completely different animals? They both have the same functionality and would be used for the same kinds of things. Maybe I'm missing something. Well, the reality of divergent

[issue10791] Wrapping TextIOWrapper around gzip files

2010-12-29 Thread David Beazley
David Beazley d...@dabeaz.com added the comment: Hmmm. Interesting. In the big picture, it might be an interesting project for someone (not necessarily the core devs) to sit down and refactor both of these modules so that they play nice with Python 3 I/O system. Obviously that's a project