Jeff McNeil j...@jmcneil.net added the comment:
Documentation patch to outline the use of context manager protocol attached.
Trying to cleanup any bugs with my name on them.
--
keywords: +patch
Added file: http://bugs.python.org/file24817/urllib_request_doc.patch
Éric Araujo mer...@netwok.org added the comment:
Thanks for the patch.
- This function returns a file-like object with two additional methods from
+ This function returns a file-like object that supports the Context Manager
+ protocol, with two additional methods from
The
Jeff McNeil j...@jmcneil.net added the comment:
Yeah, updated with different wording and proper caps. I left the piece in
regarding the use without the context manager as I think that's probably the
more common use case still.
--
Added file:
Roundup Robot devn...@psf.upfronthosting.co.za added the comment:
New changeset 8625627969aa by Senthil Kumaran in branch '3.2':
closes Issue12365 - Add an example explaining the context manager use case of
urllib.urlopen
http://hg.python.org/cpython/rev/8625627969aa
New changeset 074e12441ed6
Senthil Kumaran sent...@uthcode.com added the comment:
Thanks for the patch, Jeff McNeil. I pushed the patches to 3.2 and 3.3 docs.
Since it is a documentation change (an explaination rather), I did not update
the NEWS.
Thanks again!
--
___
Python
Senthil Kumaran sent...@uthcode.com added the comment:
I forgot completely, but in Python3, Issue5418 had already added
support to addinfourl. It is now possible to write code like
import urllib.request
with urllib.request.urlopen('http://www.python.org') as req:
res = req.read()
But
Senthil Kumaran sent...@uthcode.com added the comment:
well, urlopen does return an file like object for socket connection which
closes itself when it goes out of scope, as you raised this bug, I think a more
explicit context manager like behavior can be tried. But I am afraid that it
would
Jeff McNeil j...@jmcneil.net added the comment:
Isn't that snippet (contextlib.closing(...)) passing the result of
urllib.urlopen to closing? The urlopen call is a factory function of sorts, so
there's really no context to manage on its part? Maybe it's just a matter of
making that clear?
New submission from Jeff McNeil j...@jmcneil.net:
Per discussion within Issue10050, URLopener ought to support the context
manager protocol. That allows more idiomatic usage and doesn't require calls to
contextlib.closing for use with the 'with' statement.
If agreed, I'll create a patch.
Changes by Jeff McNeil j...@jmcneil.net:
--
type: - feature request
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12365
___
___
Python-bugs-list
Éric Araujo mer...@netwok.org added the comment:
+1.
--
nosy: +eric.araujo
stage: - needs patch
versions: +Python 3.3 -Python 3.1
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12365
___
Jeff McNeil j...@jmcneil.net added the comment:
In looking at this again, I may have spoken too soon. It seems that addinfobase
HTTPResponse already handle this. As this is what's returned by the opener,
then what I was shooting for should already be handled.
--
status: open - closed
12 matches
Mail list logo