[PyQt] Logging UTF-8 when pyqtdeployed
Kyle Altendorf
sda at fstab.net
Tue Feb 7 22:28:24 GMT 2017
On 2017-02-07 16:47, Dave Gradwell wrote:
> If my pyqtdeploy’ed app is run from under pyqtdeploy itself (with the
> ‘run application’ checkbox) then it can send UTF-8 characters to the
> Python logging module, which end up in a log file — which is good. It
> also works fine in interpreted/development mode, i.e., unpackaged.
> But if I quit pyqtdeploy and immediately just double click the (now
> packaged) app then it fails to log UTF-8 with the error message
> "UnicodeEncodeError: 'ascii' codec can't encode character '\xfc' in
> position 66: ordinal not in range(128)”
Is this Windows? Is it a GUI application? If so, I found that when
deployed my sys.stdout and sys.stderr were actually None. I won't
recommend what I have done as _good_ but I will share it in case it is
_useful_ at least for exploration.
https://github.com/altendky/st/blob/master/epyq/__main__.py#L11-L24
https://github.com/altendky/st/blob/26bfdb5a8409e20e9fc6870f6a9e56ddc516f65b/epyqlib/tee.py
Roughly speaking I replace sys.stdout and sys.stderr *shudder* with
either my log file or my tee object which sends to both the file and
stdout/err. Nasty, but without it I was flying totally blind except
that my application stopped running. Someday I'll do a proper logging
solution.
> I have the appropriate encoding hint at the top of my .py files # -*-
> coding: utf-8 -*-
My understanding is that that is for Python 2 for parsing the code file
itself and would not be relevant here.
Cheers,
-kyle
More information about the PyQt
mailing list