Skip to content

Conversation

@jmgate
Copy link
Contributor

@jmgate jmgate commented Oct 6, 2025

While attempting to test the scenarios mentioned in the description of #278, I came across what appear to be some bugs created in commit 4cd5c51. I'm not sure if these fixes are the best way to address them, though; all I know is they got my Sphinx build back up and running again.

Commits

  1. fix: Handle the zero matches case (da08566)

    When trying to test out the master branch against my project, to see if we're ready for a 0.23.0 release, I ran into the following error:

    File ".../sphinx/events.py", line 415, in emit
        raise ExtensionError(
        ...<4 lines>...
        ) from exc
    sphinx.errors.ExtensionError: Handler <function analyze at 0x...>
        for event 'builder-inited' threw an exception (exception: list
        index out of range)
    

    Digging further, the problem was actually:

    File ".../mat_tree_sitter_parser.py", line 373, in
        _parse_argument_section
        _, arg_match = q_arg.matches(arg)[0]
                       ~~~~~~~~~~~~~~~~~~^^^
    IndexError: list index out of range
    

    I was able to rewind through history to find this problem first arose with commit 4cd5c51. The problem is occasionally q_arg.matches(arg) will return no matches (an empty list), so we need to check for that possibility before attempting to access the first element of the list.

  2. fix: Don't link to base classes for non-classes (0a81e9b)

    After applying the fix in the prior commit, the next error I ran into was:

    File ".../mat_documenters.py", line 997, in make_baseclass_links
        obj_bases = obj.__bases__
                    ^^^^^^^^^^^^^
    AttributeError: 'MatFunction' object has no attribute '__bases__'.
        Did you mean: '__class__'?
    

    It appeared we were trying to add links to base classes for all object types (functions, in the error above), not just classes.

Notes to Reviewers

  • My process was:

    1. Create this branch off of the faulty commit.
    2. Create the two fix commits to get my Sphinx build working again.
    3. Merge in the latest master and ensure my Sphinx build was still working.
    4. Run tox -e "3.8-sphinx45" to ensure the tests were still passing.
  • If these fixes should be implemented in a different way, please feel free to push commits to this branch.

jmgate added 3 commits October 6, 2025 13:54
When trying to test out the `master` branch against my project, to see
if we're ready for a 0.23.0 release, I ran into the following error:

    File ".../sphinx/events.py", line 415, in emit
        raise ExtensionError(
        ...<4 lines>...
        ) from exc
    sphinx.errors.ExtensionError: Handler <function analyze at 0x...>
        for event 'builder-inited' threw an exception (exception: list
        index out of range)

Digging further, the problem was actually:

    File ".../mat_tree_sitter_parser.py", line 373, in
        _parse_argument_section
        _, arg_match = q_arg.matches(arg)[0]
                       ~~~~~~~~~~~~~~~~~~^^^
    IndexError: list index out of range

I was able to rewind through history to find this problem first arose
with commit 4cd5c51.  The problem is
occasionally `q_arg.matches(arg)` will return no matches (an empty
list), so we need to check for that possibility before attempting to
access the first element of the list.
After applying the fix in the prior commit, the next error I ran into
was:

    File ".../mat_documenters.py", line 997, in make_baseclass_links
        obj_bases = obj.__bases__
                    ^^^^^^^^^^^^^
    AttributeError: 'MatFunction' object has no attribute '__bases__'.
        Did you mean: '__class__'?

It appeared we were trying to add links to base classes for all object
types (functions, in the error above), not just classes.
@Remi-Gau
Copy link
Collaborator

Remi-Gau commented Oct 7, 2025

the fact that we are not seeing the crashes you are seeing means that we have blind spots in the test suite: do you think you can add regression tests to show the bug (or bugs) this PR is fixing?

@jmgate
Copy link
Contributor Author

jmgate commented Oct 28, 2025

My apologies. Due to other priorities, I likely won't have time to come back to this till January, at the earliest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants