From 35cc78627299507497ce68a998246bc71691addb Mon Sep 17 00:00:00 2001 From: Brendan Fahy Date: Mon, 18 Jul 2022 18:00:45 -0400 Subject: [PATCH 1/4] Make `_wave_params` public -> `wave_params` This namedtuple is the public interface for Wave_write.setparams, making this private does not allow users to create an input that is typechecked to Wave_write.setparams. Is there a reason to want to hide this from users to make it less readable for how to call Wave_write.setparams ? --- Lib/wave.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Lib/wave.py b/Lib/wave.py index 9a4557487b6e63..ff915d63d3ac69 100644 --- a/Lib/wave.py +++ b/Lib/wave.py @@ -86,8 +86,8 @@ class Error(Exception): _array_fmts = None, 'b', 'h', None, 'i' -_wave_params = namedtuple('_wave_params', - 'nchannels sampwidth framerate nframes comptype compname') +wave_params = namedtuple('wave_params', + 'nchannels sampwidth framerate nframes comptype compname') def _byteswap(data, width): swapped_data = bytearray(len(data)) @@ -335,9 +335,9 @@ def getcompname(self): return self._compname def getparams(self): - return _wave_params(self.getnchannels(), self.getsampwidth(), - self.getframerate(), self.getnframes(), - self.getcomptype(), self.getcompname()) + return wave_params(self.getnchannels(), self.getsampwidth(), + self.getframerate(), self.getnframes(), + self.getcomptype(), self.getcompname()) def getmarkers(self): return None @@ -526,7 +526,7 @@ def setparams(self, params): def getparams(self): if not self._nchannels or not self._sampwidth or not self._framerate: raise Error('not all parameters set') - return _wave_params(self._nchannels, self._sampwidth, self._framerate, + return wave_params(self._nchannels, self._sampwidth, self._framerate, self._nframes, self._comptype, self._compname) def setmark(self, id, pos, name): From 1e1beaa255d95e15fd1b38f6b18b6027fce4ff26 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Tue, 19 Jul 2022 02:20:30 +0000 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2022-07-19-02-20-29.gh-issue-94991.kRGnFh.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2022-07-19-02-20-29.gh-issue-94991.kRGnFh.rst diff --git a/Misc/NEWS.d/next/Library/2022-07-19-02-20-29.gh-issue-94991.kRGnFh.rst b/Misc/NEWS.d/next/Library/2022-07-19-02-20-29.gh-issue-94991.kRGnFh.rst new file mode 100644 index 00000000000000..0de97369aa8892 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-07-19-02-20-29.gh-issue-94991.kRGnFh.rst @@ -0,0 +1 @@ +Make wave._wave_params public From c01cc8ca3767c5db68db0a49b7967cf31f00251d Mon Sep 17 00:00:00 2001 From: Brendan Fahy Date: Mon, 18 Jul 2022 22:42:18 -0400 Subject: [PATCH 3/4] add the now public wave_params to __all__ --- Lib/wave.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/wave.py b/Lib/wave.py index ff915d63d3ac69..7e22dab61bed4c 100644 --- a/Lib/wave.py +++ b/Lib/wave.py @@ -77,7 +77,7 @@ import sys -__all__ = ["open", "Error", "Wave_read", "Wave_write"] +__all__ = ["open", "Error", "Wave_read", "Wave_write", "wave_params"] class Error(Exception): pass From 3938ef3383198ade0c72f2872bdd158bd0337001 Mon Sep 17 00:00:00 2001 From: Brendan Fahy Date: Tue, 19 Jul 2022 16:57:13 -0400 Subject: [PATCH 4/4] add an alias to keep compatibility if anyone used the private type --- Lib/wave.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/wave.py b/Lib/wave.py index 7e22dab61bed4c..cca13738187632 100644 --- a/Lib/wave.py +++ b/Lib/wave.py @@ -88,6 +88,7 @@ class Error(Exception): wave_params = namedtuple('wave_params', 'nchannels sampwidth framerate nframes comptype compname') +_wave_params = wave_params # alias to keep compatibility def _byteswap(data, width): swapped_data = bytearray(len(data))