From 6df9ee56ae8d607f7c1805fc7818273f88391274 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Mon, 29 May 2023 09:53:38 -0700 Subject: [PATCH] fix: revert "Map also empty dictionaries to file" (#1629) * Revert "Map also empty dictionaries to file" This reverts commit f54428fb8dfe98aacecc0b66e3c1ca2071ce1834 (#1347), which was a big regression in performance and file sizes when using dynamic_context, and is no longer needed for #972 as of 4cc32922685c6971275f522304b3754ad1a233c1 (#1538). Fixes #1586. Signed-off-by: Anders Kaseorg * docs: details of the fix in pull #1629, fixing #1586. --------- Signed-off-by: Anders Kaseorg Co-authored-by: Ned Batchelder --- CHANGES.rst | 9 ++++++++- CONTRIBUTORS.txt | 1 + coverage/collector.py | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 2f9dd0e55..938f10da1 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -20,7 +20,14 @@ development at the same time, such as 4.5.x and 5.0. Unreleased ---------- -Nothing yet. +- Fix: reverted a `change from 6.4.3 `_ that helped Cython, but + also increased the size of data files when using dynamic contexts, as + described in the now-fixed `issue 1586`_. The problem is now avoided due to a + recent change (`issue 1538`_). Thanks to `Anders Kaseorg `_ + and David Szotten for persisting with problem reports and detailed diagnoses. + +.. _issue 1586: https://github.com/nedbat/coveragepy/issues/1586 +.. _pull 1629: https://github.com/nedbat/coveragepy/pull/1629 .. scriv-start-here diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 91f914ba3..c3dfef428 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -16,6 +16,7 @@ Alexander Todorov Alexander Walters Alpha Chen Ammar Askar +Anders Kaseorg Andrew Hoos Anthony Sottile Arcadiy Ivanov diff --git a/coverage/collector.py b/coverage/collector.py index 2f8c17520..ca7f5d94b 100644 --- a/coverage/collector.py +++ b/coverage/collector.py @@ -456,7 +456,7 @@ def mapped_file_dict(self, d: Mapping[str, T]) -> Dict[str, T]: assert isinstance(runtime_err, Exception) raise runtime_err - return {self.cached_mapped_file(k): v for k, v in items} + return {self.cached_mapped_file(k): v for k, v in items if v} def plugin_was_disabled(self, plugin: CoveragePlugin) -> None: """Record that `plugin` was disabled during the run."""