|
2 | 2 | from test import support |
3 | 3 | from test.support import ( |
4 | 4 | is_apple, os_helper, refleak_helper, socket_helper, threading_helper, |
5 | | - warnings_helper, |
6 | 5 | ) |
7 | 6 | import _thread as thread |
8 | 7 | import array |
@@ -200,12 +199,20 @@ def socket_setdefaulttimeout(timeout): |
200 | 199 |
|
201 | 200 |
|
202 | 201 | @contextlib.contextmanager |
203 | | -def catch_malformed_data_warning(quiet=True): |
| 202 | +def downgrade_malformed_data_warning(): |
204 | 203 | # This warning happens on macos and win, but does not always happen on linux. |
205 | | - with warnings_helper.check_warnings( |
206 | | - ("received malformed or improperly-truncated ancillary data", RuntimeWarning), |
207 | | - quiet=quiet, |
208 | | - ): |
| 204 | + if sys.platform not in {"win32", "darwin"}: |
| 205 | + yield |
| 206 | + return |
| 207 | + |
| 208 | + with warnings.catch_warnings(): |
| 209 | + # TODO: gh-110012, we should investigate why this warning is happening |
| 210 | + # and fix it properly. |
| 211 | + warnings.simplefilter( |
| 212 | + "always:" |
| 213 | + r"received malformed or improperly-truncated ancillary data" |
| 214 | + ":RuntimeWarning" |
| 215 | + ) |
209 | 216 | yield |
210 | 217 |
|
211 | 218 |
|
@@ -3957,7 +3964,7 @@ def checkTruncatedArray(self, ancbuf, maxdata, mindata=0): |
3957 | 3964 | # mindata and maxdata bytes when received with buffer size |
3958 | 3965 | # ancbuf, and that any complete file descriptor numbers are |
3959 | 3966 | # valid. |
3960 | | - with catch_malformed_data_warning(): |
| 3967 | + with downgrade_malformed_data_warning(): # TODO: gh-110012 |
3961 | 3968 | msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, |
3962 | 3969 | len(MSG), ancbuf) |
3963 | 3970 | self.assertEqual(msg, MSG) |
@@ -4310,7 +4317,7 @@ def testSingleCmsgTruncInData(self): |
4310 | 4317 | self.serv_sock.setsockopt(socket.IPPROTO_IPV6, |
4311 | 4318 | socket.IPV6_RECVHOPLIMIT, 1) |
4312 | 4319 | self.misc_event.set() |
4313 | | - with catch_malformed_data_warning(): |
| 4320 | + with downgrade_malformed_data_warning(): # TODO: gh-110012 |
4314 | 4321 | msg, ancdata, flags, addr = self.doRecvmsg( |
4315 | 4322 | self.serv_sock, len(MSG), socket.CMSG_LEN(SIZEOF_INT) - 1) |
4316 | 4323 |
|
@@ -4415,7 +4422,7 @@ def testSecondCmsgTruncInData(self): |
4415 | 4422 | self.serv_sock.setsockopt(socket.IPPROTO_IPV6, |
4416 | 4423 | socket.IPV6_RECVTCLASS, 1) |
4417 | 4424 | self.misc_event.set() |
4418 | | - with catch_malformed_data_warning(): |
| 4425 | + with downgrade_malformed_data_warning(): # TODO: gh-110012 |
4419 | 4426 | msg, ancdata, flags, addr = self.doRecvmsg( |
4420 | 4427 | self.serv_sock, len(MSG), |
4421 | 4428 | socket.CMSG_SPACE(SIZEOF_INT) + socket.CMSG_LEN(SIZEOF_INT) - 1) |
|
0 commit comments