Fix crashes in multi-column detection on position-less shapes - #98
Open
eeshsaxena wants to merge 1 commit into
Open
Fix crashes in multi-column detection on position-less shapes#98eeshsaxena wants to merge 1 commit into
eeshsaxena wants to merge 1 commit into
Conversation
Shapes can have no explicit offset in their XML, so python-pptx returns None for
shape.top/left/width. is_two_column_text and assign_shapes then crashed:
sorting by attrgetter('top','left') raised TypeError comparing None with Emu,
and 'shape.left + shape.width / 2' raised TypeError on None. Use a None-safe
sort key and skip shapes without a position/size when computing centroids.
Also fix three 'raise (ValueError, msg)' statements, which raise a tuple rather
than the exception on Python 3.
Author
|
Hi! Gentle nudge on this one whenever you have some bandwidth. It's a small, self-contained fix ( |
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.
With
--try-multi-column, converting a deck that contains a shape without an explicit position crashes.python-pptx returns
Noneforshape.top/left/widthwhen the shape's XML has no offset (real .pptx files do this).multi_column.pythen hits two crashes:Fixes:
None-safe key (lambda s: (s.top or 0, s.left or 0)).raise (ValueError, "...")(3 places) raises a tuple, which Python 3 rejects withTypeError: exceptions must derive from BaseException; changed toraise ValueError("...").Added a regression test that builds a slide mixing positioned shapes with a position-less one; it crashes on
masterand passes with this change.