IndexError: list index out of range for coverage 4.5 with python3.7

Issue #639 duplicate
Peter Wang created an issue

Hi I am using coverage to collect coverage data for a long time, today the coverage seems not working any more and keeps beeping with following error:

Traceback (most recent call last):
  File "/home/circleci/project/.tox/py37/lib/python3.7/site-packages/nose2/main.py", line 271, in runTests
    self.result = runner.run(self.test)
  File "/home/circleci/project/.tox/py37/lib/python3.7/site-packages/nose2/runner.py", line 59, in run
    self.session.hooks.afterTestRun(event)
  File "/home/circleci/project/.tox/py37/lib/python3.7/site-packages/nose2/events.py", line 225, in __call__
    result = getattr(plugin, self.method)(event)
  File "/home/circleci/project/.tox/py37/lib/python3.7/site-packages/nose2/plugins/result.py", line 107, in afterTestRun
    self._reportSummary(event)
  File "/home/circleci/project/.tox/py37/lib/python3.7/site-packages/nose2/plugins/result.py", line 169, in _reportSummary
    self._printSummary(evt)
  File "/home/circleci/project/.tox/py37/lib/python3.7/site-packages/nose2/plugins/result.py", line 229, in _printSummary
    self.session.hooks.afterSummaryReport(reportEvent)
  File "/home/circleci/project/.tox/py37/lib/python3.7/site-packages/nose2/events.py", line 225, in __call__
    result = getattr(plugin, self.method)(event)
  File "/home/circleci/project/.tox/py37/lib/python3.7/site-packages/nose2/plugins/coverage.py", line 102, in afterSummaryReport
    self.covController.stop()
  File "/home/circleci/project/.tox/py37/lib/python3.7/site-packages/coverage/control.py", line 1140, in xml_report
    return reporter.report(morfs, outfile=outfile)
  File "/home/circleci/project/.tox/py37/lib/python3.7/site-packages/coverage/xmlreport.py", line 72, in report
    self.report_files(self.xml_file, morfs)
  File "/home/circleci/project/.tox/py37/lib/python3.7/site-packages/coverage/report.py", line 91, in report_files
    report_fn(fr, self.coverage._analyze(fr))
  File "/home/circleci/project/.tox/py37/lib/python3.7/site-packages/coverage/control.py", line 970, in _analyze
    return Analysis(self.data, it)
  File "/home/circleci/project/.tox/py37/lib/python3.7/site-packages/coverage/results.py", line 28, in __init__
    self._arc_possibilities = sorted(self.file_reporter.arcs())
  File "/home/circleci/project/.tox/py37/lib/python3.7/site-packages/coverage/python.py", line 208, in arcs
    return self.parser.arcs()
  File "/home/circleci/project/.tox/py37/lib/python3.7/site-packages/coverage/parser.py", line 263, in arcs
    self._analyze_ast()
  File "/home/circleci/project/.tox/py37/lib/python3.7/site-packages/coverage/parser.py", line 273, in _analyze_ast
    aaa.analyze()
  File "/home/circleci/project/.tox/py37/lib/python3.7/site-packages/coverage/parser.py", line 545, in analyze
    code_object_handler(node)
  File "/home/circleci/project/.tox/py37/lib/python3.7/site-packages/coverage/parser.py", line 1089, in _code_object__ClassDef
    exits = self.add_body_arcs(node.body, from_start=ArcStart(start))
  File "/home/circleci/project/.tox/py37/lib/python3.7/site-packages/coverage/parser.py", line 666, in add_body_arcs
    prev_starts = self.add_arcs(body_node)
  File "/home/circleci/project/.tox/py37/lib/python3.7/site-packages/coverage/parser.py", line 629, in add_arcs
    return handler(node)
  File "/home/circleci/project/.tox/py37/lib/python3.7/site-packages/coverage/parser.py", line 834, in _handle_decorated
    body_start = self.line_for_node(node.body[0])
IndexError: list index out of range
Internal Error: runTests aborted: list index out of range

more details on below link: https://circleci.com/gh/peter-wangxu/persist-queue/234?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link

Comments (6)

  1. Ned Batchelder repo owner

    Thanks, this looks like a bug on a bug: the reason 4.5 fails is because it's including more code in the report than it used to, and that code is triggering an older bug in the code parser.

    BTW: it looks like you force-pushed your branch? The commit mentioned in the CI report isn't in your GitHub repo. No need to do anything, I've reproduced it.

  2. Ned Batchelder repo owner

    I see what happened: your commit added Python 3.7 as a test environment, which is where #640 shows up.

  3. Log in to comment