Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-1160

Fix MongoClient.__repr__ when using Unix domain sockets

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 3.4
    • Affects Version/s: None
    • Component/s: None
    • None

      If i start a mongos with --bind_ip 127.0.0.1 --port 20000, a unix socket is created at /tmp/mongodb-20000.sock, but i get this error:

      >>> import pymongo
      >>> pymongo.version
      '3.3.0'
      >>> pm = pymongo.MongoClient(host='/tmp/mongodb-20000.sock')
      >>> pm
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
        File "/usr/local/lib/python2.7/dist-packages/pymongo/mongo_client.py", line 909, in __repr__
          return ("MongoClient(%s)" % (self._repr_helper(),))
        File "/usr/local/lib/python2.7/dist-packages/pymongo/mongo_client.py", line 896, in _repr_helper
          for host, port in self._topology_settings.seeds]]
      TypeError: %d format: a number is required, not NoneType
      

      Some things seem to work though:

      >>> pm.somedb.somecol.find_one()
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
        File "/usr/local/lib/python2.7/dist-packages/pymongo/collection.py", line 1014, in find_one
          for result in cursor.limit(-1):
        File "/usr/local/lib/python2.7/dist-packages/pymongo/cursor.py", line 1090, in next
          if len(self.__data) or self._refresh():
        File "/usr/local/lib/python2.7/dist-packages/pymongo/cursor.py", line 1012, in _refresh
          self.__read_concern))
        File "/usr/local/lib/python2.7/dist-packages/pymongo/cursor.py", line 905, in __send_message
          helpers._check_command_response(doc['data'][0])
        File "/usr/local/lib/python2.7/dist-packages/pymongo/helpers.py", line 205, in _check_command_response
          raise OperationFailure(msg % errmsg, code, response)
      pymongo.errors.OperationFailure: not authorized on somedb to execute command { find: "somecol", filter: {}, limit: 1, singleBatch: true }
      

      Because authentication is required.

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            thestick613 Tudor Aursulesei
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: