Skip to content

Commit e2c3bc3

Browse files
committed
Better error if frames/channels are non-integers
1 parent 6989362 commit e2c3bc3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

sounddevice.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2561,7 +2561,15 @@ def check_out(self, out, frames, channels, dtype, mapping):
25612561
channels = len(np.atleast_1d(mapping))
25622562
if dtype is None:
25632563
dtype = default.dtype['input']
2564-
out = np.empty((frames, channels), dtype, order='C')
2564+
try:
2565+
out = np.empty((frames, channels), dtype, order='C')
2566+
except TypeError as e:
2567+
from numbers import Integral
2568+
if not isinstance(frames, Integral):
2569+
raise TypeError("'frames' must be an integer") from e
2570+
if not isinstance(channels, Integral):
2571+
raise TypeError("'channels' must be an integer") from e
2572+
raise e
25652573
else:
25662574
frames, channels = out.shape
25672575
dtype = out.dtype

0 commit comments

Comments
 (0)