diff options
| author | Matthias Geier <Matthias.Geier@gmail.com> | 2024-10-12 11:15:03 +0200 |
|---|---|---|
| committer | Matthias Geier <Matthias.Geier@gmail.com> | 2024-10-15 19:43:33 +0200 |
| commit | f37a6ef214e7bea507cb23b76e9d4f47f9795d93 (patch) | |
| tree | 4ecfd58bb20323784a6436d4c710c2106cd46e19 | |
| parent | 25894e326fce2dd8b5172624b621c32a3550c5b4 (diff) | |
Better error if frames/channels are non-integers
| -rw-r--r-- | sounddevice.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/sounddevice.py b/sounddevice.py index 2d0114d..0974289 100644 --- a/sounddevice.py +++ b/sounddevice.py @@ -2561,7 +2561,15 @@ class _CallbackContext: 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 |
