From 100abeb812ac3ec59efcad1cb062b462f2e2d2a6 Mon Sep 17 00:00:00 2001 From: Roel Postelmans Date: Sat, 21 Oct 2017 09:49:21 +0200 Subject: Support for Unicode strings onPython 2.x (#104) * Support unicode strings * Added python 3.x support for basestring * The analog to basestring in python3 is a combination of bytes and str --- sounddevice.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sounddevice.py b/sounddevice.py index c548286..c73d94c 100644 --- a/sounddevice.py +++ b/sounddevice.py @@ -60,6 +60,11 @@ _sampleformats = { _initialized = 0 _last_callback = None +try: + _basestring = basestring +except NameError: + _basestring = (str, bytes) + def play(data, samplerate=None, mapping=None, blocking=False, loop=False, **kwargs): @@ -2497,7 +2502,7 @@ def _array(buffer, channels, dtype): def _split(value): """Split input/output value into two values.""" - if isinstance(value, str): + if isinstance(value, _basestring): # iterable, but not meant for splitting return value, value try: -- cgit v1.2.3