From e2c3bc34b042f9ffd90df281c3f9abc30b339095 Mon Sep 17 00:00:00 2001 From: Matthias Geier Date: Sat, 12 Oct 2024 11:15:03 +0200 Subject: [PATCH] Better error if frames/channels are non-integers --- sounddevice.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sounddevice.py b/sounddevice.py index 871cefe..ae0e1eb 100644 --- a/sounddevice.py +++ b/sounddevice.py @@ -2561,7 +2561,15 @@ def check_out(self, out, frames, channels, dtype, mapping): channels = len(np.atleast_1d(mapping)) if dtype is None: dtype = default.dtype['input'] - out = np.empty((frames, channels), dtype, order='C') + try: + out = np.empty((frames, channels), dtype, order='C') + except TypeError as e: + from numbers import Integral + if not isinstance(frames, Integral): + raise TypeError("'frames' must be an integer") from e + if not isinstance(channels, Integral): + raise TypeError("'channels' must be an integer") from e + raise e else: frames, channels = out.shape dtype = out.dtype