Skip to content

Instantly share code, notes, and snippets.

@ErinCall
Created June 5, 2012 03:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ErinCall/2872479 to your computer and use it in GitHub Desktop.
Save ErinCall/2872479 to your computer and use it in GitHub Desktop.
Do these look functionally equivalent
#python 2.7
with warnings.catch_warnings(record=False) as w:
soup = BeautifulStoneSoup("<b />")
self.assertEqual(u"<b/>", unicode(soup.b))
#python 2.5
warnings_manager = warnings.catch_warnings(record=True)
w = warnings_manager.__enter__()
try:
soup = BeautifulStoneSoup("<b />")
self.assertEqual(u"<b/>", unicode(soup.b))
except Exception, e:
warnings_manager.__exit__(sys.exc_info())
raise
else:
warnings_manager.__exit__(None, None, None)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment