Skip to content

Commit f28fb9a

Browse files
thejesh23miss-islington
authored andcommitted
gh-161179: Fix function names in os.{spawnve,preadv}() and tkinter.wm_attributes() error messages (GH-161180)
(cherry picked from commit 4fb0070) Co-authored-by: Thejesh <35212698+thejesh23@users.noreply.github.com>
1 parent 96e1f2b commit f28fb9a

6 files changed

Lines changed: 15 additions & 3 deletions

File tree

‎Lib/test/test_os.py‎

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

3866+
@requires_native_spawnv
3867+
def test_spawnve_empty_first_arg_message(self):
3868+
with self.assertRaisesRegex(ValueError,
3869+
r'^spawnve\(\) arg 2 first element'):
3870+
os.spawnve(os.P_NOWAIT, sys.executable, [''], {})
3871+
38663872
@requires_native_spawnv
38673873
def test_spawnv_arg_conversion_errors(self):
38683874
# A non-path argv item gets a TypeError naming the argument...

‎Lib/test/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
@@ -969,6 +969,8 @@ def test_wm_attribute(self):
969969
w.wm_attributes(alpha=1.0)
970970
self.assertEqual(w.wm_attributes('alpha'),
971971
1.0 if self.wantobjects else '1.0')
972+
with self.assertRaisesRegex(TypeError, r'^wm_attributes\(\) options'):
973+
w.wm_attributes('alpha', alpha=0.5)
972974

973975
def test_wm_iconbitmap(self):
974976
t = tkinter.Toplevel(self.root)

‎Lib/tkinter/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2205,7 +2205,7 @@ def wm_attributes(self, *args, return_python_dict=False, **kwargs):
22052205
# TODO: deprecate
22062206
return self.tk.call('wm', 'attributes', self._w, *args)
22072207
elif args:
2208-
raise TypeError('wm_attribute() options have been specified as '
2208+
raise TypeError('wm_attributes() options have been specified as '
22092209
'positional and keyword arguments')
22102210
else:
22112211
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
@@ -7915,7 +7915,7 @@ os_spawnve_impl(PyObject *module, int mode, path_t *path, PyObject *argv,
79157915
lastarg = i + 1;
79167916
PyErr_SetString(
79177917
PyExc_ValueError,
7918-
"spawnv() arg 2 first element cannot be empty");
7918+
"spawnve() arg 2 first element cannot be empty");
79197919
goto fail_1;
79207920
}
79217921
}
@@ -11831,7 +11831,7 @@ os_preadv_impl(PyObject *module, int fd, PyObject *buffers, Py_off_t offset,
1183111831

1183211832
if (!PySequence_Check(buffers)) {
1183311833
PyErr_SetString(PyExc_TypeError,
11834-
"preadv2() arg 2 must be a sequence");
11834+
"preadv() arg 2 must be a sequence");
1183511835
return -1;
1183611836
}
1183711837

0 commit comments

Comments
 (0)