[Python-bugs-list] [ python-Bugs-476593 ] Bad mode for opening file gives bad msg.
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 30 Oct 2001 17:27:58 -0800
Bugs item #476593, was opened at 2001-10-30 17:27
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=476593&group_id=5470
Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Gregory H. Ball (greg_ball)
Assigned to: Nobody/Anonymous (nobody)
Summary: Bad mode for opening file gives bad msg.
Initial Comment:
Calling the open (or file) builtin with an incorrect
mode
(for example, 'bw' or 's') causes an exception which
claims that the filename is invalid.
>>> open('tmp','s')
Traceback (innermost last):
File "<stdin>", line 1, in ?
IOError: [Errno 22] Invalid argument: 'tmp'
(double spaced in hopes of preserving line breaks)
It comes down to this call:
PyErr_SetFromErrnoWithFilename(PyExc_IOError, name);
which assumes that the filename is relevant to any
IOError
that pops up.
man fopen on linux says:
EINVAL The mode provided to fopen, fdopen, or freopen
was
invalid.
so it seems possible to catch this case, but not
without making the code more complex.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=476593&group_id=5470