From c1ff68f95b5ef6d63f45df4fa9ceaae11a2603ff Mon Sep 17 00:00:00 2001 From: Hiroyuki Sogo Date: Tue, 18 Apr 2017 19:48:23 +0900 Subject: [PATCH] BF: Non-ASCII audio driver names causes error --- psychopy/sound/__init__.py | 2 +- psychopy/sound/backend_pyo.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/psychopy/sound/__init__.py b/psychopy/sound/__init__.py index 25d7c14cb5..afcd88b69c 100644 --- a/psychopy/sound/__init__.py +++ b/psychopy/sound/__init__.py @@ -139,7 +139,7 @@ def setDevice(dev, kind=None): pass # do nothing elif dev not in backend.getDevices(kind='output'): devNames = backend.getDevices(kind='output').keys() - logging.error("Requested audio device '{}' that is not available on " + logging.error(u"Requested audio device '{}' that is not available on " "this hardware. The 'audioDevice' preference should be one of " "{}".format(dev, devNames)) else: diff --git a/psychopy/sound/backend_pyo.py b/psychopy/sound/backend_pyo.py index 0df32e583d..149d0156c9 100644 --- a/psychopy/sound/backend_pyo.py +++ b/psychopy/sound/backend_pyo.py @@ -54,6 +54,7 @@ def getDevices(kind=None): The dict keys are names and items are dicts of properties """ + osEncoding = sys.getfilesystemencoding() inputs, outputs = pyo.pa_get_devices_infos() if kind is None: allDevs = inputs.update(outputs) @@ -64,7 +65,8 @@ def getDevices(kind=None): devs = {} for ii in allDevs: # in pyo this is a dict but keys are ii ! :-/ dev = allDevs[ii] - devs[dev['name']] = dev + devName = dev['name'].decode(osEncoding) # convert to unicode + devs[devName] = dev dev['id'] = ii return devs