"TypeError: bad argument type for built-in operation"

10,823

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.

Share:
10,823
Facundo Casco
Author by

Facundo Casco

When I was 6 my father told me that there was a machine that could record my favorite TV show automatically so I didn't miss it while at school. I knew then that I wanted to learn everything about this new machines and know how to use them to give us new powers. That machine was just a VCR but for me was the power of electronics working for us. Since then I keep having the same feeling of power and awe every time I learn how to use some new technology to work for us. We live in an era where technology shapes all aspects of our everyday life and its changing with a speed never seen before. I love surfing this new wave watching it unravel before our eyes and using some of this new power to improve our lives. Get in touch and lets find out how we can work together building the tools people will love to use.

Updated on June 04, 2022

Comments

  • Facundo Casco
    Facundo Casco almost 2 years

    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=dialect)
    

    I've tried to reproduce it but the closest I got was this error:

    "TypeError: coercing to Unicode: need string or buffer, bool found"
    

    I've tried with Python2.7 and Python 2.5 on Linux and Python 2.4 on Windows XP