Apology to Bill Gates (was Re: ASV module, CVS modules)

John Machin sjmachin at lexicon.net
Fri Mar 1 07:07:26 EST 2002


sjmachin at lexicon.net (John Machin) wrote in message news:<c76ff6fc.0202282132.569aef5a at posting.google.com>...
> >     my_data.input_from_file("c:\test_data.csv", ASV.CSV(),
> >   File "C:\PYTHON22\ASV.py", line 222, in input_from_file
> >     file = open(input_file, "rb")
> > IOError: invalid argument: rb
> Bill behaving badly: Seems like Bill chucks a wobbly if there is
> a_bloody_tab_character in a file name. I could be maligning Bill
> unjustly; could be GvR & Co -- I'll have a look at the Python source
> in a minute -- but I'd bet a couple of pots of beer that it's down to
> Bill.

Looks like the Windows compiler runtimes, enforcing the (sensible,
IMO) Windows rule that file names shouldn't have "unprintable"
characters in them, are faced with signalling the error with a
least-bad choice of errno: ENOENT ("No such file or directory") or
EINVAL ("Invalid argument"). Borland chose ENOENT, MS chose EINVAL.

Python, starting from a Unix background, where there is evidently no
such thing as an invalid character in a file name, can only imagine
that EINVAL must refer to the mode argument, and in fact special-cases
EINVAL (see below) to produce the error message that baffled (inter
alia) the OP.

if (errno == EINVAL)
    PyErr_Format(PyExc_IOError, "invalid argument: %s", mode);
else
    PyErr_SetFromErrnoWithFilename(PyExc_IOError, name);

However given what Tim P. said in a recent posting, I won't add to the
patching bottleneck by rushing off to file an enhancement request on
this one.



More information about the Python-list mailing list