From 365d7cb03d65ae5c830c3c97a2471478988695f1 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 3 Mar 2022 09:50:45 -0500 Subject: fix: protect fullcoverage against lineno=None, bpo46911 https://bugs.python.org/issue46911 --- coverage/fullcoverage/encodings.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'coverage/fullcoverage/encodings.py') diff --git a/coverage/fullcoverage/encodings.py b/coverage/fullcoverage/encodings.py index b248bdbc..b8841866 100644 --- a/coverage/fullcoverage/encodings.py +++ b/coverage/fullcoverage/encodings.py @@ -35,20 +35,14 @@ class FullCoverageTracer: def fullcoverage_trace(self, *args): frame, event, arg = args - self.traces.append((args, frame.f_lineno)) + if frame.f_lineno is not None: + # https://bugs.python.org/issue46911 + self.traces.append((args, frame.f_lineno)) return self.fullcoverage_trace sys.settrace(FullCoverageTracer().fullcoverage_trace) -# In coverage/files.py is actual_filename(), which uses glob.glob. I don't -# understand why, but that use of glob borks everything if fullcoverage is in -# effect. So here we make an ugly hail-mary pass to switch off glob.glob over -# there. This means when using fullcoverage, Windows path names will not be -# their actual case. - -#sys.fullcoverage = True - -# Finally, remove our own directory from sys.path; remove ourselves from +# Remove our own directory from sys.path; remove ourselves from # sys.modules; and re-import "encodings", which will be the real package # this time. Note that the delete from sys.modules dictionary has to # happen last, since all of the symbols in this module will become None -- cgit v1.2.1