exscript icon indicating copy to clipboard operation
exscript copied to clipboard

Scripts support only ASCII, not UTF-8?

Open lathspell opened this issue 7 years ago • 4 comments

I had a German umlaut ("ü") in one of my .exscript files and got this. Took me a while to realize that it was not "gargabe" in the output of the router but just the "fail" message that was the problem. Would be nice if the scripts could be in UTF-8.

Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/local/lib/python2.7/dist-packages/Exscript/queue.py", line 187, in run
    self._handle_request(request)
  File "/usr/local/lib/python2.7/dist-packages/Exscript/queue.py", line 171, in _handle_request
    _call_logger('log_aborted', *arg)
  File "/usr/local/lib/python2.7/dist-packages/Exscript/queue.py", line 120, in _call_logger
    return getattr(logger, funcname)(*args)
  File "/usr/local/lib/python2.7/dist-packages/Exscript/logger.py", line 307, in log_aborted
    Logger.log_aborted(self, job_id, exc_info)
  File "/usr/local/lib/python2.7/dist-packages/Exscript/logger.py", line 226, in log_aborted
    log.aborted(exc_info)
  File "/usr/local/lib/python2.7/dist-packages/Exscript/logger.py", line 154, in aborted
    self.write('ERROR:', str(exc_info[1]), '\n')
  File "/usr/lib/python2.7/dist-packages/future/types/newstr.py", line 102, in __new__
    return super(newstr, cls).__new__(cls, value)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 20: ordinal not in range(128)

lathspell avatar Sep 12 '18 11:09 lathspell

BTW, the 0xc3 is the first byte of UTF-8 "ü":

echo -n ü | od -t x1
0000000 c3 bc

As it says "UnicodeDecoder" but then "ascii" codec, it's maybe a Python misconficuration? Any ideas?

lathspell avatar Sep 12 '18 12:09 lathspell

I can imagine there being problems when using Python 2.7. Can you try if the problem persists with Python 3?

knipknap avatar Sep 12 '18 12:09 knipknap

It's a Debian system with both python2.7 and python3 installed. How can I force the installation for python3? I tried replacing python by python3 in the Makefile but it fails:

# make install
mkdir -p /usr/local/`python3 -c "import sys; from distutils.sysconfig import get_python_lib; print get_python_lib()[len(sys.prefix):]"`
  File "<string>", line 1
    import sys; from distutils.sysconfig import get_python_lib; print get_python_lib()[len(sys.prefix):]
                                                                                   ^
SyntaxError: invalid syntax

lathspell avatar Sep 12 '18 13:09 lathspell

Your idea is right; you can force it that way. Except the line was not Python 3 compatible yet. I just pushed a change for that.

knipknap avatar Sep 12 '18 13:09 knipknap