Skip to content

Commit d9f4682

Browse files
committed
Work around pydoctor bug parsing binary .so files
pydoctor's _parseFile only catches SyntaxError, but binary .so files raise UnicodeDecodeError via tokenize.open(), leaving the `parsed` variable unassigned and crashing in the finally block with UnboundLocalError. Patch the installed pydoctor to also catch UnicodeDecodeError so introspection can fall back to importing.
1 parent 275d9e6 commit d9f4682

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

.github/workflows/pydoctor.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@ jobs:
3737
pip install pydoctor
3838
- name: Build API docs
3939
run: |
40-
# Remove non-Python .so files (Rust proc-macro build artifacts) that
41-
# confuse pydoctor's introspection
40+
# Remove Rust proc-macro .so build artifacts that confuse pydoctor
4241
find subvertpy -name 'lib*.so' -delete
42+
# Work around pydoctor bug: _parseFile only catches SyntaxError but
43+
# binary .so files raise UnicodeDecodeError, causing an UnboundLocalError crash.
44+
sed -i 's/except SyntaxError/except (SyntaxError, UnicodeDecodeError)/g' \
45+
"$(python -c 'import pydoctor.astbuilder; print(pydoctor.astbuilder.__file__)')"
4346
pydoctor --introspect-c-modules -c subvertpy.cfg --make-html subvertpy
4447
- name: Upload Pages artifact
4548
uses: actions/upload-pages-artifact@v3

0 commit comments

Comments
 (0)