Skip to content

Commit

Permalink
Remove all deprecated methods and some deprecated attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
WyattBlue committed Oct 25, 2023
1 parent 6605975 commit 4bea102
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 59 deletions.
15 changes: 0 additions & 15 deletions av/buffer.pyx
Original file line number Diff line number Diff line change
@@ -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


Expand Down Expand Up @@ -29,20 +28,6 @@ cdef class Buffer:
"""The memory address of the buffer."""
return <size_t>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 <https://docs.python.org/3/c-api/buffer.html>`_
as that will be more efficient.
This is largely for Python2, as Python 3 can do the same via
``bytes(the_buffer)``.
"""
return <bytes>(<char*>self._buffer_ptr())[:self._buffer_size()]

def update(self, input):
"""Replace the data in this object with the given buffer.
Expand Down
15 changes: 0 additions & 15 deletions av/packet.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down Expand Up @@ -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
Expand Down
11 changes: 0 additions & 11 deletions av/stream.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ from av.utils cimport (
to_avrational
)

from av.deprecation import AVDeprecationWarning


cdef object _cinit_bypass_sentinel = object()

Expand Down Expand Up @@ -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

Expand Down
18 changes: 0 additions & 18 deletions tests/test_file_probing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from fractions import Fraction
import warnings

import av

Expand All @@ -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(
"<av.AudioStream #0 aac_latm at 48000Hz, stereo, fltp at "
Expand Down Expand Up @@ -90,7 +88,6 @@ def test_container_probing(self):
def test_stream_probing(self):
stream = self.file.streams[0]

# ensure __repr__ does not crash
self.assertTrue(
str(stream).startswith(
"<av.AudioStream #0 flac at 0Hz, 0 channels, None at "
Expand Down Expand Up @@ -154,7 +151,6 @@ def test_container_probing(self):
None,
),
("modification_date", "2016-09-20T20:33:26.000000Z", None),
# Next one is FFmpeg >= 4.2.
(
"operational_pattern_ul",
"060e2b34.04010102.0d010201.10030000",
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 4bea102

Please sign in to comment.