From 501ccab1057dd1722d8d575d59a3f17153d11547 Mon Sep 17 00:00:00 2001 From: Bastian Bechtold Date: Fri, 28 Nov 2014 14:50:47 +0100 Subject: [PATCH 1/2] added deprecation warning to indexing operations --- pysoundfile.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pysoundfile.py b/pysoundfile.py index 948fa2e..ada39b9 100644 --- a/pysoundfile.py +++ b/pysoundfile.py @@ -756,6 +756,9 @@ def __len__(self): def __getitem__(self, frame): # access the file as if it where a Numpy array. The data is # returned as numpy array. + from warnings import warn + warn('indexing has been deprecated and will be removed in the future', + DeprecationWarning) second_frame = None if isinstance(frame, tuple): if len(frame) > 2: @@ -776,6 +779,9 @@ def __setitem__(self, frame, data): # access the file as if it where a one-dimensional Numpy # array. Data must be in the form (frames x channels). # Both open slice bounds and negative values are allowed. + from warnings import warn + warn('indexing has been deprecated and will be removed in the future', + DeprecationWarning) start, stop = self._get_slice_bounds(frame) if stop - start != len(data): raise IndexError( From d2badea5aae571b329959c4d2b352db03f7b5202 Mon Sep 17 00:00:00 2001 From: Bastian Bechtold Date: Mon, 1 Dec 2014 10:15:54 +0100 Subject: [PATCH 2/2] elevated DeprecationWarning to plain Warning since DeprecationWarnings are by default not visible to users, and this is a user-visible feature. --- pysoundfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pysoundfile.py b/pysoundfile.py index ada39b9..c44bfce 100644 --- a/pysoundfile.py +++ b/pysoundfile.py @@ -758,7 +758,7 @@ def __getitem__(self, frame): # returned as numpy array. from warnings import warn warn('indexing has been deprecated and will be removed in the future', - DeprecationWarning) + Warning) second_frame = None if isinstance(frame, tuple): if len(frame) > 2: @@ -781,7 +781,7 @@ def __setitem__(self, frame, data): # Both open slice bounds and negative values are allowed. from warnings import warn warn('indexing has been deprecated and will be removed in the future', - DeprecationWarning) + Warning) start, stop = self._get_slice_bounds(frame) if stop - start != len(data): raise IndexError(