fix(pptx): handle unsupported 3-D chart types without crashing - #3972
Open
ceberam wants to merge 1 commit into
Open
fix(pptx): handle unsupported 3-D chart types without crashing#3972ceberam wants to merge 1 commit into
ceberam wants to merge 1 commit into
Conversation
Signed-off-by: Cesar Berrospi Ramis <ceb@zurich.ibm.com>
Contributor
|
✅ DCO Check Passed Thanks @ceberam, all your commits are properly signed off. 🎉 |
Contributor
Merge Protections🔴 1 of 2 protections blocking · waiting on 👀 reviews
🔴 Require two reviewer for test updatesWaiting for
This rule is failing.When test data is updated, we require two reviewers
Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #3970
Problem
A
.pptxcontaining a 3-D chart element (e.g.c:bar3DChart) caused theentire document conversion to fail with:
python-pptx has no registered custom element class for 3-D chart types, so
chart.seriesraisesAttributeErroron the raw lxml element. One affectedslide was enough to lose the whole deck.
Fix
In
_handle_chart, the call to_chart_to_table_datais now guarded with thesame
try/exceptpattern already used one line above forchart.chart_type:With
table_data = Nonethe rest of_handle_chartalready handles thegraceful path — the chart is emitted as a
PictureItemwith its classificationand caption (if any),
tabular_chartisNone, and all other slide contentis preserved.
Tests
The existing
pptx_chart.pptxfixture was extended with a second slidecontaining a
c:bar3DChartelement (patched in-place from a normalc:barChart, which is what PowerPoint writes for 3-D bar/column charts).test_chart_parsed_as_classified_picture_with_data— updated to cover bothslides: the 2-D chart (slide 1) is verified to carry full tabular data; the
3-D chart (slide 2) is verified to produce a
PictureItemwithtabular_chart = Noneand no crash.pptx_chart.pptxregenerated.Checklist: