From 31ecef727a597ef8d46e759a97d8f05db8034945 Mon Sep 17 00:00:00 2001 From: Thejesh <35212698+thejesh23@users.noreply.github.com> Date: Sun, 1 Nov 2026 16:27:51 -0800 Subject: [PATCH 1/2] Fix function names in error messages of os.spawnve(), os.preadv() and wm_attributes() os.spawnve() said "spawnv()" when the first element of argv is empty, os.preadv() said "preadv2()" when buffers is not a sequence, and tkinter's wm_attributes() said "wm_attribute()" when options are given both positionally and as keywords. Add tests checking the messages. --- Lib/test/test_os/test_os.py | 6 ++++++ Lib/test/test_os/test_posix.py | 2 ++ Lib/test/test_tkinter/test_misc.py | 2 ++ Lib/tkinter/__init__.py | 2 +- Modules/posixmodule.c | 4 ++-- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_os/test_os.py b/Lib/test/test_os/test_os.py index 79aa9e96dc91a6b..662b57702fe26cd 100644 --- a/Lib/test/test_os/test_os.py +++ b/Lib/test/test_os/test_os.py @@ -3593,6 +3593,12 @@ def test_spawnve_noargs(self): self.assertRaises(ValueError, os.spawnve, os.P_NOWAIT, program, ('',), {}) self.assertRaises(ValueError, os.spawnve, os.P_NOWAIT, program, [''], {}) + @requires_native_spawnv + def test_spawnve_empty_first_arg_message(self): + with self.assertRaisesRegex(ValueError, + r'^spawnve\(\) arg 2 first element'): + os.spawnve(os.P_NOWAIT, sys.executable, [''], {}) + @requires_native_spawnv def test_spawnv_arg_conversion_errors(self): # A non-path argv item gets a TypeError naming the argument... diff --git a/Lib/test/test_os/test_posix.py b/Lib/test/test_os/test_posix.py index 82115c338906fc0..6df1ae8c09ec5f2 100644 --- a/Lib/test/test_os/test_posix.py +++ b/Lib/test/test_os/test_posix.py @@ -328,6 +328,8 @@ def test_preadv(self): buf = [bytearray(i) for i in [5, 3, 2]] self.assertEqual(posix.preadv(fd, buf, 3), 10) self.assertEqual([b't1tt2', b't3t', b'5t'], list(buf)) + with self.assertRaisesRegex(TypeError, r'^preadv\(\) arg 2 '): + posix.preadv(fd, 42, 0) finally: os.close(fd) diff --git a/Lib/test/test_tkinter/test_misc.py b/Lib/test/test_tkinter/test_misc.py index b32b58ab4340d20..59769b7250d76ac 100644 --- a/Lib/test/test_tkinter/test_misc.py +++ b/Lib/test/test_tkinter/test_misc.py @@ -1160,6 +1160,8 @@ def test_wm_attribute(self): w.wm_attributes(alpha=1.0) self.assertEqual(w.wm_attributes('alpha'), 1.0 if self.wantobjects else '1.0') + with self.assertRaisesRegex(TypeError, r'^wm_attributes\(\) options'): + w.wm_attributes('alpha', alpha=0.5) def test_wm_iconbitmap(self): t = tkinter.Toplevel(self.root) diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py index 11bb0ba9c89c4ac..f06807a6cb9c7d7 100644 --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -2355,7 +2355,7 @@ def wm_attributes(self, *args, return_python_dict=False, **kwargs): # TODO: deprecate return self.tk.call('wm', 'attributes', self._w, *args) elif args: - raise TypeError('wm_attribute() options have been specified as ' + raise TypeError('wm_attributes() options have been specified as ' 'positional and keyword arguments') else: self.tk.call('wm', 'attributes', self._w, *self._options(kwargs)) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index b78bc1683538312..3a76474a2bd8a34 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -8369,7 +8369,7 @@ os_spawnve_impl(PyObject *module, int mode, path_t *path, PyObject *argv, lastarg = i + 1; PyErr_SetString( PyExc_ValueError, - "spawnv() arg 2 first element cannot be empty"); + "spawnve() arg 2 first element cannot be empty"); goto fail_1; } } @@ -12454,7 +12454,7 @@ os_preadv_impl(PyObject *module, int fd, PyObject *buffers, Py_off_t offset, if (!PySequence_Check(buffers)) { PyErr_SetString(PyExc_TypeError, - "preadv2() arg 2 must be a sequence"); + "preadv() arg 2 must be a sequence"); return -1; } From a6a9422e45cc6ea27602f6e6edfe96cc3c77cad9 Mon Sep 17 00:00:00 2001 From: Thejesh <35212698+thejesh23@users.noreply.github.com> Date: Mon, 2 Nov 2026 05:26:36 -0800 Subject: [PATCH 2/2] gh-161179: Add NEWS entry --- .../next/Library/2026-11-02-13-26-36.gh-issue-161179.H8Yyaw.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2026-11-02-13-26-36.gh-issue-161179.H8Yyaw.rst diff --git a/Misc/NEWS.d/next/Library/2026-11-02-13-26-36.gh-issue-161179.H8Yyaw.rst b/Misc/NEWS.d/next/Library/2026-11-02-13-26-36.gh-issue-161179.H8Yyaw.rst new file mode 100644 index 000000000000000..81d12633029959e --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-11-02-13-26-36.gh-issue-161179.H8Yyaw.rst @@ -0,0 +1,2 @@ +Fix the function names in the error messages of :func:`os.spawnve`, +:func:`os.preadv` and :meth:`tkinter.Wm.wm_attributes`.