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

Remove uuidRepresentation deprecation warnings

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.11
    • Affects Version/s: None
    • Component/s: None
    • None

      We should stop raising DeprecationWarning when no UuidRepresentation has been specified by the user.

      Note that a similar warning will be added back to PyMongo 3.12 as part of PYTHON-2309 to aid users in transitioning from PyMongo 3.x to PyMongo 4.x.


      Original Description

      We should improve the uuidRepresentation deprecation warnings added in PYTHON-2152. For example, this should raise a warning but doesn’t:

      >>> import bson
      >>> bson.encode({'u': uuid.uuid4()})
      b'\x1d\x00\x00\x00\x05u\x00\x10\x00\x00\x00\x03W\xbd\xdchssDr\x86\x1e\x07i\xe1\xa2\xc4B\x00'
      

      Same for bson.decode(), and json_util.loads/dumps when encoding/decoding UUIDs with the default options.

      Another area to improve is that creating a MongoClient seems to cause a warning to be created but it’s attributed to codec_options.py. It’ll be hard for users to diagnose this warning:

      >>> c = MongoClient()
      /Users/shane/git/mongo-python-driver/bson/codec_options.py:333: DeprecationWarning: Starting in PyMongo 4.0, the default uuidRepresentation will be changed to 'unspecified'. Applications will need to explicitly set 'uuidRepresentation=pythonLegacy' in the connection string to preserve current behavior.
        return CodecOptions(
      

      Instead the DeprecationWarning should point to line where the MongoClient was created.

            Assignee:
            prashant.mital Prashant Mital (Inactive)
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: