Skip to content

Commit 31ecef7

Browse files
committed
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.
1 parent 4b21d15 commit 31ecef7

5 files changed

Lines changed: 13 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
@@ -3593,6 +3593,12 @@ def test_spawnve_noargs(self):
35933593
self.assertRaises(ValueError, os.spawnve, os.P_NOWAIT, program, ('',), {})
35943594
self.assertRaises(ValueError, os.spawnve, os.P_NOWAIT, program, [''], {})
35953595

3596+
@requires_native_spawnv
3597+
def test_spawnve_empty_first_arg_message(self):
3598+
with self.assertRaisesRegex(ValueError,
3599+
r'^spawnve\(\) arg 2 first element'):
3600+
os.spawnve(os.P_NOWAIT, sys.executable, [''], {})
3601+
35963602
@requires_native_spawnv
35973603
def test_spawnv_arg_conversion_errors(self):
35983604
# 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
@@ -328,6 +328,8 @@ def test_preadv(self):
328328
buf = [bytearray(i) for i in [5, 3, 2]]
329329
self.assertEqual(posix.preadv(fd, buf, 3), 10)
330330
self.assertEqual([b't1tt2', b't3t', b'5t'], list(buf))
331+
with self.assertRaisesRegex(TypeError, r'^preadv\(\) arg 2 '):
332+
posix.preadv(fd, 42, 0)
331333
finally:
332334
os.close(fd)
333335

‎Lib/test/test_tkinter/test_misc.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,8 @@ def test_wm_attribute(self):
11601160
w.wm_attributes(alpha=1.0)
11611161
self.assertEqual(w.wm_attributes('alpha'),
11621162
1.0 if self.wantobjects else '1.0')
1163+
with self.assertRaisesRegex(TypeError, r'^wm_attributes\(\) options'):
1164+
w.wm_attributes('alpha', alpha=0.5)
11631165

11641166
def test_wm_iconbitmap(self):
11651167
t = tkinter.Toplevel(self.root)

‎Lib/tkinter/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2355,7 +2355,7 @@ def wm_attributes(self, *args, return_python_dict=False, **kwargs):
23552355
# TODO: deprecate
23562356
return self.tk.call('wm', 'attributes', self._w, *args)
23572357
elif args:
2358-
raise TypeError('wm_attribute() options have been specified as '
2358+
raise TypeError('wm_attributes() options have been specified as '
23592359
'positional and keyword arguments')
23602360
else:
23612361
self.tk.call('wm', 'attributes', self._w, *self._options(kwargs))

‎Modules/posixmodule.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8369,7 +8369,7 @@ os_spawnve_impl(PyObject *module, int mode, path_t *path, PyObject *argv,
83698369
lastarg = i + 1;
83708370
PyErr_SetString(
83718371
PyExc_ValueError,
8372-
"spawnv() arg 2 first element cannot be empty");
8372+
"spawnve() arg 2 first element cannot be empty");
83738373
goto fail_1;
83748374
}
83758375
}
@@ -12454,7 +12454,7 @@ os_preadv_impl(PyObject *module, int fd, PyObject *buffers, Py_off_t offset,
1245412454

1245512455
if (!PySequence_Check(buffers)) {
1245612456
PyErr_SetString(PyExc_TypeError,
12457-
"preadv2() arg 2 must be a sequence");
12457+
"preadv() arg 2 must be a sequence");
1245812458
return -1;
1245912459
}
1246012460

0 commit comments

Comments
 (0)