From 4bea10247262ef04b6aa091baec15b7f866c8b35 Mon Sep 17 00:00:00 2001 From: WyattBlue Date: Wed, 25 Oct 2023 17:44:53 -0400 Subject: [PATCH] Remove all deprecated methods and some deprecated attributes --- av/buffer.pyx | 15 --------------- av/packet.pyx | 15 --------------- av/stream.pyx | 11 ----------- tests/test_file_probing.py | 18 ------------------ 4 files changed, 59 deletions(-) diff --git a/av/buffer.pyx b/av/buffer.pyx index 19912815c..e8b94df8d 100644 --- a/av/buffer.pyx +++ b/av/buffer.pyx @@ -1,7 +1,6 @@ from cpython cimport PyBUF_WRITABLE, PyBuffer_FillInfo from libc.string cimport memcpy -from av import deprecation from av.bytesource cimport ByteSource, bytesource @@ -29,20 +28,6 @@ cdef class Buffer: """The memory address of the buffer.""" return self._buffer_ptr() - @deprecation.method - def to_bytes(self): - """Return the contents of this buffer as ``bytes``. - - This copies the entire contents; consider using something that uses - the `buffer protocol `_ - as that will be more efficient. - - This is largely for Python2, as Python 3 can do the same via - ``bytes(the_buffer)``. - - """ - return (self._buffer_ptr())[:self._buffer_size()] - def update(self, input): """Replace the data in this object with the given buffer. diff --git a/av/packet.pyx b/av/packet.pyx index a7b450a7d..f5286d221 100644 --- a/av/packet.pyx +++ b/av/packet.pyx @@ -4,8 +4,6 @@ from av.bytesource cimport bytesource from av.error cimport err_check from av.utils cimport avrational_to_fraction, to_avrational -from av import deprecation - cdef class Packet(Buffer): @@ -84,19 +82,6 @@ cdef class Packet(Buffer): """ return self._stream.decode(self) - @deprecation.method - def decode_one(self): - """ - Send the packet's data to the decoder and return the first decoded frame. - - Returns ``None`` if there is no frame. - - .. warning:: This method is deprecated, as it silently discards any - other frames which were decoded. - """ - res = self._stream.decode(self) - return res[0] if res else None - property stream_index: def __get__(self): return self.ptr.stream_index diff --git a/av/stream.pyx b/av/stream.pyx index 0d93bff51..7fd1962b1 100644 --- a/av/stream.pyx +++ b/av/stream.pyx @@ -16,8 +16,6 @@ from av.utils cimport ( to_avrational ) -from av.deprecation import AVDeprecationWarning - cdef object _cinit_bypass_sentinel = object() @@ -116,15 +114,6 @@ cdef class Stream: ) def __getattr__(self, name): - # Deprecate framerate pass-through as it is not always set. - # See: https://github.com/PyAV-Org/PyAV/issues/1005 - if self.ptr.codecpar.codec_type == lib.AVMEDIA_TYPE_VIDEO and name in ("framerate", "rate"): - warnings.warn( - "VideoStream.%s is deprecated as it is not always set; please use VideoStream.average_rate." % name, - AVDeprecationWarning - ) - - if name == 'side_data': return self.side_data diff --git a/tests/test_file_probing.py b/tests/test_file_probing.py index c67f7fb8e..2d6c87257 100644 --- a/tests/test_file_probing.py +++ b/tests/test_file_probing.py @@ -1,5 +1,4 @@ from fractions import Fraction -import warnings import av @@ -26,7 +25,6 @@ def test_container_probing(self): def test_stream_probing(self): stream = self.file.streams[0] - # check __repr__ self.assertTrue( str(stream).startswith( "= 4.2. ( "operational_pattern_ul", "060e2b34.04010102.0d010201.10030000", @@ -320,20 +316,6 @@ def test_stream_probing(self): self.assertIn(stream.coded_width, (720, 0)) self.assertIn(stream.coded_height, (576, 0)) - # Deprecated properties. - with warnings.catch_warnings(record=True) as captured: - self.assertIsNone(stream.framerate) - self.assertEqual( - captured[0].message.args[0], - "VideoStream.framerate is deprecated as it is not always set; please use VideoStream.average_rate.", - ) - with warnings.catch_warnings(record=True) as captured: - self.assertIsNone(stream.rate) - self.assertEqual( - captured[0].message.args[0], - "VideoStream.rate is deprecated as it is not always set; please use VideoStream.average_rate.", - ) - class TestVideoProbeCorrupt(TestCase): def setUp(self):