Skip to content

fix: PptxConverter tolerates None shape.text and notes text#2059

Open
alvinttang wants to merge 1 commit into
microsoft:mainfrom
alvinttang:fix/pptx-none-text-frame
Open

fix: PptxConverter tolerates None shape.text and notes text#2059
alvinttang wants to merge 1 commit into
microsoft:mainfrom
alvinttang:fix/pptx-none-text-frame

Conversation

@alvinttang
Copy link
Copy Markdown

Refs #1808.

PptxConverter.convert does unguarded + / .lstrip() on shape.text and notes_text_frame.text. python-pptx returns None for a text frame whose <a:r> run has no <a:t> child, and for certain third-party-generated decks. One malformed shape then fails the whole file with AttributeError: 'NoneType' object has no attribute 'lstrip' or TypeError: can only concatenate str (not "NoneType") to str.

Fix: treat None text as empty string at all three sites (title shape, body shape, notes frame).

RED

FAILED tests/test_pptx_none_text.py::test_pptx_converter_handles_none_shape_text
- PptxConverter threw AttributeError: 'NoneType' object has no attribute 'lstrip'
FAILED tests/test_pptx_none_text.py::test_pptx_converter_handles_none_notes_text
- PptxConverter threw TypeError: can only concatenate str (not "NoneType") to str

GREEN

tests/test_pptx_none_text.py::test_pptx_converter_handles_none_shape_text PASSED
tests/test_pptx_none_text.py::test_pptx_converter_handles_none_notes_text PASSED
2 passed in 0.65s

Full test_module_vectors.py (109 tests, covers real pptx conversion) still passes.

shape.text and notes_text_frame.text can return None for runs with no
<a:t> child or certain third-party decks. Treat None as empty string so
one malformed shape does not fail the whole file.

Refs microsoft#1808
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.

1 participant