Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utf-8 problems - crash ('ascii' codec can't encode in python 2.7, ValueError: '1000000000' not allowed as Boolean value for boolean-value in 3.4) #28

Open
matkoniecz opened this issue Feb 7, 2016 · 1 comment

Comments

@matkoniecz
Copy link

crash was triggered by

import odf.opendocument
odf.opendocument.load(u'test.ods')

using python 2.7

  File "/usr/local/lib/python2.7/dist-packages/odf/opendocument.py", line 969, in load
    __loadxmlparts(z, manifest, doc, u'')
  File "/usr/local/lib/python2.7/dist-packages/odf/opendocument.py", line 900, in __loadxmlparts
    parser.parse(inpsrc)
  File "/usr/lib/python2.7/xml/sax/expatreader.py", line 107, in parse
    xmlreader.IncrementalParser.parse(self, source)
  File "/usr/lib/python2.7/xml/sax/xmlreader.py", line 123, in parse
    self.feed(buffer)
  File "/usr/lib/python2.7/xml/sax/expatreader.py", line 210, in feed
    self._parser.Parse(data, isFinal)
  File "/usr/lib/python2.7/xml/sax/expatreader.py", line 341, in start_element_ns
    AttributesNSImpl(newattrs, qnames))
  File "/usr/local/lib/python2.7/dist-packages/odf/load.py", line 78, in startElementNS
    e = Element(qname = tag, qattributes=attrdict, check_grammar=False)
  File "/usr/local/lib/python2.7/dist-packages/odf/element.py", line 318, in __init__
    self.setAttrNS(attr[0], attr[1], value)
  File "/usr/local/lib/python2.7/dist-packages/odf/element.py", line 446, in setAttrNS
    self.attributes[(namespace, localpart)] = c.convert((namespace, localpart), value, self)
  File "/usr/local/lib/python2.7/dist-packages/odf/attrconverters.py", line 1607, in convert
    return conversion(attribute, value, element)
  File "/usr/local/lib/python2.7/dist-packages/odf/attrconverters.py", line 41, in cnv_anyURI
    return str(arg)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf3' in position 103: ordinal not in range(128)

using python3.4

  File "/usr/local/lib/python3.4/dist-packages/odf/opendocument.py", line 969, in load
    __loadxmlparts(z, manifest, doc, u'')
  File "/usr/local/lib/python3.4/dist-packages/odf/opendocument.py", line 900, in __loadxmlparts
    parser.parse(inpsrc)
  File "/usr/lib/python3.4/xml/sax/expatreader.py", line 107, in parse
    xmlreader.IncrementalParser.parse(self, source)
  File "/usr/lib/python3.4/xml/sax/xmlreader.py", line 123, in parse
    self.feed(buffer)
  File "/usr/lib/python3.4/xml/sax/expatreader.py", line 207, in feed
    self._parser.Parse(data, isFinal)
  File "../Modules/pyexpat.c", line 405, in StartElement
  File "/usr/lib/python3.4/xml/sax/expatreader.py", line 341, in start_element_ns
    AttributesNSImpl(newattrs, qnames))
  File "/usr/local/lib/python3.4/dist-packages/odf/load.py", line 78, in startElementNS
    e = Element(qname = tag, qattributes=attrdict, check_grammar=False)
  File "/usr/local/lib/python3.4/dist-packages/odf/element.py", line 318, in __init__
    self.setAttrNS(attr[0], attr[1], value)
  File "/usr/local/lib/python3.4/dist-packages/odf/element.py", line 446, in setAttrNS
    self.attributes[(namespace, localpart)] = c.convert((namespace, localpart), value, self)
  File "/usr/local/lib/python3.4/dist-packages/odf/attrconverters.py", line 1607, in convert
    return conversion(attribute, value, element)
  File "/usr/local/lib/python3.4/dist-packages/odf/attrconverters.py", line 52, in cnv_boolean
    raise ValueError( "'%s' not allowed as Boolean value for %s" % (str(arg), attribute[1]))
ValueError: '1000000000' not allowed as Boolean value for boolean-value

Is this library maintained? If yes I may try reducing my file to a testcase.

@Virako
Copy link

Virako commented Jun 8, 2016

I have the same problem

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

No branches or pull requests

2 participants