[Python-Dev] cpython (3.2): Fix closes Issue12576 (original) (raw)

[Python-Dev] cpython (3.2): Fix closes Issue12576 - fix urlopen behavior on sites which do not send (or

Antoine Pitrou solipsis at pitrou.net
Wed Jul 27 14:21:59 CEST 2011


On Wed, 27 Jul 2011 20:16:01 +0800 Senthil Kumaran <senthil at uthcode.com> wrote:

On Wed, Jul 27, 2011 at 11:52:32AM +0200, Antoine Pitrou wrote: > > + > > + try: > > + with urllib.request.urlopen('http://www.imdb.com') as res: > > + pass > > Can you please at least use support.transientinternet() as in other > tests in this file?

It was intentional because ValueError was raised from context manager use case for a bug where the request object was closed prematurely. support.transientinternet, I believe would not have covered that case (Usage scenario).

Unless I'm reading wrongly, transient_internet doesn't silence ValueError at all.

> > + res = req.read() > > + self.assertTrue(res) > > Also, when does "req" get closed? Right now I get resource warnings:

I shall fix this one. I think, attempting to fix the Resource warning caused the regression wherein the request object closed prematurely. I shall look at this.

Well, the test should simply call close() as is done in other tests.

Regards

Antoine.



More information about the Python-Dev mailing list