Merge branch 'master' of github.com:mongodb/mongo-python-driver

This commit is contained in:
Steven Silvester 2025-05-12 07:53:49 -05:00
commit 9768a0506a
No known key found for this signature in database
GPG Key ID: B1BF5EC3A8B32F91
7 changed files with 31 additions and 20 deletions

View File

@ -3227,11 +3227,18 @@ _cbson_exec(PyObject *m)
INITERROR;
}
#if PY_VERSION_HEX >= 0x030D0000
if (PyModule_Add(m, "_C_API", c_api_object) < 0) {
Py_DECREF(m);
INITERROR;
}
# else
if (PyModule_AddObject(m, "_C_API", c_api_object) < 0) {
Py_DECREF(c_api_object);
Py_DECREF(m);
INITERROR;
}
#endif
return 0;
}

View File

@ -154,8 +154,8 @@ class Topology:
_SDAM_LOGGER,
message=_SDAMStatusMessage.TOPOLOGY_CHANGE,
topologyId=self._topology_id,
previousDescription=initial_td,
newDescription=self._description,
previousDescription=repr(initial_td),
newDescription=repr(self._description),
)
for seed in topology_settings.seeds:
@ -514,8 +514,8 @@ class Topology:
_SDAM_LOGGER,
message=_SDAMStatusMessage.TOPOLOGY_CHANGE,
topologyId=self._topology_id,
previousDescription=td_old,
newDescription=self._description,
previousDescription=repr(td_old),
newDescription=repr(self._description),
)
# Shutdown SRV polling for unsupported cluster types.
@ -581,8 +581,8 @@ class Topology:
_SDAM_LOGGER,
message=_SDAMStatusMessage.TOPOLOGY_CHANGE,
topologyId=self._topology_id,
previousDescription=td_old,
newDescription=self._description,
previousDescription=repr(td_old),
newDescription=repr(self._description),
)
async def on_srv_update(self, seedlist: list[tuple[str, Any]]) -> None:
@ -747,8 +747,8 @@ class Topology:
_SDAM_LOGGER,
message=_SDAMStatusMessage.TOPOLOGY_CHANGE,
topologyId=self._topology_id,
previousDescription=old_td,
newDescription=self._description,
previousDescription=repr(old_td),
newDescription=repr(self._description),
)
_debug_log(
_SDAM_LOGGER, message=_SDAMStatusMessage.STOP_TOPOLOGY, topologyId=self._topology_id

View File

@ -154,8 +154,8 @@ class Topology:
_SDAM_LOGGER,
message=_SDAMStatusMessage.TOPOLOGY_CHANGE,
topologyId=self._topology_id,
previousDescription=initial_td,
newDescription=self._description,
previousDescription=repr(initial_td),
newDescription=repr(self._description),
)
for seed in topology_settings.seeds:
@ -514,8 +514,8 @@ class Topology:
_SDAM_LOGGER,
message=_SDAMStatusMessage.TOPOLOGY_CHANGE,
topologyId=self._topology_id,
previousDescription=td_old,
newDescription=self._description,
previousDescription=repr(td_old),
newDescription=repr(self._description),
)
# Shutdown SRV polling for unsupported cluster types.
@ -581,8 +581,8 @@ class Topology:
_SDAM_LOGGER,
message=_SDAMStatusMessage.TOPOLOGY_CHANGE,
topologyId=self._topology_id,
previousDescription=td_old,
newDescription=self._description,
previousDescription=repr(td_old),
newDescription=repr(self._description),
)
def on_srv_update(self, seedlist: list[tuple[str, Any]]) -> None:
@ -745,8 +745,8 @@ class Topology:
_SDAM_LOGGER,
message=_SDAMStatusMessage.TOPOLOGY_CHANGE,
topologyId=self._topology_id,
previousDescription=old_td,
newDescription=self._description,
previousDescription=repr(old_td),
newDescription=repr(self._description),
)
_debug_log(
_SDAM_LOGGER, message=_SDAMStatusMessage.STOP_TOPOLOGY, topologyId=self._topology_id

View File

@ -20,7 +20,6 @@ import sys
import time
from test.utils_shared import FunctionCallRecorder
from typing import Any
from unittest import skipIf
sys.path[0:0] = [""]
@ -92,7 +91,6 @@ class SrvPollingKnobs:
self.disable()
@skipIf(not _IS_SYNC and sys.platform == "win32", "PYTHON-5342 known issue on Windows")
class TestSrvPolling(AsyncPyMongoTestCase):
BASE_SRV_RESPONSE = [
("localhost.test.build.10gen.cc", 27017),
@ -186,6 +184,9 @@ class TestSrvPolling(AsyncPyMongoTestCase):
):
await assertion_method(expected_response, client)
# Close the client early to avoid affecting the next scenario run.
await client.close()
async def test_addition(self):
response = self.BASE_SRV_RESPONSE[:]
response.append(("localhost.test.build.10gen.cc", 27019))

View File

@ -303,6 +303,7 @@ class EntityMapUtil:
if uri:
kwargs["h"] = uri
client = await self.test.async_rs_or_single_client(**kwargs)
await client.aconnect()
self[spec["id"]] = client
return
elif entity_type == "database":

View File

@ -20,7 +20,6 @@ import sys
import time
from test.utils_shared import FunctionCallRecorder
from typing import Any
from unittest import skipIf
sys.path[0:0] = [""]
@ -92,7 +91,6 @@ class SrvPollingKnobs:
self.disable()
@skipIf(not _IS_SYNC and sys.platform == "win32", "PYTHON-5342 known issue on Windows")
class TestSrvPolling(PyMongoTestCase):
BASE_SRV_RESPONSE = [
("localhost.test.build.10gen.cc", 27017),
@ -186,6 +184,9 @@ class TestSrvPolling(PyMongoTestCase):
):
assertion_method(expected_response, client)
# Close the client early to avoid affecting the next scenario run.
client.close()
def test_addition(self):
response = self.BASE_SRV_RESPONSE[:]
response.append(("localhost.test.build.10gen.cc", 27019))

View File

@ -302,6 +302,7 @@ class EntityMapUtil:
if uri:
kwargs["h"] = uri
client = self.test.rs_or_single_client(**kwargs)
client._connect()
self[spec["id"]] = client
return
elif entity_type == "database":