Skip to content

Commit 1ad5f6d

Browse files
committed
explicitly accept scheduler=None
1 parent 9ba4410 commit 1ad5f6d

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

Lib/test/test_os/test_posix.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2096,10 +2096,13 @@ def test_setsigdef_wrong_type(self):
20962096
[sys.executable, "-c", "pass"],
20972097
os.environ, setsigdef=[signal.NSIG, signal.NSIG+1])
20982098

2099-
@support.subTests("scheduler", [None, 1, [1, 2]])
2099+
@support.subTests("scheduler", [object(), 1, [1, 2]])
21002100
def test_invalid_scheduler_param(self, scheduler):
21012101
path, args = self.NOOP_PROGRAM[0], self.NOOP_PROGRAM
2102-
with self.assertRaisesRegex(TypeError, "scheduler must be a tuple"):
2102+
with self.assertRaisesRegex(
2103+
TypeError,
2104+
"scheduler must be a tuple or None",
2105+
):
21032106
self.spawn_func(path, args, os.environ, scheduler=scheduler)
21042107

21052108
@requires_sched

Modules/clinic/posixmodule.c.h

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/posixmodule.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7693,7 +7693,7 @@ parse_posix_spawn_flags(PyObject *module, const char *func_name, PyObject *setpg
76937693
}
76947694
#endif
76957695

7696-
if (scheduler) {
7696+
if (scheduler && scheduler != Py_None) {
76977697
#ifdef POSIX_SPAWN_SETSCHEDULER
76987698
PyObject *py_schedpolicy;
76997699
PyObject *schedparam_obj;
@@ -7918,9 +7918,9 @@ py_posix_spawn(int use_posix_spawnp, PyObject *module, path_t *path, PyObject *a
79187918
goto exit;
79197919
}
79207920

7921-
if (scheduler && !PyTuple_Check(scheduler)) {
7921+
if (!PyTuple_Check(scheduler) && scheduler != Py_None) {
79227922
PyErr_Format(PyExc_TypeError,
7923-
"%s: scheduler must be a tuple", func_name);
7923+
"%s: scheduler must be a tuple or None", func_name);
79247924
goto exit;
79257925
}
79267926

@@ -8045,7 +8045,7 @@ os.posix_spawn
80458045
The sigmask to use with the POSIX_SPAWN_SETSIGMASK flag.
80468046
setsigdef: object(c_default='NULL') = ()
80478047
The sigmask to use with the POSIX_SPAWN_SETSIGDEF flag.
8048-
scheduler: object = NULL
8048+
scheduler: object(c_default='NULL') = None
80498049
A tuple with the scheduler policy (optional) and parameters.
80508050

80518051
Execute the program specified by path in a new process.
@@ -8057,7 +8057,7 @@ os_posix_spawn_impl(PyObject *module, path_t *path, PyObject *argv,
80578057
PyObject *setpgroup, int resetids, int setsid,
80588058
PyObject *setsigmask, PyObject *setsigdef,
80598059
PyObject *scheduler)
8060-
/*[clinic end generated code: output=14a1098c566bc675 input=808aed1090d84e33]*/
8060+
/*[clinic end generated code: output=14a1098c566bc675 input=242939f993243c45]*/
80618061
{
80628062
return py_posix_spawn(0, module, path, argv, env, file_actions,
80638063
setpgroup, resetids, setsid, setsigmask, setsigdef,
@@ -8091,7 +8091,7 @@ os.posix_spawnp
80918091
The sigmask to use with the POSIX_SPAWN_SETSIGMASK flag.
80928092
setsigdef: object(c_default='NULL') = ()
80938093
The sigmask to use with the POSIX_SPAWN_SETSIGDEF flag.
8094-
scheduler: object = NULL
8094+
scheduler: object(c_default='NULL') = None
80958095
A tuple with the scheduler policy (optional) and parameters.
80968096

80978097
Execute the program specified by path in a new process.
@@ -8103,7 +8103,7 @@ os_posix_spawnp_impl(PyObject *module, path_t *path, PyObject *argv,
81038103
PyObject *setpgroup, int resetids, int setsid,
81048104
PyObject *setsigmask, PyObject *setsigdef,
81058105
PyObject *scheduler)
8106-
/*[clinic end generated code: output=7b9aaefe3031238d input=9e89e616116752a1]*/
8106+
/*[clinic end generated code: output=7b9aaefe3031238d input=e77db185549d088c]*/
81078107
{
81088108
return py_posix_spawn(1, module, path, argv, env, file_actions,
81098109
setpgroup, resetids, setsid, setsigmask, setsigdef,

0 commit comments

Comments
 (0)