Title: Non-integer font sizes · Issue #1475 · python-openxml/python-docx · GitHub
Open Graph Title: Non-integer font sizes · Issue #1475 · python-openxml/python-docx
X Title: Non-integer font sizes · Issue #1475 · python-openxml/python-docx
Description: version: 1.1.2 I have multiple documents (which, unfortunately, I'm not able to share directly) that I can open just fine in word, but when I try to access a run.font.size on a certain cursed run, I get an error like this: ValueError: in...
Open Graph Description: version: 1.1.2 I have multiple documents (which, unfortunately, I'm not able to share directly) that I can open just fine in word, but when I try to access a run.font.size on a certain cursed run, ...
X Description: version: 1.1.2 I have multiple documents (which, unfortunately, I'm not able to share directly) that I can open just fine in word, but when I try to access a run.font.size on a certain cursed r...
Opengraph URL: https://github.com/python-openxml/python-docx/issues/1475
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Non-integer font sizes","articleBody":"version: 1.1.2\n\nI have multiple documents (which, unfortunately, I'm not able to share directly) that I can open just fine in word, but when I try to access a `run.font.size` on a certain cursed run, I get an error like this: `ValueError: invalid literal for int() with base 10: '36.56250317891439'`\n\nHere's a full traceback:\n```python\n---\u003e 40 return run.font.size\nFile /local_disk0/.ephemeral_nfs/envs/pythonEnv-46f9411e-ed8b-4f5f-ac48-4707bd9781bd/lib/python3.10/site-packages/docx/text/font.py:273, in Font.size(self)\n 272 return None\n--\u003e 273 return rPr.sz_val\nFile /local_disk0/.ephemeral_nfs/envs/pythonEnv-46f9411e-ed8b-4f5f-ac48-4707bd9781bd/lib/python3.10/site-packages/docx/oxml/text/font.py:300, in CT_RPr.sz_val(self)\n 299 return None\n--\u003e 300 return sz.val\nFile /local_disk0/.ephemeral_nfs/envs/pythonEnv-46f9411e-ed8b-4f5f-ac48-4707bd9781bd/lib/python3.10/site-packages/docx/oxml/xmlchemy.py:258, in RequiredAttribute._getter.\u003clocals\u003e.get_attr_value(obj)\n 255 raise InvalidXmlError(\n 256 \"required '%s' attribute not present on element %s\" % (self._attr_name, obj.tag)\n 257 )\n--\u003e 258 return self._simple_type.from_xml(attr_str_value)\nFile /local_disk0/.ephemeral_nfs/envs/pythonEnv-46f9411e-ed8b-4f5f-ac48-4707bd9781bd/lib/python3.10/site-packages/docx/oxml/simpletypes.py:26, in BaseSimpleType.from_xml(cls, xml_value)\n 24 @classmethod\n 25 def from_xml(cls, xml_value: str) -\u003e Any:\n---\u003e 26 return cls.convert_from_xml(xml_value)\nFile /local_disk0/.ephemeral_nfs/envs/pythonEnv-46f9411e-ed8b-4f5f-ac48-4707bd9781bd/lib/python3.10/site-packages/docx/oxml/simpletypes.py:265, in ST_HpsMeasure.convert_from_xml(cls, str_value)\n 264 return ST_UniversalMeasure.convert_from_xml(str_value)\n--\u003e 265 return Pt(int(str_value) / 2.0)\nValueError: invalid literal for int() with base 10: '36.56250317891439'\n```\n\nI'm guessing this is something similar to an earlier issue, #1335, where the XML schema says this is invalid but there must be some way it ends up happening, but it doesn't break Microsoft Word. Given that this int is being instantly converted to a float, it seems likely that it will be completely harmless to just change `int` to `float` on `docx/oxml/simpletypes.py:265`","author":{"url":"https://github.com/ThomasProctor","@type":"Person","name":"ThomasProctor"},"datePublished":"2025-03-12T20:47:33.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/1475/python-docx/issues/1475"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:018ce94b-a648-5767-7139-1aee22112790 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D1CE:2C86E:4B1178:6605BF:696E75CD |
| html-safe-nonce | 2a4a968a4f4f89866849082177f30b661eb9d29aa11d68c8c8676052f058a281 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMUNFOjJDODZFOjRCMTE3ODo2NjA1QkY6Njk2RTc1Q0QiLCJ2aXNpdG9yX2lkIjoiODI5Nzk4NzUwNzUzNzk5OTMwOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 73ad1303e59ad7e3cded1d3b7d55e892edba2f866abe7ca0e70abfffa6c6c718 |
| hovercard-subject-tag | issue:2915128146 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-openxml/python-docx/1475/issue_layout |
| twitter:image | https://opengraph.githubassets.com/393b37721b2cb7052c08299016fe365fb7aab87ec6b3e2cfe26bfa640dd09ca4/python-openxml/python-docx/issues/1475 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/393b37721b2cb7052c08299016fe365fb7aab87ec6b3e2cfe26bfa640dd09ca4/python-openxml/python-docx/issues/1475 |
| og:image:alt | version: 1.1.2 I have multiple documents (which, unfortunately, I'm not able to share directly) that I can open just fine in word, but when I try to access a run.font.size on a certain cursed run, ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ThomasProctor |
| hostname | github.com |
| expected-hostname | github.com |
| None | 01185010a96388a2a8cd8bd7f5824fdf090522b219f9aecf8c7ff1857aeb489b |
| turbo-cache-control | no-preview |
| go-import | github.com/python-openxml/python-docx git https://github.com/python-openxml/python-docx.git |
| octolytics-dimension-user_id | 3403760 |
| octolytics-dimension-user_login | python-openxml |
| octolytics-dimension-repository_id | 13592924 |
| octolytics-dimension-repository_nwo | python-openxml/python-docx |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 13592924 |
| octolytics-dimension-repository_network_root_nwo | python-openxml/python-docx |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 673a80c1bce2a1e6a48b530ce2b72bf8fd253386 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width