Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(127)

#19524: ResourceWarning when urlopen() forgets the HTTPConnection object

Can't Edit
Can't Publish+Mail
Start Review
Created:
4 years, 1 month ago by vadmium+py
Modified:
3 years, 6 months ago
Reviewers:
pitrou
CC:
barry, orsenthil, AntoinePitrou, devnull_psf.upfronthosting.co.za, Martin Panter, storchaka
Visibility:
Public.

Patch Set 1 #

Total comments: 2

Patch Set 2 #

Unified diffs Side-by-side diffs Delta from patch set Stats Patch
Lib/test/test_urllib.py View 1 1 chunk +38 lines, -34 lines 0 comments Download
Lib/test/test_urllib2.py View 1 3 chunks +29 lines, -0 lines 0 comments Download

Messages

Total messages: 2
AntoinePitrou
Looks ok to me, just a question. http://bugs.python.org/review/19524/diff/10360/Lib/test/test_urllib.py File Lib/test/test_urllib.py (right): http://bugs.python.org/review/19524/diff/10360/Lib/test/test_urllib.py#newcode57 Lib/test/test_urllib.py:57: def fakehttp(fakedata): ...
4 years ago #1
Martin Panter
4 years ago #2
http://bugs.python.org/review/19524/diff/10360/Lib/test/test_urllib.py
File Lib/test/test_urllib.py (right):

http://bugs.python.org/review/19524/diff/10360/Lib/test/test_urllib.py#newcode57
Lib/test/test_urllib.py:57: def fakehttp(fakedata):
I wanted to use the FakeHTTPConnection class without monkey-patching
http.client.HTTPConnection, so I separated most of the fakehttp() body from the
FakeHTTPMixin class. An alternative might look something like this in
test_urllib2.py, a bit more awkward:

monkey = FakeHTTPMixin()
...
monkey.fakehttp(<data>)
try:
    ...
    handler.do_open(http.client.HTTPConnection, req)
    ...
    self.assertTrue(http.client.HTTPConnection.fakesock.closed, ...)
finally:
    monkey.unfakehttp()
Sign in to reply to this message.

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7