[ python-Bugs-1001053 ] wave.open() with unicode filename fails

SourceForge.net noreply at sourceforge.net
Mon Aug 2 00:48:18 CEST 2004


Bugs item #1001053, was opened at 2004-07-30 23:17
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1001053&group_id=5470

Category: Python Library
Group: Python 2.3
>Status: Closed
>Resolution: Accepted
Priority: 5
Submitted By: John Popplewell (johnnypops)
>Assigned to: Neal Norwitz (nnorwitz)
Summary: wave.open() with unicode filename fails

Initial Comment:
If you pass a unicode string to wave.open() it is treated as if it 
was an open file object and fails with an AttributeError. For 
example, the following code behaves correctly: 
 
import wave 
f = wave.open("sound.wav", "r") 
 
but this fails: 
 
import wave 
f = wave.open(u"sound.wav", "r") 
 
... 
AttributeError: 'unicode' object has no attribute 'read' 
 
The error occurs twice in the file 'wave.py' in the __init__ functions 
for Wave_read and Wave_write. 
 
I was playing with the unicode version of wxPython on Windows 
XP at the time, but the bug applies to other platforms as well.  
 
Hope the patch is of use, 
 
best regards, 
John. 
 
---8<--------------------------------------------------------------- 
158c158 
<         if type(f) == type(''): 
--- 
>         if isinstance(f, basestring): 
297c297 
<         if type(f) == type(''): 
--- 
>         if isinstance(f, basestring): 
 

----------------------------------------------------------------------

>Comment By: Neal Norwitz (nnorwitz)
Date: 2004-08-01 18:48

Message:
Logged In: YES 
user_id=33168

Thanks!

Checked in as Lib/wave.py 1.18

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1001053&group_id=5470


More information about the Python-bugs-list mailing list