Re - Contradictory error messages in Python 3.4 - standard library issue!

Ned Batchelder ned at nedbatchelder.com
Thu Jun 16 19:03:40 EDT 2016


On Thursday, June 16, 2016 at 6:39:27 PM UTC-4, Harrison Chudleigh wrote:
> Sorry! I was trying to indent a line and accidentally sent only half of the
> message.
> 
> As I was saying, I changed the line and reran the program. However, this
> produced another group of error messages. One was -
> File
> "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tokenize.py",
> line 438, in open
>     encoding, lines = detect_encoding(buffer.readline)
>   File
> "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tokenize.py",
> line 409, in detect_encoding
>     if first.startswith('BOM_UTF8'):
> TypeError: startswith first arg must be bytes or a tuple of bytes, not str.
> So, first the interpreter says startswith() takes strings, now it says it
> takes bytes? What should the module be doing?
> This is an error with the standard library of Python 3.4.1, Mac OS X.

You shouldn't have to edit the stdlib files to get your program to work.
It sounds like you are using values with the tokenize module that it isn't
expecting. Can you show your code?

--Ned.



More information about the Python-list mailing list