Exception is raise when authenticate fails and user includes percent sign '%'.
Example of code to reproduce the issue:
from pymongo import MongoClient client = MongoClient("127.0.0.1") admin_db = client.admin admin_db.authenticate("abc%", "cba%")
The problem line is https://github.com/mongodb/mongo-python-driver/blob/master/pymongo/helpers.py#L178
raise OperationFailure(msg % errmsg, code, response)
In my case msg is "command SON ( [ ( 'authenticate', 1), ('user', u'abc%'), ('nonce', u'd8eec066dd2c61c0'), ('key', u'7e11b80df608cbc9a38d0403da9333f2')]) failed: %s"
I.e. this string includes symbols %' which can be formatted by python. So escaping is needed.