views:

49

answers:

1

Usually one comes across this problem in python3.0 while attempting a split() method on a bytes type object.

TypeError: Type str does'nt support the buffer API

This issue can be resolved by using the split method after decoding the bytes type object.

However, I find the error message rather ambiguous. Am I missing some underlying concept or do you think the message is ambiguous too?(If more people think so, maybe we could ask for a fix)

+9  A: 

Just forget the existence of totally-obsolete, zero-reasons-to-keep-it-around 3.0, upgrade to 3.1 instead, and splitting bytes is just fine:

>>> x = bytes(b'ciao bella')
>>> x.split()
[b'ciao', b'bella']
Alex Martelli