[PyQt] Logging UTF-8 when pyqtdeployed
davegradwell at yahoo.co.uk
Wed Feb 8 18:53:55 GMT 2017
Thanks for your message and links to your code. I like the name of the ’T’ object!
It’s Mac OS X El Capitan 10.11.4, and yes, a GUI application.
I do pretty much the same thing as you do with stderr and stdout, however, this issue is not specifically to do with stderr or stdout. The problem occurs when I do:
logging.info("testing ungültig”) # note the umlaut.
My worry is that this works fine in some cases (i.e. an interactive environment or when app is started post-qmake by pyqtdeploy itself) but in another case it fails (i.e. when the pyqtdeploy’ed app is double-clicked from Finder).
I’m wondering if there’s an environment variable that needs to be set (or something?) that hints that the world is in UTF-8…
It’s possibly just an education issue for me - maybe I need to figure out how to use Python Logging a bit better. I’m just not sure _why_ Logging would suddenly start thinking it’s appropriate to use an ASCII codec on a UTF-8 string.
> On 7 Feb 2017, at 14:28, Kyle Altendorf <sda at fstab.net> wrote:
> 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.
> 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.
More information about the PyQt