From e3f8053d805f8930ffc8424ac098576457c5f506 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 2 Jan 2021 10:38:56 -0500 Subject: PEP 626: constant tests are kept as no-ops The conditionals are now getting unwieldy, perhaps we can simplify them in the future? --- coverage/parser.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'coverage/parser.py') diff --git a/coverage/parser.py b/coverage/parser.py index 6a3ca2fc..1e307c41 100644 --- a/coverage/parser.py +++ b/coverage/parser.py @@ -1118,9 +1118,14 @@ class AstArcAnalyzer(object): @contract(returns='ArcStarts') def _handle__While(self, node): - constant_test = self.is_constant_expr(node.test) start = to_top = self.line_for_node(node.test) + constant_test = self.is_constant_expr(node.test) + top_is_body0 = False if constant_test and (env.PY3 or constant_test == "Num"): + top_is_body0 = True + if env.PYBEHAVIOR.keep_constant_test: + top_is_body0 = False + if top_is_body0: to_top = self.line_for_node(node.body[0]) self.block_stack.append(LoopBlock(start=to_top)) from_start = ArcStart(start, cause="the condition on line {lineno} was never true") -- cgit v1.2.1