Skip to content

bpo-36814: ensure os.posix_spawnp handles Py_None #13144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Lib/test/test_posix.py
Original file line number Diff line number Diff line change
Expand Up @@ -1550,6 +1550,15 @@ def test_specify_environment(self):
with open(envfile) as f:
self.assertEqual(f.read(), 'bar')

def test_none_file_actions(self):
pid = self.spawn_func(
self.NOOP_PROGRAM[0],
self.NOOP_PROGRAM,
os.environ,
file_actions=None
)
self.assertEqual(os.waitpid(pid, 0), (pid, 0))

def test_empty_file_actions(self):
pid = self.spawn_func(
self.NOOP_PROGRAM[0],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix an issue where os.posix_spawnp() would incorrectly raise a TypeError when file_actions is None.
2 changes: 1 addition & 1 deletion Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -5465,7 +5465,7 @@ py_posix_spawn(int use_posix_spawnp, PyObject *module, path_t *path, PyObject *a
goto exit;
}

if (file_actions != NULL) {
if (file_actions != NULL && file_actions != Py_None) {
/* There is a bug in old versions of glibc that makes some of the
* helper functions for manipulating file actions not copy the provided
* buffers. The problem is that posix_spawn_file_actions_addopen does not
Expand Down