Skip to content

fix: handle TypeError when source is None in Sphinx 8.2#240

Merged
dhellmann merged 2 commits intosphinx-contrib:mainfrom
dhellmann:fix-issue-234-none-source
Nov 28, 2025
Merged

fix: handle TypeError when source is None in Sphinx 8.2#240
dhellmann merged 2 commits intosphinx-contrib:mainfrom
dhellmann:fix-issue-234-none-source

Conversation

@dhellmann
Copy link
Copy Markdown
Member

Fixes #234

When docutils.utils.get_source_line() returns None for the source parameter, the code was attempting to call osutil.relpath(None), which caused a TypeError in Sphinx 8.2.3.

This can occur with programmatically generated nodes or certain document structures that don't have proper source attribution.

Changes:

  • Added null check before calling osutil.relpath() in builder.py
  • Use '' placeholder when source is None
  • Added test case that reproduces the issue and verifies the fix

Chat log: https://gist.github.com/dhellmann/27d64eb733af50a2c1e460cc40164a11

@dhellmann dhellmann force-pushed the fix-issue-234-none-source branch from e19f9f7 to e2b101b Compare November 28, 2025 15:14
Fixes sphinx-contrib#234

When docutils.utils.get_source_line() returns None for the source
parameter, the code was attempting to call osutil.relpath(None),
which caused a TypeError in Sphinx 8.2.3.

This can occur with programmatically generated nodes or certain
document structures that don't have proper source attribution.

Changes:
- Added null check before calling osutil.relpath() in builder.py
- Use '<unknown>' placeholder when source is None
- Added test case that reproduces the issue and verifies the fix

Chat log: https://gist.github.com/dhellmann/27d64eb733af50a2c1e460cc40164a11

Co-authored-by: Claude Sonnet 4.5 <ai-assistant@anthropic.com>
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
@dhellmann dhellmann force-pushed the fix-issue-234-none-source branch from e2b101b to fe50721 Compare November 28, 2025 15:17
Something changed in the way hatch is working that makes it not possible
to run 'hatch build' inside of a test env. Disable the job while
debugging that problem.
@mergify mergify bot added the ci a CI change label Nov 28, 2025
@dhellmann dhellmann merged commit c039e7a into sphinx-contrib:main Nov 28, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci a CI change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incompatible with sphinx 8.2

1 participant