Skip to content

Handle fractional twips measures - #1603

Open
rootsec1 wants to merge 1 commit into
python-openxml:masterfrom
rootsec1:fix/1539-fractional-twips
Open

Handle fractional twips measures#1603
rootsec1 wants to merge 1 commit into
python-openxml:masterfrom
rootsec1:fix/1539-fractional-twips

Conversation

@rootsec1

Copy link
Copy Markdown

Word can write fractional values into twips-based attributes, which currently causes ST_TwipsMeasure to raise while reading properties such as Section.right_margin.

This keeps the existing exact integer path (including values above 2^53) and uses float conversion plus rounding only when integer parsing fails. Unit-suffixed measurements and integer serialization remain unchanged.

Regression coverage includes fractional twips through both ST_TwipsMeasure and the public section margin API, exact large integers, unit suffixes, invalid/non-finite inputs, and serialization.

Tests: pytest tests/oxml/test_simpletypes.py tests/test_section.py

Fixes #1539

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.

Getting "ValueError: invalid literal for int() with base 10" error when access section's margin

1 participant