MCPcopy Index your code
hub / github.com/cool-RR/PySnooper / _make_context_fixer

Function _make_context_fixer

tests/mini_toolbox/contextlib.py:258–272  ·  view source on GitHub ↗
(frame_exc)

Source from the content-addressed store, hash-verified

256_HAVE_EXCEPTION_CHAINING = sys.version_info[0] >= 3
257if _HAVE_EXCEPTION_CHAINING:
258 def _make_context_fixer(frame_exc):
259 def _fix_exception_context(new_exc, old_exc):
260 # Context may not be correct, so find the end of the chain
261 while 1:
262 exc_context = new_exc.__context__
263 if exc_context is old_exc:
264 # Context is already set correctly (see issue 20317)
265 return
266 if exc_context is None or exc_context is frame_exc:
267 break
268 new_exc = exc_context
269 # Change the end of the chain to point to the exception
270 # we expect it to reference
271 new_exc.__context__ = old_exc
272 return _fix_exception_context
273
274 def _reraise_with_existing_context(exc_details):
275 try:

Callers 1

__exit__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected