Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test suite fails with sending None to string2lines() in Sphinx #987

Open
mcepl opened this issue Jul 20, 2024 · 0 comments
Open

test suite fails with sending None to string2lines() in Sphinx #987

mcepl opened this issue Jul 20, 2024 · 0 comments

Comments

@mcepl
Copy link

mcepl commented Jul 20, 2024

While packaging breathe for openSUSE 4.35.0 and with Sphinx 7.4.5 I found that 13 tests (out of 21) failed because apparently they are sending something wrong to Sphinx so that string2lines ends up with None instead of string or bytes:

[   20s] _______________________________ test_render_func _______________________________
[   20s] 
[   20s] app = <SphinxTestApp buildername='html'>
[   20s] 
[   20s]     def test_render_func(app):
[   20s]         member_def = WrappedMemberDef(
[   20s]             kind="function",
[   20s]             definition="void foo",
[   20s]             type_="void",
[   20s]             name="foo",
[   20s]             argsstring="(int)",
[   20s]             virt="non-virtual",
[   20s]             param=[
[   20s]                 WrappedParam(type_=WrappedLinkedText(content_=[WrappedMixedContainer(value="int")]))
[   20s]             ],
[   20s]         )
[   20s] >       signature = find_node(render(app, member_def), "desc_signature")
[   20s] 
[   20s] tests/test_renderer.py:335: 
[   20s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[   20s] tests/test_renderer.py:320: in render
[   20s]     return renderer.render(member_def)
[   20s] ../../BUILDROOT/python-breathe-4.35.0-0.x86_64/usr/lib/python3.10/site-packages/breathe/renderer/sphinxrenderer.py:2624: in render
[   20s]     result = method(self, node)
[   20s] ../../BUILDROOT/python-breathe-4.35.0-0.x86_64/usr/lib/python3.10/site-packages/breathe/renderer/sphinxrenderer.py:2511: in dispatch_memberdef
[   20s]     return self.visit_function(node)
[   20s] ../../BUILDROOT/python-breathe-4.35.0-0.x86_64/usr/lib/python3.10/site-packages/breathe/renderer/sphinxrenderer.py:2003: in visit_function
[   20s]     nodes = self.handle_declaration(node, declaration)
[   20s] ../../BUILDROOT/python-breathe-4.35.0-0.x86_64/usr/lib/python3.10/site-packages/breathe/renderer/sphinxrenderer.py:667: in handle_declaration
[   20s]     nodes_ = self.run_directive(obj_type, declaration, content_callback, options)
[   20s] ../../BUILDROOT/python-breathe-4.35.0-0.x86_64/usr/lib/python3.10/site-packages/breathe/renderer/sphinxrenderer.py:619: in run_directive
[   20s]     nodes = directive.run()
[   20s] /usr/lib/python3.10/site-packages/sphinx/domains/cpp/__init__.py:319: in run
[   20s]     return super().run()
[   20s] /usr/lib/python3.10/site-packages/sphinx/directives/__init__.py:281: in run
[   20s]     content_children = self.parse_content_to_nodes(allow_section_headings=True)
[   20s] /usr/lib/python3.10/site-packages/sphinx/util/docutils.py:415: in parse_content_to_nodes
[   20s]     return nested_parse_to_nodes(
[   20s] /usr/lib/python3.10/site-packages/sphinx/util/parsing.py:55: in nested_parse_to_nodes
[   20s]     content = _text_to_string_list(
[   20s] /usr/lib/python3.10/site-packages/sphinx/util/parsing.py:92: in _text_to_string_list
[   20s]     content = string2lines(text, tab_width, convert_whitespace=True)
[   20s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[   20s] 
[   20s] astring = None, tab_width = 8, convert_whitespace = True
[   20s] whitespace = re.compile('[\x0b\x0c]')
[   20s] 
[   20s]     def string2lines(astring, tab_width=8, convert_whitespace=False,
[   20s]                      whitespace=re.compile('[\v\f]')):
[   20s]         """
[   20s]         Return a list of one-line strings with tabs expanded, no newlines, and
[   20s]         trailing whitespace stripped.
[   20s]     
[   20s]         Each tab is expanded with between 1 and `tab_width` spaces, so that the
[   20s]         next character's index becomes a multiple of `tab_width` (8 by default).
[   20s]     
[   20s]         Parameters:
[   20s]     
[   20s]         - `astring`: a multi-line string.
[   20s]         - `tab_width`: the number of columns between tab stops.
[   20s]         - `convert_whitespace`: convert form feeds and vertical tabs to spaces?
[   20s]         - `whitespace`: pattern object with the to-be-converted
[   20s]           whitespace characters (default [\\v\\f]).
[   20s]         """
[   20s]         if convert_whitespace:
[   20s] >           astring = whitespace.sub(' ', astring)
[   20s] E           TypeError: expected string or bytes-like object
[   20s] 
[   20s] /usr/lib/python3.10/site-packages/docutils/statemachine.py:1506: TypeError
[   20s] --------------------------- Captured stdout teardown ---------------------------
[   20s] # testroot: root
[   20s] # builder: html
[   20s] # srcdir: /tmp/pytest-of-abuild/pytest-0/root
[   20s] # outdir: /tmp/pytest-of-abuild/pytest-0/root/_build/html
[   20s] # status: 
[   20s] �[01mRunning Sphinx v7.4.5�[39;49;00m
[   20s] �[01mloading translations [en]... �[39;49;00mdone
[   20s] 
[   20s] # warning: 
[   20s] 

Complete build log with all packages used and steps to produce the reproduction

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

No branches or pull requests

1 participant