Title: Soft deprecate os.spawn*(), os.popen() and os.system() functions · Issue #120743 · python/cpython · GitHub
Open Graph Title: Soft deprecate os.spawn*(), os.popen() and os.system() functions · Issue #120743 · python/cpython
X Title: Soft deprecate os.spawn*(), os.popen() and os.system() functions · Issue #120743 · python/cpython
Description: See the discussion for the rationale: Is time to remove os module spawn* functions? See also the discussion: How to deal with unsafe/broken os.spawn* arg handling behavior on Windows (Nov 2022). Advantages of the subprocess module: subpr...
Open Graph Description: See the discussion for the rationale: Is time to remove os module spawn* functions? See also the discussion: How to deal with unsafe/broken os.spawn* arg handling behavior on Windows (Nov 2022). Ad...
X Description: See the discussion for the rationale: Is time to remove os module spawn* functions? See also the discussion: How to deal with unsafe/broken os.spawn* arg handling behavior on Windows (Nov 2022). Ad...
Opengraph URL: https://github.com/python/cpython/issues/120743
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Soft deprecate os.spawn*(), os.popen() and os.system() functions","articleBody":"See the discussion for the rationale: [Is time to remove os module spawn* functions?](https://discuss.python.org/t/is-time-to-remove-os-module-spawn-functions/55829)\r\n\r\nSee also the discussion: [How to deal with unsafe/broken os.spawn* arg handling behavior on Windows](https://discuss.python.org/t/how-to-deal-with-unsafe-broken-os-spawn-arg-handling-behavior-on-windows/20829) (Nov 2022).\r\n\r\nAdvantages of the subprocess module:\r\n\r\n* subprocess restores the signal handlers (**reliable behavior**).\r\n* subprocess closes all file descriptors (**more secure**).\r\n* subprocess doesn't use a shell by default, `shell=True` must be used explicitly.\r\n* subprocess is the defacto standard way to spawn processes in Python.\r\n\r\nExamples of os functions issues:\r\n\r\n* os.popen() and os.system() always use `shell=True`, it cannot be disabled. (**higher risk of shell code injection**)\r\n* os.popen().close() return value depends on the platform. (**not portable**)\r\n* os.popen().close() return value is a \"wait status\", not an exit code: waitstatus_to_exitcode() must be used to get a return code.\r\n* There are 8 os.spawn*() functions, it's more **error prone** and harder to use than subprocess APIs.\r\n* os.spawn*() functions return an exit code 1 if the program is not found instead of raising an exception. It's harder to distinguish if the program exists and has an exit code of 1, or if it doesn't exist.\r\n* The os.spawn*() functions are not safe for use in multithreaded programs on POSIX systems as they use fork()+exec() from Python there.\r\n\r\n\u003c!-- gh-linked-prs -->\r\n### Linked PRs\r\n* gh-120744\r\n\u003c!-- /gh-linked-prs -->\r\n","author":{"url":"https://github.com/vstinner","@type":"Person","name":"vstinner"},"datePublished":"2024-06-19T13:37:23Z","url":"https://github.com/python/cpython/issues/120743"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e260226b-0e37-4f6a-e7ad-b54c6217f9a2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9F76:27AD12:717220:976133:6B0039C6 |
| html-safe-nonce | 79ddc414c920dc4139df4c716e8d6cd9b71a6f111384f47206afc29adecf1412 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5Rjc2OjI3QUQxMjo3MTcyMjA6OTc2MTMzOjZCMDAzOUM2IiwidmlzaXRvcl9pZCI6IjQ4OTM3OTY0MzczNDQ2NjQwMDYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ed61414642e60eb7115e6479a12f4328a1afacb3afd028fc15e4bf29c4e15a56 |
| hovercard-subject-tag | issue:2362413100 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/120743/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e6999d01f8354e7cda9837d821ed4dfa455a60c0dc5999cd80e1485d27857d49/python/cpython/issues/120743 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e6999d01f8354e7cda9837d821ed4dfa455a60c0dc5999cd80e1485d27857d49/python/cpython/issues/120743 |
| og:image:alt | See the discussion for the rationale: Is time to remove os module spawn* functions? See also the discussion: How to deal with unsafe/broken os.spawn* arg handling behavior on Windows (Nov 2022). Ad... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | vstinner |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width