Skip to content Skip to sidebar Skip to footer

"typeerror: Bad Argument Type For Built-in Operation"

In what cases would Python throw this error: 'TypeError: bad argument type for built-in operation' The error was reported in this line of code: csv.reader(open(file_name), dialect

Solution 1:

The csv.reader in Python 2.4 has known bugs; see http://mail.python.org/pipermail/tutor/2008-January/059758.html

In general, "bad argument type for built-in operation" crops up all over the place because it's the exception text generated by PyErr_BadArgument CPython API call. This means that the traceback won't be much use because the exception is raised in C code. Your best bet for debugging is to run Python under a debugger and set a breakpoint on PyErr_BadArgument.

Solution 2:

My guess is that file_name is a bool instead of a string or buffer like open() expects. I wouldn't be very concerned with the differing messages; they are both TypeErrors, one just happens to be more specific than the other, probably because of some difference in Python version.

Post a Comment for ""typeerror: Bad Argument Type For Built-in Operation""