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 committed Jun 6, 2023
1 parent 6982d81 commit 99f70c9
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 @@ -9,14 +9,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 99f70c9

Please sign in to comment.