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.
- is related to
-
PYTHON-1782 MongoClient fails ConfigurationError: Unknown option type_registry
- Closed