python-soundfile
python-soundfile copied to clipboard
Test if closefd argument works
From what I can see, closefd doesn't work at all. For example:
>>> import soundfile as sf
>>> f=open('test.wav', 'rb')
>>> ff = sf.SoundFile(f)
>>> f.closed
False
>>> ff.closed
False
>>> ff.close()
>>> ff.closed
True
>>> f.closed
False
This is from a test I did on the trunk.
The closefd argument is not supposed to have an effect if you use file-like objects.
It only comes into action if you use file descriptors. In Python you can get them for example with os.open(), but probably also from some external libraries.
You can get the underlying file descriptor of a Python file object with the fileno() method, but I don't know what happens to the file object if you close its file descriptor ...
BTW, this functionality is not implemented in Python, it is a feature of the libsndfile library itself.
Okay, I suspected that I wasn't understanding this feature correctly. I see now, thanks.