New submission from Alastair Porter:

Passing a unicode filename to aifc.open() results in the argument being treated 
like a filepointer instead of opening the file.

The argument check,
http://hg.python.org/cpython/file/default/Lib/aifc.py#l332
only checks if the argument is a str. Should this be extended to accept all 
string-type objects?

Example usage:
>>> import aifc
>>> aifc.open(u"/some/path")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/aifc.py",
 line 924, in open
    return Aifc_read(f)
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/aifc.py",
 line 335, in __init__
    self.initfp(f)
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/aifc.py",
 line 286, in initfp
    chunk = Chunk(file)
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/chunk.py",
 line 61, in __init__
    self.chunkname = file.read(4)
AttributeError: 'unicode' object has no attribute 'read'

----------
components: None
messages: 169673
nosy: alastairp
priority: normal
severity: normal
status: open
title: aifc.open expects only str or file pointer
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue15843>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to