@@ -40,9 +40,22 @@ def __init__(self, client=None, *args, **kwargs):
4040 # To support the former trace_mongo_client interface, we have to keep this old interface
4141 # TODO(Benjamin): drop it in a later version
4242 if not isinstance (client , _MongoClient ):
43- # Patched interface, instanciate the client
44- # Note that, in that case, the client argument isn't a client, it's just the first arg
45- client = _MongoClient (client , * args , ** kwargs )
43+ # Patched interface, instantiate the client
44+
45+ # client is just the first arg which could be the host if it is
46+ # None, then it could be that the caller:
47+
48+ # if client is None then __init__ was:
49+ # 1) invoked with host=None
50+ # 2) not given a first argument (client defaults to None)
51+ # we cannot tell which case it is, but it should not matter since
52+ # the default value for host is None, in either case we can simply
53+ # not provide it as an argument
54+ if client is None :
55+ client = _MongoClient (* args , ** kwargs )
56+ # else client is a value for host so just pass it along
57+ else :
58+ client = _MongoClient (client , * args , ** kwargs )
4659
4760 super (TracedMongoClient , self ).__init__ (client )
4861 # NOTE[matt] the TracedMongoClient attempts to trace all of the network
0 commit comments