diff options
| author | Matthias Geier <Matthias.Geier@gmail.com> | 2016-08-02 09:12:13 +0200 |
|---|---|---|
| committer | Matthias Geier <Matthias.Geier@gmail.com> | 2016-08-02 09:55:53 +0200 |
| commit | 76fe59d45bac5b4be16a7cb48f2cf26ba8d0b2aa (patch) | |
| tree | 0bcc8fab2d34ea39a23934a0341981ec1949dc39 | |
| parent | f8de5aa7d784d8801413abadca1903accbdc0fbd (diff) | |
Return bytes in DeviceList.__repr__() for Python 2
Closes #30.
| -rw-r--r-- | sounddevice.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sounddevice.py b/sounddevice.py index 3a40486..874054a 100644 --- a/sounddevice.py +++ b/sounddevice.py @@ -1798,8 +1798,8 @@ class DeviceList(tuple): ] digits = len(str(_lib.Pa_GetDeviceCount() - 1)) hostapi_names = [hostapi['name'] for hostapi in query_hostapis()] - return '\n'.join( - "{mark} {idx:{dig}} {name}, {ha} ({ins} in, {outs} out)".format( + text = '\n'.join( + u"{mark} {idx:{dig}} {name}, {ha} ({ins} in, {outs} out)".format( mark=(" ", ">", "<", "*")[(idx == idev) + 2 * (idx == odev)], idx=idx, dig=digits, @@ -1808,6 +1808,9 @@ class DeviceList(tuple): ins=info['max_input_channels'], outs=info['max_output_channels']) for idx, info in enumerate(self)) + if _sys.version_info.major < 3: + return text.encode(_sys.stdout.encoding or 'utf-8') + return text class CallbackFlags(object): |
