From f28fb9afa07a3c6896e5e7ca0b803fbfd6b71ba4 Mon Sep 17 00:00:00 2001 From: Thejesh <35212698+thejesh23@users.noreply.github.com> Date: Mon, 2 Nov 2026 13:07:29 -0800 Subject: [PATCH] gh-161179: Fix function names in `os.{spawnve,preadv}()` and `tkinter.wm_attributes()` error messages (GH-161180) (cherry picked from commit 4fb00706194e3c5ee5f821d816234b1052e4ced3) Co-authored-by: Thejesh <35212698+thejesh23@users.noreply.github.com> --- Lib/test/test_os.py | 6 ++++++ Lib/test/test_posix.py | 2 ++ Lib/test/test_tkinter/test_misc.py | 2 ++ Lib/tkinter/__init__.py | 2 +- .../Library/2026-11-02-13-26-36.gh-issue-161179.H8Yyaw.rst | 2 ++ Modules/posixmodule.c | 4 ++-- 6 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2026-11-02-13-26-36.gh-issue-161179.H8Yyaw.rst diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index 99c91ea2ca2dac..29f15cd622e0f9 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -3863,6 +3863,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_posix.py b/Lib/test/test_posix.py index 03538a940cb363..aeaff280c69ef1 100644 --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -320,6 +320,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 8bd93ff77d6cc4..bae1c6c4005b31 100644 --- a/Lib/test/test_tkinter/test_misc.py +++ b/Lib/test/test_tkinter/test_misc.py @@ -969,6 +969,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 1c2afadd3cb234..7397f576a61f24 100644 --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -2205,7 +2205,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/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 00000000000000..81d12633029959 --- /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`. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 51d218859d0ecb..996f5451da059a 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -7915,7 +7915,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; } } @@ -11831,7 +11831,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; }