Skip to content

Commit

Permalink
fix: #168 Unicode error on Python 2 core-props
Browse files Browse the repository at this point in the history
  • Loading branch information
scanny committed Aug 18, 2018
1 parent aad71d4 commit 37822d3
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions docx/oxml/coreprops.py
@@ -1,8 +1,6 @@
# encoding: utf-8

"""
lxml custom element classes for core properties-related XML elements.
"""
"""Custom element classes for core properties-related XML elements"""

from __future__ import (
absolute_import, division, print_function, unicode_literals
Expand All @@ -12,9 +10,10 @@

from datetime import datetime, timedelta

from . import parse_xml
from .ns import nsdecls, qn
from .xmlchemy import BaseOxmlElement, ZeroOrOne
from docx.compat import is_string
from docx.oxml import parse_xml
from docx.oxml.ns import nsdecls, qn
from docx.oxml.xmlchemy import BaseOxmlElement, ZeroOrOne


class CT_CoreProperties(BaseOxmlElement):
Expand Down Expand Up @@ -293,10 +292,10 @@ def _set_element_datetime(self, prop_name, value):
del self.attrib[qn('xsi:foo')]

def _set_element_text(self, prop_name, value):
"""
Set string value of *name* property to *value*.
"""
value = str(value)
"""Set string value of *name* property to *value*."""
if not is_string(value):
value = str(value)

if len(value) > 255:
tmpl = (
"exceeded 255 char limit for property, got:\n\n'%s'"
Expand Down

0 comments on commit 37822d3

Please sign in to comment.