Example:
>>> ObjectId('some.words..')
ObjectId('736f6d652e776f7264696573')
>>> ObjectId(u'some.words..')
Traceback (most recent call last):
[...]
raise InvalidId("%s is not a valid ObjectId" % oid)
bson.errors.InvalidId: some.wordies is not a valid ObjectId
I'm not sure whether this would be considered a bug or whether it's strictly intentional, but from the point of view of an application developer, I find it very confusing that the ObjectId constructor doesn't handle `str` and `unicode` the same. I ran into it in using a library (Eve) which uses the constructor as a way to check whether a string can be an ObjectId or not. It was particularly mysterious because it only happens for strings of length 12, so it has the potential to cause bugs in applications which would go undetected by tests unless someone happened to pick a 12-letter test string (as I did).
Thanks!