Skip to content

Fix: guard against None text in PptxConverter#1826

Open
Jah-yee wants to merge 1 commit intomicrosoft:mainfrom
Jah-yee:fix/pptx-none-text-guard
Open

Fix: guard against None text in PptxConverter#1826
Jah-yee wants to merge 1 commit intomicrosoft:mainfrom
Jah-yee:fix/pptx-none-text-guard

Conversation

@Jah-yee
Copy link
Copy Markdown

@Jah-yee Jah-yee commented Apr 23, 2026

Good day

Fix: guard against None text in PptxConverter

Issue: #1808

When python-pptx returns None for shape.text or notes_frame.text (e.g. third-party generators, SmartArt elements, malformed runs without text content), the string concatenation operator (+) threw TypeError: can only concatenate str (not NoneType) to str and crashed the entire PPTX conversion. One malformed shape would fail the whole file.

Changes (3 lines, 1 file):

  • L165: shape.text.lstrip()(shape.text or "").lstrip()
  • L167: shape.text + "\n"(shape.text or "") + "\n"
  • L197: notes_frame.text(notes_frame.text or "")

Testing:

  • Syntax validation passed
  • Logic is a minimal, targeted guard — no behavior change for normal files
  • Follows existing or "" null-coalescing pattern already present in the same file (line 194)

Thank you for your work on this project. I hope this small fix is helpful. Please let me know if there's anything to adjust.

Warmly,
RoomWithOutRoof

When python-pptx returns None for shape.text or notes_frame.text
(e.g. third-party generators, SmartArt elements, malformed runs),
the + operator threw TypeError and crashed the entire conversion.

Fixed by adding 'or ""' guards on L165, L167, L197.
@Jah-yee
Copy link
Copy Markdown
Author

Jah-yee commented Apr 24, 2026

Hi maintainers! This is a very small 3-line safety fix (guard against None text in PptxConverter). The PR has been waiting for a while with no reviews. Could someone take a look? Happy to make any adjustments. Thanks!

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