Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Non-integer font sizes #1475

Open
Open
@ThomasProctor

Description

@ThomasProctor

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 arun.font.size on a certain cursed run, I get an error like this:ValueError: invalid literal for int() with base 10: '36.56250317891439'

Here's a full traceback:

--->40returnrun.font.sizeFile/local_disk0/.ephemeral_nfs/envs/pythonEnv-46f9411e-ed8b-4f5f-ac48-4707bd9781bd/lib/python3.10/site-packages/docx/text/font.py:273,inFont.size(self)272returnNone-->273returnrPr.sz_valFile/local_disk0/.ephemeral_nfs/envs/pythonEnv-46f9411e-ed8b-4f5f-ac48-4707bd9781bd/lib/python3.10/site-packages/docx/oxml/text/font.py:300,inCT_RPr.sz_val(self)299returnNone-->300returnsz.valFile/local_disk0/.ephemeral_nfs/envs/pythonEnv-46f9411e-ed8b-4f5f-ac48-4707bd9781bd/lib/python3.10/site-packages/docx/oxml/xmlchemy.py:258,inRequiredAttribute._getter.<locals>.get_attr_value(obj)255raiseInvalidXmlError(256"required '%s' attribute not present on element %s"% (self._attr_name,obj.tag)257     )-->258returnself._simple_type.from_xml(attr_str_value)File/local_disk0/.ephemeral_nfs/envs/pythonEnv-46f9411e-ed8b-4f5f-ac48-4707bd9781bd/lib/python3.10/site-packages/docx/oxml/simpletypes.py:26,inBaseSimpleType.from_xml(cls,xml_value)24 @classmethod25deffrom_xml(cls,xml_value:str)->Any:--->26returncls.convert_from_xml(xml_value)File/local_disk0/.ephemeral_nfs/envs/pythonEnv-46f9411e-ed8b-4f5f-ac48-4707bd9781bd/lib/python3.10/site-packages/docx/oxml/simpletypes.py:265,inST_HpsMeasure.convert_from_xml(cls,str_value)264returnST_UniversalMeasure.convert_from_xml(str_value)-->265returnPt(int(str_value)/2.0)ValueError:invalidliteralforint()withbase10:'36.56250317891439'

I'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 changeint tofloat ondocx/oxml/simpletypes.py:265

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp