Skip to content

Conversation

@Lonami
Copy link
Contributor

@Lonami Lonami commented Oct 3, 2023

Subject: Fix #11678.

Feature or Bugfix

  • Bugfix

Purpose

  • Fix ZeroDivisionError in _write_py_statistics.
  • Running with python -m sphinx -M coverage.

Detail

Fixes:

Exception occurred:
  File "C:\Users\L\Documents\Projects\sphinx\sphinx\ext\coverage.py", line 295, in _write_py_statistics
    f'{100 * len(all_documented_objects) / len(all_objects):.2f}%',
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
ZeroDivisionError: division by zero

Relates

If you run coverage and there are no modules documented, we currently
exit with a ZeroDivision error. Resolve this.

Signed-off-by: Stephen Finucane <[email protected]>
@Lonami Lonami changed the title coverage: Handle no modules Fix coverage extension crash when module contents are not found Oct 3, 2023
Co-authored-by: Bénédikt Tran <[email protected]>
@AA-Turner
Copy link
Member

Please update CHANGES.

@Lonami
Copy link
Contributor Author

Lonami commented Oct 4, 2023

Not sure if the "Patch by Lonami" is correct. The patch isn't mine. I just applied it and sent it as a standalone PR.

Regardless I plan to make a subsequent PR with more improvements to the coverage module (namely, coverage for parameter documentation). Which will make this one redundant. But I guess it can be merged, in case my later PR is not.

LMK if you want me to squash the changes.

@AA-Turner AA-Turner merged commit bb74aec into sphinx-doc:master Oct 5, 2023
@Lonami Lonami deleted the fix/coverage/zerodiv branch October 5, 2023 20:21
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 5, 2023
@AA-Turner AA-Turner added this to the 7.3.0 milestone Jul 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

coverage extension crashes when module contents are not found

4 participants