Skip to content

Comments

gh-143698: correctly check scheduler and setpgroup values for os.posix_spawn[p]#143699

Merged
picnixz merged 7 commits intopython:mainfrom
picnixz:fix/os-posix-spawn-143698
Feb 21, 2026
Merged

gh-143698: correctly check scheduler and setpgroup values for os.posix_spawn[p]#143699
picnixz merged 7 commits intopython:mainfrom
picnixz:fix/os-posix-spawn-143698

Conversation

@picnixz
Copy link
Member

@picnixz picnixz commented Jan 11, 2026

@johnslavik
Copy link
Member

johnslavik commented Jan 11, 2026

The documentation to me is a bit subtle about providing this parameter:

The scheduler argument must be a tuple containing the (optional) scheduler policy and an instance of sched_param with the scheduler parameters. (...) A value of None in the place of the scheduler policy indicates that is not being provided. (...)

Do I understand correctly that:

  • scheduler=None is just an illustrative figure in the documentation
  • one can either (a) only to provide as a 2-element tuple or (b) not provide it at all
  • consequently, one cannot explicitly set scheduler=None in the code, even though the documentation uses scheduler=None as an illustrative figure

?

@picnixz
Copy link
Member Author

picnixz commented Jan 11, 2026

scheduler=None is just an illustrative figure in the documentation

Yes, None is only valid for the scheduler policy (so first item of the tuple) not the scheduler itself. I think we can either have an overload for the signature with scheduler omitted, or I can allow scheduler=None explicitly so that the doc is fine.

@johnslavik
Copy link
Member

or I can allow scheduler=None explicitly so that the doc is fine.

I think it would be better, yeah 👍
Unless there are some downsides to supporting an explicit scheduler=None?

@picnixz
Copy link
Member Author

picnixz commented Jan 11, 2026

Unless there are some downsides to supporting an explicit scheduler=None?

Mmh. I don't think so (?) at least I don't have an example

@donbarbos
Copy link
Contributor

donbarbos commented Jan 11, 2026

I'd like to note that if you pass None to setpgroup, a TypeError is also thrown (this is a common behavior, it might be worth specifying a different default value in the documentation to avoid user confusion)

@picnixz picnixz changed the title gh-143698: correctly check scheduler type for os.posix_spawn[p] gh-143698: correctly check scheduler and setpgroup values for os.posix_spawn[p] Jan 11, 2026
@picnixz picnixz force-pushed the fix/os-posix-spawn-143698 branch from 644cfdf to 34cd655 Compare January 11, 2026 17:34
@picnixz
Copy link
Member Author

picnixz commented Jan 11, 2026

Hum. I don't know if I want to split this PR. I think it's better, but it won't help for reverts because reverting one change would anyway create a conflict with another.

@vstinner Do you want me to split this PR just for commit history being a bit clearer?

@picnixz
Copy link
Member Author

picnixz commented Jan 11, 2026

Oh I forgot about those inspect tests. Ok, I'll do two PRs.

@picnixz picnixz marked this pull request as draft January 11, 2026 18:17
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vstinner
Copy link
Member

Oh I forgot about those inspect tests. Ok, I'll do two PRs.

Right, test_inspect is failing on CIs. Why do you want to make two PRs? You can update test_inspect in this PR, no?

@picnixz
Copy link
Member Author

picnixz commented Jan 16, 2026

That is what I thought but since it has both an additionnal feature (that is the setpgroup stuff) I maybe wanted a separate PR (as this would change more than one thing). I thought about first fixing the crash and then allowing explicit None.

@picnixz picnixz marked this pull request as ready for review February 7, 2026 11:17
@picnixz picnixz added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Feb 7, 2026
@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Feb 7, 2026
@vstinner

This comment was marked as resolved.

@picnixz picnixz marked this pull request as draft February 21, 2026 10:54
@picnixz picnixz added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes and removed needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Feb 21, 2026
@picnixz picnixz marked this pull request as ready for review February 21, 2026 10:55
@picnixz picnixz enabled auto-merge (squash) February 21, 2026 11:00
@picnixz picnixz merged commit 347fc43 into python:main Feb 21, 2026
57 checks passed
@miss-islington-app
Copy link

Thanks @picnixz for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Sorry, @picnixz, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 347fc438cf903c1d7fa5063464ae2e93c11b2232 3.14

@miss-islington-app
Copy link

Sorry, @picnixz, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 347fc438cf903c1d7fa5063464ae2e93c11b2232 3.13

@picnixz picnixz deleted the fix/os-posix-spawn-143698 branch February 21, 2026 11:22
picnixz added a commit to picnixz/cpython that referenced this pull request Feb 21, 2026
…alues for `os.posix_spawn[p]` (pythonGH-143699)

Fix an issue where passing invalid arguments to `os.posix_spawn[p]` functions
raised a SystemError instead of a TypeError, and allow to explicitly use `None`
for `scheduler` and `setpgroup` as specified in the docs.
(cherry picked from commit 347fc43)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@bedevere-app
Copy link

bedevere-app bot commented Feb 21, 2026

GH-145073 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Feb 21, 2026
picnixz added a commit to picnixz/cpython that referenced this pull request Feb 21, 2026
…alues for `os.posix_spawn[p]` (pythonGH-143699)

Fix an issue where passing invalid arguments to `os.posix_spawn[p]` functions
raised a SystemError instead of a TypeError, and allow to explicitly use `None`
for `scheduler` and `setpgroup` as specified in the docs.
(cherry picked from commit 347fc43)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@bedevere-app
Copy link

bedevere-app bot commented Feb 21, 2026

GH-145074 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Feb 21, 2026
picnixz added a commit that referenced this pull request Feb 21, 2026
…for `os.posix_spawn[p]` (GH-143699) (#145073)

Fix an issue where passing invalid arguments to `os.posix_spawn[p]` functions
raised a SystemError instead of a TypeError, and allow to explicitly use `None`
for `scheduler` and `setpgroup` as specified in the docs.

(cherry picked from commit 347fc43)
picnixz added a commit that referenced this pull request Feb 21, 2026
…for `os.posix_spawn[p]` (GH-143699) (#145074)

* [3.13] gh-143698: correctly check `scheduler` and `setpgroup` values for `os.posix_spawn[p]` (GH-143699)

Fix an issue where passing invalid arguments to `os.posix_spawn[p]` functions
raised a SystemError instead of a TypeError, and allow to explicitly use `None`
for `scheduler` and `setpgroup` as specified in the docs.

(cherry picked from commit 347fc43)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants