You are using the wrong opening.
>>> help(open) Help on built-in function open in module __builtin__: open(...) open(name[, mode[, buffering]]) -> file object Open a file using the file() type, returns a file object. This is the preferred way to open a file. See file.__doc__ for further information.
As you can see, it expects the buffering parameter to be an integer.
What you might want is codecs.open :
open(filename, mode='rb', encoding=None, errors='strict', buffering=1)
source share