Issue3860
Created on 2008-09-13 19:29 by hagen, last changed 2009-01-10 16:23 by pitrou.
| File name |
Uploaded |
Description |
Edit |
Remove |
|
withgzip.patch
|
pitrou,
2008-12-18 17:53
|
|
|
|
|
msg73194 - (view) |
Author: Hagen Fürstenau (hagen) |
Date: 2008-09-13 19:29 |
|
When you've become used to writing
with open("xzy", "w") as f:
it's strange when it doesn't work for gzip.open or bz2.BZ2File.
Or is there a reason for them not being context managers?
|
|
msg78035 - (view) |
Author: Antoine Pitrou (pitrou) |
Date: 2008-12-18 17:53 |
|
Here is a patch for the trunk. I'm waiting for the opinion other
developers before deciding to commit or no.
|
|
msg78037 - (view) |
Author: Benjamin Peterson (benjamin.peterson) |
Date: 2008-12-18 18:43 |
|
Here's the StringIO discussion: #1286
|
|
msg78046 - (view) |
Author: Antoine Pitrou (pitrou) |
Date: 2008-12-18 23:01 |
|
Thanks. The outcome of the StringIO discussion isn't clearly negative,
although Guido does not see a big benefit in it. If some people are
opposed to this, please stand up :) Otherwise I'll commit the patch to
trunk.
|
|
msg78319 - (view) |
Author: STINNER Victor (haypo) |
Date: 2008-12-26 23:45 |
|
I love "with ... as f:" and I want it for gzip/bz2 files!
Comment about the patch:
(1) the IOError message is different for the two modules:
"I/O operation on closed GzipFile object"
vs
"I/O operation on closed file"
Specify the object name in both messages or remove it from both
messages. I prefer verbose error message ("I/O operation on closed
BZ2File object").
(2) For bz2module, Why don't you call BZ2File_close() directly instead
of the generic version PyObject_CallMethod(... "close" ...)?
|
|
msg78324 - (view) |
Author: Antoine Pitrou (pitrou) |
Date: 2008-12-27 00:46 |
|
> (1) the IOError message is different for the two modules:
> "I/O operation on closed GzipFile object"
> vs
> "I/O operation on closed file"
I've reused the same error message as used in other parts of each
module.
> (2) For bz2module, Why don't you call BZ2File_close() directly instead
> of the generic version PyObject_CallMethod(... "close" ...)?
Because someone may subclass BZ2File and override the close() method. I
don't know if it's likely to happen, though.
|
|
msg79551 - (view) |
Author: Antoine Pitrou (pitrou) |
Date: 2009-01-10 16:23 |
|
Committed in trunk and py3k. Thanks!
|
|
| Date |
User |
Action |
Args |
| 2009-01-10 16:23:27 | pitrou | set | status: open -> closed resolution: fixed messages:
+ msg79551 |
| 2008-12-27 00:46:09 | pitrou | set | messages:
+ msg78324 |
| 2008-12-26 23:45:13 | haypo | set | nosy:
+ haypo messages:
+ msg78319 |
| 2008-12-18 23:01:42 | pitrou | set | messages:
+ msg78046 |
| 2008-12-18 18:43:14 | benjamin.peterson | set | nosy:
+ benjamin.peterson messages:
+ msg78037 |
| 2008-12-18 17:53:14 | pitrou | set | files:
+ withgzip.patch keywords:
+ patch messages:
+ msg78035 nosy:
+ pitrou stage: patch review |
| 2008-09-13 19:32:07 | benjamin.peterson | set | priority: normal versions:
+ Python 3.1, Python 2.7, - Python 2.6, Python 3.0 |
| 2008-09-13 19:29:02 | hagen | create | |
|