Skip to content

Commit 076d0eb

Browse files
hugovksrinivasreddy
authored andcommitted
Revert "pythongh-128770: raise warnings as errors in test suite - except for test_socket which still logs warnings (python#128726)" (python#128936)
1 parent 5c4cbf1 commit 076d0eb

File tree

3 files changed

+26
-47
lines changed

3 files changed

+26
-47
lines changed

Lib/test/libregrtest/main.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -642,9 +642,9 @@ def _add_ci_python_opts(self, python_opts, keep_environ):
642642
if not sys.stdout.write_through:
643643
python_opts.append('-u')
644644

645-
# Add warnings filter 'error'
645+
# Add warnings filter 'default'
646646
if 'default' not in sys.warnoptions:
647-
python_opts.extend(('-W', 'error'))
647+
python_opts.extend(('-W', 'default'))
648648

649649
# Error on bytes/str comparison
650650
if sys.flags.bytes_warning < 2:

Lib/test/test_pyrepl/test_pyrepl.py

+16-15
Original file line numberDiff line numberDiff line change
@@ -1324,21 +1324,22 @@ def test_readline_history_file(self):
13241324
if readline.backend != "editline":
13251325
self.skipTest("GNU readline is not affected by this issue")
13261326

1327-
with tempfile.NamedTemporaryFile() as hfile:
1328-
env = os.environ.copy()
1329-
env["PYTHON_HISTORY"] = hfile.name
1330-
1331-
env["PYTHON_BASIC_REPL"] = "1"
1332-
output, exit_code = self.run_repl("spam \nexit()\n", env=env)
1333-
self.assertEqual(exit_code, 0)
1334-
self.assertIn("spam ", output)
1335-
self.assertNotEqual(pathlib.Path(hfile.name).stat().st_size, 0)
1336-
self.assertIn("spam\\040", pathlib.Path(hfile.name).read_text())
1337-
1338-
env.pop("PYTHON_BASIC_REPL", None)
1339-
output, exit_code = self.run_repl("exit\n", env=env)
1340-
self.assertEqual(exit_code, 0)
1341-
self.assertNotIn("\\040", pathlib.Path(hfile.name).read_text())
1327+
hfile = tempfile.NamedTemporaryFile()
1328+
self.addCleanup(unlink, hfile.name)
1329+
env = os.environ.copy()
1330+
env["PYTHON_HISTORY"] = hfile.name
1331+
1332+
env["PYTHON_BASIC_REPL"] = "1"
1333+
output, exit_code = self.run_repl("spam \nexit()\n", env=env)
1334+
self.assertEqual(exit_code, 0)
1335+
self.assertIn("spam ", output)
1336+
self.assertNotEqual(pathlib.Path(hfile.name).stat().st_size, 0)
1337+
self.assertIn("spam\\040", pathlib.Path(hfile.name).read_text())
1338+
1339+
env.pop("PYTHON_BASIC_REPL", None)
1340+
output, exit_code = self.run_repl("exit\n", env=env)
1341+
self.assertEqual(exit_code, 0)
1342+
self.assertNotIn("\\040", pathlib.Path(hfile.name).read_text())
13421343

13431344
def test_keyboard_interrupt_after_isearch(self):
13441345
output, exit_code = self.run_repl(["\x12", "\x03", "exit"])

Lib/test/test_socket.py

+8-30
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import unittest
2-
import warnings
32
from test import support
43
from test.support import (
5-
is_apple, os_helper, refleak_helper, socket_helper, threading_helper,
4+
is_apple, os_helper, refleak_helper, socket_helper, threading_helper
65
)
76
import _thread as thread
87
import array
@@ -199,24 +198,6 @@ def socket_setdefaulttimeout(timeout):
199198
socket.setdefaulttimeout(old_timeout)
200199

201200

202-
@contextlib.contextmanager
203-
def downgrade_malformed_data_warning():
204-
# This warning happens on macos and win, but does not always happen on linux.
205-
if sys.platform not in {"win32", "darwin"}:
206-
yield
207-
return
208-
209-
with warnings.catch_warnings():
210-
# TODO: gh-110012, we should investigate why this warning is happening
211-
# and fix it properly.
212-
warnings.filterwarnings(
213-
action="always",
214-
message=r"received malformed or improperly-truncated ancillary data",
215-
category=RuntimeWarning,
216-
)
217-
yield
218-
219-
220201
HAVE_SOCKET_CAN = _have_socket_can()
221202

222203
HAVE_SOCKET_CAN_ISOTP = _have_socket_can_isotp()
@@ -3965,9 +3946,8 @@ def checkTruncatedArray(self, ancbuf, maxdata, mindata=0):
39653946
# mindata and maxdata bytes when received with buffer size
39663947
# ancbuf, and that any complete file descriptor numbers are
39673948
# valid.
3968-
with downgrade_malformed_data_warning(): # TODO: gh-110012
3969-
msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock,
3970-
len(MSG), ancbuf)
3949+
msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock,
3950+
len(MSG), ancbuf)
39713951
self.assertEqual(msg, MSG)
39723952
self.checkRecvmsgAddress(addr, self.cli_addr)
39733953
self.checkFlags(flags, eor=True, checkset=socket.MSG_CTRUNC)
@@ -4318,9 +4298,8 @@ def testSingleCmsgTruncInData(self):
43184298
self.serv_sock.setsockopt(socket.IPPROTO_IPV6,
43194299
socket.IPV6_RECVHOPLIMIT, 1)
43204300
self.misc_event.set()
4321-
with downgrade_malformed_data_warning(): # TODO: gh-110012
4322-
msg, ancdata, flags, addr = self.doRecvmsg(
4323-
self.serv_sock, len(MSG), socket.CMSG_LEN(SIZEOF_INT) - 1)
4301+
msg, ancdata, flags, addr = self.doRecvmsg(
4302+
self.serv_sock, len(MSG), socket.CMSG_LEN(SIZEOF_INT) - 1)
43244303

43254304
self.assertEqual(msg, MSG)
43264305
self.checkRecvmsgAddress(addr, self.cli_addr)
@@ -4423,10 +4402,9 @@ def testSecondCmsgTruncInData(self):
44234402
self.serv_sock.setsockopt(socket.IPPROTO_IPV6,
44244403
socket.IPV6_RECVTCLASS, 1)
44254404
self.misc_event.set()
4426-
with downgrade_malformed_data_warning(): # TODO: gh-110012
4427-
msg, ancdata, flags, addr = self.doRecvmsg(
4428-
self.serv_sock, len(MSG),
4429-
socket.CMSG_SPACE(SIZEOF_INT) + socket.CMSG_LEN(SIZEOF_INT) - 1)
4405+
msg, ancdata, flags, addr = self.doRecvmsg(
4406+
self.serv_sock, len(MSG),
4407+
socket.CMSG_SPACE(SIZEOF_INT) + socket.CMSG_LEN(SIZEOF_INT) - 1)
44304408

44314409
self.assertEqual(msg, MSG)
44324410
self.checkRecvmsgAddress(addr, self.cli_addr)

0 commit comments

Comments
 (0)