servo / highfive

Github hooks to provide an encouraging atmosphere for new contributors
Mozilla Public License 2.0
254 stars 58 forks source link

urllib2.urlopen should be properly closed to avoid exceptions #89

Closed wafflespeanut closed 8 years ago

wafflespeanut commented 8 years ago

get_page_content seemed to throw an exception when I tried locally. It turned out that with actually calls the __enter__ and __exit__ methods on a file descriptor. While file has those methods, urlopen doesn't (which explains why the tests passed locally) - it always throws an AttributeError. This should just work if the thing's properly closed.

highfive commented 8 years ago

Heads up! This PR modifies the following files:

wafflespeanut commented 8 years ago

I just realized that there's also a built-in function for handling these cases :)

jdm commented 8 years ago

Good find!