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

Method __exit__

Lib/test/libregrtest/save_env.py:339–357  ·  view source on GitHub ↗
(self, exc_type, exc_val, exc_tb)

Source from the content-addressed store, hash-verified

337 return self
338
339 def __exit__(self, exc_type, exc_val, exc_tb):
340 saved_values = self.saved_values
341 self.saved_values = None
342
343 # Some resources use weak references
344 support.gc_collect()
345
346 for name, get, restore, original in saved_values:
347 current = get()
348 # Check for changes to the resource's value
349 if current != original:
350 support.environment_altered = True
351 restore(original)
352 if not self.quiet and not self.pgo:
353 print_warning(
354 f"{name} was modified by {self.test_name}\n"
355 f" Before: {original}\n"
356 f" After: {current} ")
357 return False

Callers

nothing calls this directly

Calls 3

print_warningFunction · 0.70
getFunction · 0.50
restoreFunction · 0.50

Tested by

no test coverage detected