bpo-32056: Improve exceptions in aifc, wave and sunau. (GH-5951)
(cherry picked from commit 134cb01cda50f02725575808130b05d2d776693f)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
diff --git a/Lib/sunau.py b/Lib/sunau.py
index dbad3db..129502b 100644
--- a/Lib/sunau.py
+++ b/Lib/sunau.py
@@ -208,6 +208,8 @@
raise Error('unknown encoding')
self._framerate = int(_read_u32(file))
self._nchannels = int(_read_u32(file))
+ if not self._nchannels:
+ raise Error('bad # of channels')
self._framesize = self._framesize * self._nchannels
if self._hdr_size > 24:
self._info = file.read(self._hdr_size - 24)