help('modules spam') causes segfault.
When pydoc tries goes though the files it does the following in the ModuleScanner class.
(minimal example)
>>> for importer, modname, ispkg in pkgutil.walk_packages():
... if modname == 'test.badsyntax_pep3120':
... loader = importer.find_module(modname)
...
Segmentation fault
Adding:
if modname=='test.badsyntax_pep3120':
continue
At the top of the for loop will suppress the segfault in pydoc by skipping that file.
A bit further probing narrowed it down to this...
>>> loader = pkgutil.get_loader('test.badsyntax_pep3120')
Segmentation fault
I'm not familiar with the pkgutil module so I didn't go further.