Author rpyle
Recipients BreamoreBoy, rpyle
Date 2010-07-09.15:27:42
SpamBayes Score 0.00233382
Marked as misclassified No
Message-id <37E33902-D5CA-42EA-B92C-C540F3260089@post.harvard.edu>
In-reply-to <1278629523.45.0.693065589089.issue5024@psf.upfronthosting.co.za>
Content
On Jul 8, 2010, at 6:52 PM, Mark Lawrence wrote:

>
> Mark Lawrence <breamoreboy@yahoo.co.uk> added the comment:
>
> Robert, could you provide a patch for this?
>
> ----------
> nosy: +BreamoreBoy
> stage:  -> needs patch
> versions: +Python 3.2
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue5024>
> _______________________________________

Okay, I'm not sure exactly how I'm supposed to go about this.  Here's  
the output from diff <new file> <original file> for sndhdr.py

131d130
<     import wave
135,141c134,138
<     f.seek(0)
<     try:
<         w = wave.openfp(f, 'r')
<     except (EOFError, wave.Error):
<         return None
<     return ('wav', w.getframerate(), w.getnchannels(), \
<             w.getnframes(), 8*w.getsampwidth())
---
 >     style = get_short_le(h[20:22])
 >     nchannels = get_short_le(h[22:24])
 >     rate = get_long_le(h[24:28])
 >     sample_bits = get_short_le(h[34:36])
 >     return 'wav', rate, nchannels, -1, sample_bits
$

All I did was use test_aifc() as inspiration, so the patched sndhdr.py  
calls wave.py to get the file parameters.

Here's the new test_wav() in its entirety:

--------------------------------
def test_wav(h, f):
     import wave
     # 'RIFF' <len> 'WAVE' 'fmt ' <len>
     if h[:4] != 'RIFF' or h[8:12] != 'WAVE' or h[12:16] != 'fmt ':
         return None
     f.seek(0)
     try:
         w = wave.openfp(f, 'r')
     except (EOFError, wave.Error):
         return None
     return ('wav', w.getframerate(), w.getnchannels(), \
             w.getnframes(), 8*w.getsampwidth())
--------------------------------

If you want anything else, please ask.

Bob Pyle
History
Date User Action Args
2010-07-09 15:27:44rpylesetrecipients: + rpyle, BreamoreBoy
2010-07-09 15:27:42rpylelinkissue5024 messages
2010-07-09 15:27:42rpylecreate