Skip to content

Commit

Permalink
Catching AttributeError when repr(fifo) that hasn't had fifo.write(fr…
Browse files Browse the repository at this point in the history
…ame) called yet
  • Loading branch information
ekalosak authored and jlaine committed Oct 31, 2023
1 parent 24bcd1f commit 9078a1c
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions av/audio/fifo.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,21 @@ cdef class AudioFifo:
"""A simple audio sample FIFO (First In First Out) buffer."""

def __repr__(self):
return '<av.%s %s samples of %dhz %s %s at 0x%x>' % (
self.__class__.__name__,
self.samples,
self.sample_rate,
self.layout,
self.format,
id(self),
)
try:
result = '<av.%s %s samples of %dhz %s %s at 0x%x>' % (
self.__class__.__name__,
self.samples,
self.sample_rate,
self.layout,
self.format,
id(self),
)
except AttributeError:
result = '<av.%s uninitialized, use fifo.write(frame), at 0x%x>' % (
self.__class__.__name__,
id(self),
)
return result

def __dealloc__(self):
if self.ptr:
Expand Down

0 comments on commit 9078a1c

Please sign in to comment.