Skip to content

Commit a2e2391

Browse files
[3.15] gh-161179: Fix function names in os.{spawnve,preadv}() and tkinter.wm_attributes() error messages (GH-161180) (#161210)
(cherry picked from commit 4fb0070) Co-authored-by: Thejesh <35212698+thejesh23@users.noreply.github.com>
1 parent 9615515 commit a2e2391

6 files changed

Lines changed: 15 additions & 3 deletions

File tree

‎Lib/test/test_os/test_os.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3543,6 +3543,12 @@ def test_spawnve_noargs(self):
35433543
self.assertRaises(ValueError, os.spawnve, os.P_NOWAIT, program, ('',), {})
35443544
self.assertRaises(ValueError, os.spawnve, os.P_NOWAIT, program, [''], {})
35453545

3546+
@requires_native_spawnv
3547+
def test_spawnve_empty_first_arg_message(self):
3548+
with self.assertRaisesRegex(ValueError,
3549+
r'^spawnve\(\) arg 2 first element'):
3550+
os.spawnve(os.P_NOWAIT, sys.executable, [''], {})
3551+
35463552
@requires_native_spawnv
35473553
def test_spawnv_arg_conversion_errors(self):
35483554
# A non-path argv item gets a TypeError naming the argument...

‎Lib/test/test_os/test_posix.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,8 @@ def test_preadv(self):
320320
buf = [bytearray(i) for i in [5, 3, 2]]
321321
self.assertEqual(posix.preadv(fd, buf, 3), 10)
322322
self.assertEqual([b't1tt2', b't3t', b'5t'], list(buf))
323+
with self.assertRaisesRegex(TypeError, r'^preadv\(\) arg 2 '):
324+
posix.preadv(fd, 42, 0)
323325
finally:
324326
os.close(fd)
325327

‎Lib/test/test_tkinter/test_misc.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,8 @@ def test_wm_attribute(self):
10021002
w.wm_attributes(alpha=1.0)
10031003
self.assertEqual(w.wm_attributes('alpha'),
10041004
1.0 if self.wantobjects else '1.0')
1005+
with self.assertRaisesRegex(TypeError, r'^wm_attributes\(\) options'):
1006+
w.wm_attributes('alpha', alpha=0.5)
10051007

10061008
def test_wm_iconbitmap(self):
10071009
t = tkinter.Toplevel(self.root)

‎Lib/tkinter/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2276,7 +2276,7 @@ def wm_attributes(self, *args, return_python_dict=False, **kwargs):
22762276
# TODO: deprecate
22772277
return self.tk.call('wm', 'attributes', self._w, *args)
22782278
elif args:
2279-
raise TypeError('wm_attribute() options have been specified as '
2279+
raise TypeError('wm_attributes() options have been specified as '
22802280
'positional and keyword arguments')
22812281
else:
22822282
self.tk.call('wm', 'attributes', self._w, *self._options(kwargs))
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix the function names in the error messages of :func:`os.spawnve`,
2+
:func:`os.preadv` and :meth:`tkinter.Wm.wm_attributes`.

‎Modules/posixmodule.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8397,7 +8397,7 @@ os_spawnve_impl(PyObject *module, int mode, path_t *path, PyObject *argv,
83978397
lastarg = i + 1;
83988398
PyErr_SetString(
83998399
PyExc_ValueError,
8400-
"spawnv() arg 2 first element cannot be empty");
8400+
"spawnve() arg 2 first element cannot be empty");
84018401
goto fail_1;
84028402
}
84038403
}
@@ -12337,7 +12337,7 @@ os_preadv_impl(PyObject *module, int fd, PyObject *buffers, Py_off_t offset,
1233712337

1233812338
if (!PySequence_Check(buffers)) {
1233912339
PyErr_SetString(PyExc_TypeError,
12340-
"preadv2() arg 2 must be a sequence");
12340+
"preadv() arg 2 must be a sequence");
1234112341
return -1;
1234212342
}
1234312343

0 commit comments

Comments
 (0)