Skip to content

Commit 9768a05

Browse files
committed
Merge branch 'master' of github.com:mongodb/mongo-python-driver
2 parents 39559d6 + 2655bb4 commit 9768a05

File tree

7 files changed

+31
-20
lines changed

7 files changed

+31
-20
lines changed

bson/_cbsonmodule.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3227,11 +3227,18 @@ _cbson_exec(PyObject *m)
32273227
INITERROR;
32283228
}
32293229

3230+
#if PY_VERSION_HEX >= 0x030D0000
3231+
if (PyModule_Add(m, "_C_API", c_api_object) < 0) {
3232+
Py_DECREF(m);
3233+
INITERROR;
3234+
}
3235+
# else
32303236
if (PyModule_AddObject(m, "_C_API", c_api_object) < 0) {
32313237
Py_DECREF(c_api_object);
32323238
Py_DECREF(m);
32333239
INITERROR;
32343240
}
3241+
#endif
32353242

32363243
return 0;
32373244
}

pymongo/asynchronous/topology.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ def __init__(self, topology_settings: TopologySettings):
154154
_SDAM_LOGGER,
155155
message=_SDAMStatusMessage.TOPOLOGY_CHANGE,
156156
topologyId=self._topology_id,
157-
previousDescription=initial_td,
158-
newDescription=self._description,
157+
previousDescription=repr(initial_td),
158+
newDescription=repr(self._description),
159159
)
160160

161161
for seed in topology_settings.seeds:
@@ -514,8 +514,8 @@ async def _process_change(
514514
_SDAM_LOGGER,
515515
message=_SDAMStatusMessage.TOPOLOGY_CHANGE,
516516
topologyId=self._topology_id,
517-
previousDescription=td_old,
518-
newDescription=self._description,
517+
previousDescription=repr(td_old),
518+
newDescription=repr(self._description),
519519
)
520520

521521
# Shutdown SRV polling for unsupported cluster types.
@@ -581,8 +581,8 @@ async def _process_srv_update(self, seedlist: list[tuple[str, Any]]) -> None:
581581
_SDAM_LOGGER,
582582
message=_SDAMStatusMessage.TOPOLOGY_CHANGE,
583583
topologyId=self._topology_id,
584-
previousDescription=td_old,
585-
newDescription=self._description,
584+
previousDescription=repr(td_old),
585+
newDescription=repr(self._description),
586586
)
587587

588588
async def on_srv_update(self, seedlist: list[tuple[str, Any]]) -> None:
@@ -747,8 +747,8 @@ async def close(self) -> None:
747747
_SDAM_LOGGER,
748748
message=_SDAMStatusMessage.TOPOLOGY_CHANGE,
749749
topologyId=self._topology_id,
750-
previousDescription=old_td,
751-
newDescription=self._description,
750+
previousDescription=repr(old_td),
751+
newDescription=repr(self._description),
752752
)
753753
_debug_log(
754754
_SDAM_LOGGER, message=_SDAMStatusMessage.STOP_TOPOLOGY, topologyId=self._topology_id

pymongo/synchronous/topology.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ def __init__(self, topology_settings: TopologySettings):
154154
_SDAM_LOGGER,
155155
message=_SDAMStatusMessage.TOPOLOGY_CHANGE,
156156
topologyId=self._topology_id,
157-
previousDescription=initial_td,
158-
newDescription=self._description,
157+
previousDescription=repr(initial_td),
158+
newDescription=repr(self._description),
159159
)
160160

161161
for seed in topology_settings.seeds:
@@ -514,8 +514,8 @@ def _process_change(
514514
_SDAM_LOGGER,
515515
message=_SDAMStatusMessage.TOPOLOGY_CHANGE,
516516
topologyId=self._topology_id,
517-
previousDescription=td_old,
518-
newDescription=self._description,
517+
previousDescription=repr(td_old),
518+
newDescription=repr(self._description),
519519
)
520520

521521
# Shutdown SRV polling for unsupported cluster types.
@@ -581,8 +581,8 @@ def _process_srv_update(self, seedlist: list[tuple[str, Any]]) -> None:
581581
_SDAM_LOGGER,
582582
message=_SDAMStatusMessage.TOPOLOGY_CHANGE,
583583
topologyId=self._topology_id,
584-
previousDescription=td_old,
585-
newDescription=self._description,
584+
previousDescription=repr(td_old),
585+
newDescription=repr(self._description),
586586
)
587587

588588
def on_srv_update(self, seedlist: list[tuple[str, Any]]) -> None:
@@ -745,8 +745,8 @@ def close(self) -> None:
745745
_SDAM_LOGGER,
746746
message=_SDAMStatusMessage.TOPOLOGY_CHANGE,
747747
topologyId=self._topology_id,
748-
previousDescription=old_td,
749-
newDescription=self._description,
748+
previousDescription=repr(old_td),
749+
newDescription=repr(self._description),
750750
)
751751
_debug_log(
752752
_SDAM_LOGGER, message=_SDAMStatusMessage.STOP_TOPOLOGY, topologyId=self._topology_id

test/asynchronous/test_srv_polling.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import time
2121
from test.utils_shared import FunctionCallRecorder
2222
from typing import Any
23-
from unittest import skipIf
2423

2524
sys.path[0:0] = [""]
2625

@@ -92,7 +91,6 @@ def __exit__(self, exc_type, exc_val, exc_tb):
9291
self.disable()
9392

9493

95-
@skipIf(not _IS_SYNC and sys.platform == "win32", "PYTHON-5342 known issue on Windows")
9694
class TestSrvPolling(AsyncPyMongoTestCase):
9795
BASE_SRV_RESPONSE = [
9896
("localhost.test.build.10gen.cc", 27017),
@@ -186,6 +184,9 @@ def dns_resolver_response():
186184
):
187185
await assertion_method(expected_response, client)
188186

187+
# Close the client early to avoid affecting the next scenario run.
188+
await client.close()
189+
189190
async def test_addition(self):
190191
response = self.BASE_SRV_RESPONSE[:]
191192
response.append(("localhost.test.build.10gen.cc", 27019))

test/asynchronous/unified_format.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ async def _create_entity(self, entity_spec, uri=None):
303303
if uri:
304304
kwargs["h"] = uri
305305
client = await self.test.async_rs_or_single_client(**kwargs)
306+
await client.aconnect()
306307
self[spec["id"]] = client
307308
return
308309
elif entity_type == "database":

test/test_srv_polling.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import time
2121
from test.utils_shared import FunctionCallRecorder
2222
from typing import Any
23-
from unittest import skipIf
2423

2524
sys.path[0:0] = [""]
2625

@@ -92,7 +91,6 @@ def __exit__(self, exc_type, exc_val, exc_tb):
9291
self.disable()
9392

9493

95-
@skipIf(not _IS_SYNC and sys.platform == "win32", "PYTHON-5342 known issue on Windows")
9694
class TestSrvPolling(PyMongoTestCase):
9795
BASE_SRV_RESPONSE = [
9896
("localhost.test.build.10gen.cc", 27017),
@@ -186,6 +184,9 @@ def dns_resolver_response():
186184
):
187185
assertion_method(expected_response, client)
188186

187+
# Close the client early to avoid affecting the next scenario run.
188+
client.close()
189+
189190
def test_addition(self):
190191
response = self.BASE_SRV_RESPONSE[:]
191192
response.append(("localhost.test.build.10gen.cc", 27019))

test/unified_format.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ def _create_entity(self, entity_spec, uri=None):
302302
if uri:
303303
kwargs["h"] = uri
304304
client = self.test.rs_or_single_client(**kwargs)
305+
client._connect()
305306
self[spec["id"]] = client
306307
return
307308
elif entity_type == "database":

0 commit comments

Comments
 (0)