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

Documentation and code don't match for class bson.binary.Binary

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

      The documentation states that the bson.binary.Binary class is instantiated with a default subtype of BINARY_SUBTYPE if not otherwise defined.

      Relevant documentation URL: http://api.mongodb.org/python/1.9%2B/api/bson/binary.html?highlight=binary#bson.binary.Binary

      The source, on the other hand, shows that the default subtype for this class is OLD_BINARY_SUBTYPE:

      def _new_(cls, data, subtype=OLD_BINARY_SUBTYPE):
      if not isinstance(data, str):
      raise TypeError("data must be an instance of str")
      if not isinstance(subtype, int):
      raise TypeError("subtype must be an instance of int")
      if subtype >= 256 or subtype < 0:
      raise ValueError("subtype must be contained in [0, 256)")
      self = str._new_(cls, data)
      self.__subtype = subtype
      return self

      Based upon a statement in the documentation (bson.binary.BINARY_SUBTYPE - "This is becomming the default subtype and should be the most commonly used."), it seems the source should be changed to default to BINARY_SUBTYPE instead of OLD_BINARY_SUBTYPE.

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            swindmill Sterling Windmill
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: