Skip to content

python 2.x compatibility #168

Closed
Closed

Description

@snodo

there is a problem in
CT_CoreProperties._set_element_text (line 299)

value = str(value)

which will will fail in a default windows-python2.x installation when supplying unicode strings (e.g.):

UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 0: ordinal not in range(128)

This is because there is no default system encoding, so python tries to encode the unicode-string using 7-bit-ASCII, which of course fails.

My solution: Only convert to string, if its necessary. If it's already a string/unicode, don't touch.

if not isinstance(value, basestring):
    value = str(value)

Activity

  1. scanny commented on Aug 18, 2018

    @scanny
    Contributor

    Fixed in release v0.8.7 circa Aug 18 2018.

  2. added 2 commits that reference this issue on Aug 18, 2018
    c5bd9c2
    37822d3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions