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

Cannot customize the codec_options value of MongoClient

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.4
    • Affects Version/s: 3.3
    • Component/s: None
    • Fully Compatible

      TL;DR: The MongoClient class has a codec_options property, which is used as the default CodecOptions for all operations using that client unless explicitly stated otherwise. There is currently no way for the user to change two properties of MongoClient.codec_options, namely unicode_decode_error_handler and tzinfo, since they have not been added to pymongo.common.VALIDATORS.

      Going into more details:

      • the codec_options property of MongoClient is set on line 377, which takes the value of options.codec_options. options itself is a ClientOptions object which was created on line 363.
      • within the ClientOptions class, the codec_options property is set on line 128, which calls the bson.codec_options._parse_codec_options method, with the input being the options parameter of the constructor. _parse_codec_options reads the following properties of options to to create a customized CodecOptions object:
        • document_class
        • tz_aware
        • uuidrepresentation
        • unicode_decode_error_handler
        • tzinfo
      • within the context of the MongoClient constructor, the value of that parameter is given by the opts variable, which is a dictionary of validated client options. However, this opts variable cannot contain two of the properties listed above, since neither unicode_decode_error_handler nor tzinfo are part of pymongo.common.VALIDATORS.

            Assignee:
            luke.lovett Luke Lovett
            Reporter:
            oxymor0n William Tran
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: