Skip to content

Commit 5e9a075

Browse files
committed
Store file-like object as SoundFile.name
... instead of storing only the "name" attribute of the file-like object. __repr__() shows the repr() of the file name/file descriptor/file-like object and the repr() of the mode and format strings.
1 parent ee60d3a commit 5e9a075

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pysoundfile.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -636,10 +636,10 @@ def __init__(self, file, mode='r', samplerate=None, channels=None,
636636
mode_int = _snd.SFM_WRITE
637637

638638
old_fmt = format
639-
self._name = getattr(file, 'name', file)
639+
self._name = file
640640
if format is None:
641-
format = str(self.name).rsplit('.', 1)[-1].upper()
642-
if format not in _formats and 'r' not in modes:
641+
format = str(getattr(file, 'name', file)).rsplit('.', 1)[-1]
642+
if format.upper() not in _formats and 'r' not in modes:
643643
raise TypeError(
644644
"No format specified and unable to get format from "
645645
"file extension: %s" % repr(self.name))
@@ -718,8 +718,8 @@ def __init__(self, file, mode='r', samplerate=None, channels=None,
718718
_file = None
719719

720720
def __repr__(self):
721-
return ('SoundFile("%s", mode="%s", samplerate=%i, channels=%i, '
722-
'format="%s", subtype="%s", endian="%s")' %
721+
return ('SoundFile(%r, mode=%r, samplerate=%i, channels=%i, '
722+
'format=%r, subtype=%r, endian=%r)' %
723723
(self.name, self.mode, self.samplerate, self.channels,
724724
self.format, self.subtype, self.endian))
725725

0 commit comments

Comments
 (0)