283 # The trace function has to be set individually on each thread before |
283 # The trace function has to be set individually on each thread before |
284 # execution begins. Ironically, the only support the threading module has |
284 # execution begins. Ironically, the only support the threading module has |
285 # for running code before the thread main is the tracing function. So we |
285 # for running code before the thread main is the tracing function. So we |
286 # install this as a trace function, and the first time it's called, it does |
286 # install this as a trace function, and the first time it's called, it does |
287 # the real trace installation. |
287 # the real trace installation. |
|
288 # |
|
289 # New in 3.12: threading.settrace_all_threads: https://github.com/python/cpython/pull/96681 |
288 |
290 |
289 def _installation_trace(self, frame, event, arg): |
291 def _installation_trace(self, frame, event, arg): |
290 """Called on new threads, installs the real tracer.""" |
292 """Called on new threads, installs the real tracer.""" |
291 # Remove ourselves as the trace function. |
293 # Remove ourselves as the trace function. |
292 sys.settrace(None) |
294 sys.settrace(None) |
430 else: |
432 else: |
431 break |
433 break |
432 else: |
434 else: |
433 raise runtime_err # pragma: cant happen |
435 raise runtime_err # pragma: cant happen |
434 |
436 |
435 return {self.cached_mapped_file(k): v for k, v in items if v} |
437 return {self.cached_mapped_file(k): v for k, v in items} |
436 |
438 |
437 def plugin_was_disabled(self, plugin): |
439 def plugin_was_disabled(self, plugin): |
438 """Record that `plugin` was disabled during the run.""" |
440 """Record that `plugin` was disabled during the run.""" |
439 self.disabled_plugins.add(plugin._coverage_plugin_name) |
441 self.disabled_plugins.add(plugin._coverage_plugin_name) |
440 |
442 |