Skip to content

Commit 76fe59d

Browse files
committed
Return bytes in DeviceList.__repr__() for Python 2
Closes #30.
1 parent f8de5aa commit 76fe59d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

sounddevice.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,8 +1798,8 @@ def __repr__(self):
17981798
]
17991799
digits = len(str(_lib.Pa_GetDeviceCount() - 1))
18001800
hostapi_names = [hostapi['name'] for hostapi in query_hostapis()]
1801-
return '\n'.join(
1802-
"{mark} {idx:{dig}} {name}, {ha} ({ins} in, {outs} out)".format(
1801+
text = '\n'.join(
1802+
u"{mark} {idx:{dig}} {name}, {ha} ({ins} in, {outs} out)".format(
18031803
mark=(" ", ">", "<", "*")[(idx == idev) + 2 * (idx == odev)],
18041804
idx=idx,
18051805
dig=digits,
@@ -1808,6 +1808,9 @@ def __repr__(self):
18081808
ins=info['max_input_channels'],
18091809
outs=info['max_output_channels'])
18101810
for idx, info in enumerate(self))
1811+
if _sys.version_info.major < 3:
1812+
return text.encode(_sys.stdout.encoding or 'utf-8')
1813+
return text
18111814

18121815

18131816
class CallbackFlags(object):

0 commit comments

Comments
 (0)