Roundup Robot added the comment:
New changeset 6d5336a193cc by Berker Peksag in branch '3.4':
Issue #12955: Change the urlopen() examples to use context managers where
appropriate.
https://hg.python.org/cpython/rev/6d5336a193cc
New changeset 08adaaf08697 by Berker Peksag in branch 'default':
Berker Peksag added the comment:
Great patch. Thanks Martin.
--
resolution: - fixed
stage: patch review - resolved
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12955
Changes by Berker Peksag berker.pek...@gmail.com:
--
nosy: +berker.peksag
stage: needs patch - patch review
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12955
___
Martin Panter added the comment:
Issue 22755 is about the example arms race for contextlib.closing().
--
nosy: +vadmium
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12955
___
Martin Panter added the comment:
Here is a patch to change the urlopen() examples to use context managers where
appropriate.
There were also a few examples of handling HTTPError which I didn’t touch,
because the whole file object versus exception object thing is probably a
separate can of
Changes by Terry J. Reedy tjre...@udel.edu:
--
versions: +Python 3.4, Python 3.5 -Python 3.2, Python 3.3
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12955
___
Changes by Alexander Boyd a...@opengroove.org:
--
nosy: +javawizard
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12955
___
___
Python-bugs-list
Terry J. Reedy tjre...@udel.edu added the comment:
Senthil:
http://docs.python.org/dev/library/contextlib.html#contextlib.closing
currently has this example:
from urllib.request import urlopen
with closing(urlopen('http://www.python.org')) as page:
which is misleading in that the object
Éric Araujo mer...@netwok.org added the comment:
Either we find a commonly used stdlib class that is not a context manager but
has a close method and is not going to become a context manager (I can’t see
why such a thing would be), or we can add something like: “closing is useful
with code
Éric Araujo mer...@netwok.org added the comment:
[Terry]
But when I add 'http:www.python.org' as an argument, I get
urllib.error.URLError: urlopen error no host given
Your URI lacks a host (netloc, in RFC parlance) component:
urllib.parse.urlparse('http:python.org')
Terry J. Reedy tjre...@udel.edu added the comment:
On 3.2.2, your example (adapted) produces
2945 characters fetched
So, as Senthil said, the requested feature already exists. But it cannot be
added to the 2.7 series; the Python 2.7 *language* is feature frozen. 2.7.z bug
fixes serve to
Valery Khamenya khame...@gmail.com added the comment:
Guys, in my item 2 the simplistic goal was stated clearly: open, read and close.
Do you confirm that this basic sequence is not supported by urllib2 under 2.7 ?
(I just requested for a tiny documentation update entry)
regards,
Valery
Senthil Kumaran sent...@uthcode.com added the comment:
Valery, yes. I shall update 2.7 documentation with this known limitation and
3.x documentation with the example usage scenarios.
Thanks!
--
assignee: docs@python - orsenthil
___
Python tracker
13 matches
Mail list logo