lino-framework / appypod

appy.pod for Python 3
1 stars 3 forks source link

Unicode #4

Open tityrus opened 6 years ago

tityrus commented 6 years ago

Has anyone else had issues with unicode chars in the LibreOffice document? Mine fails over a ³ for example:

Traceback:

File "/home/joris/Projects/CerCon/env/lib/python3.5/site-packages/appy/pod/renderer.py", line 451, in run self.currentParser.parse(self.contentXml) File "/home/joris/Projects/CerCon/env/lib/python3.5/site-packages/appy/xml/init.py", line 273, in parse self.parser.parse(inputSource) File "/usr/lib/python3.5/xml/sax/expatreader.py", line 110, in parse xmlreader.IncrementalParser.parse(self, source) File "/usr/lib/python3.5/xml/sax/xmlreader.py", line 125, in parse self.feed(buffer) File "/usr/lib/python3.5/xml/sax/expatreader.py", line 210, in feed self._parser.Parse(data, isFinal) File "../Modules/pyexpat.c", line 468, in EndElement File "/usr/lib/python3.5/xml/sax/expatreader.py", line 325, in end_element self._cont_handler.endElement(name) File "/home/joris/Projects/CerCon/env/lib/python3.5/site-packages/appy/pod/pod_parser.py", line 319, in endElement e.currentBuffer.transferAllContent() File "/home/joris/Projects/CerCon/env/lib/python3.5/site-packages/appy/pod/buffers.py", line 384, in transferAllContent self.evaluate(self.parent, self.env.context) File "/home/joris/Projects/CerCon/env/lib/python3.5/site-packages/appy/pod/buffers.py", line 753, in evaluate result.write(self.content[currentIndex:index]) File "/home/joris/Projects/CerCon/env/lib/python3.5/site-packages/appy/pod/buffers.py", line 215, in write self.content.write(something) UnicodeEncodeError: 'ascii' codec can't encode character '\xb3' in position 2: ordinal not in range(128)

lsaffre commented 6 years ago

@tityrus, can you provide an example template file and a script that renders it and raises the problem?

tityrus commented 6 years ago

@lsaffre OK after some further testing this error doesn't occur when run from a standalone module or from a Django management command.

To test I was quickly trying this inside the web process in some test view.

Either way the idea is to have this process async, so it seems the functional problem is solved :)

Still wondering though why this error pops up from within a web instance.

juaky commented 5 years ago

Hi, I have exactly the same problem. Anyone know why?

Django Version: 2.2.5 Python Version: 3.6.8

Traceback:

File "/usr/lib/python3.6/xml/sax/expatreader.py" in parse

  1. xmlreader.IncrementalParser.parse(self, source)

File "/usr/lib/python3.6/xml/sax/xmlreader.py" in parse

  1. self.feed(buffer)

File "/usr/lib/python3.6/xml/sax/expatreader.py" in feed

  1. self._parser.Parse(data, isFinal)

File "../Modules/pyexpat.c" in StartElement

File "/usr/lib/python3.6/xml/sax/expatreader.py" in start_element

  1. self._cont_handler.startElement(name, AttributesImpl(attrs))

File "/opt/aa/bb/venv/lib/python3.6/site-packages/appy/pod/pod_parser.py" in startElement

  1. e.currentBuffer.dumpStartElement(elem, attrs)

File "/opt/aa/bb/venv/lib/python3.6/site-packages/appy/pod/buffers.py" in dumpStartElement

  1. self.write(' %s=%s' % (name, quoteattr(value)))

File "/opt/aa/bb/venv/lib/python3.6/site-packages/appy/pod/buffers.py" in write

  1. self.content.write(something)

Exception Type: UnicodeEncodeError at /cc/cc/x/y Exception Value: 'ascii' codec can't encode character '\xe0' in position 29: ordinal not in range(128)