MCPcopy Index your code
hub / github.com/python/cpython / __exit__

Method __exit__

Lib/test/test_urllib2net.py:53–64  ·  view source on GitHub ↗

If type_ is a subclass of self.exc and value has attributes matching self.attrs, raise ResourceDenied. Otherwise let the exception propagate (if any).

(self, type_=None, value=None, traceback=None)

Source from the content-addressed store, hash-verified

51 return self
52
53 def __exit__(self, type_=None, value=None, traceback=None):
54 """If type_ is a subclass of self.exc and value has attributes matching
55 self.attrs, raise ResourceDenied. Otherwise let the exception
56 propagate (if any)."""
57 if type_ is not None and issubclass(self.exc, type_):
58 for attr, attr_value in self.attrs.items():
59 if not hasattr(value, attr):
60 break
61 if getattr(value, attr) != attr_value:
62 break
63 else:
64 raise ResourceDenied("an optional resource is not available")
65
66# Context managers that raise ResourceDenied when various issues
67# with the internet connection manifest themselves as exceptions.

Callers

nothing calls this directly

Calls 2

ResourceDeniedClass · 0.90
itemsMethod · 0.45

Tested by

no test coverage detected