-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
gh-102179: Fix os.dup2() error reporting for negative fds #102180
gh-102179: Fix os.dup2() error reporting for negative fds #102180
Conversation
A remnant of old code manually checks the sign of fds, but doesn't set errno before raising OSError: ``` >>> os.dup2(-1, 0) Traceback (most recent call last): File "<stdin>", line 1, in <module> OSError: [Errno 0] Error ``` Remove the manual check altogether: the C library functions used to implement os.dup2() check fd validity anyway.
Misc/NEWS.d/next/Library/2023-02-23-15-06-01.gh-issue-102179.P6KQ4c.rst
Outdated
Show resolved
Hide resolved
🤖 New build scheduled with the buildbot fleet by @kumaraditya303 for commit 01df936 🤖 If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again. |
@izbyshev Looks like on wasm this check is not implemented. https://buildbot.python.org/all/#/builders/1060/builds/378/steps/10/logs/stdio |
@kumaraditya303 That's interesting. It seems OSError is raised with E2BIG (1) instead of EBADF (8), which doesn't make sense to me. I'm not familar with WASI, but will take a look. |
@kumaraditya303 I've described the situation with Emscripten in #102179 (comment). |
Okay, thanks for investigating this! |
Thanks @izbyshev for the PR, and @kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11. |
Sorry @izbyshev and @kumaraditya303, I had trouble checking out the |
GH-102419 is a backport of this pull request to the 3.10 branch. |
…onGH-102180) (cherry picked from commit c2bd55d) Co-authored-by: Alexey Izbyshev <[email protected]>
Thanks @izbyshev for the PR, and @kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11. |
…onGH-102180) (cherry picked from commit c2bd55d) Co-authored-by: Alexey Izbyshev <[email protected]>
GH-102420 is a backport of this pull request to the 3.11 branch. |
(cherry picked from commit c2bd55d) Co-authored-by: Alexey Izbyshev <[email protected]>
…102180) (#102419) * gh-102179: Fix `os.dup2` error reporting for negative fds (GH-102180) (cherry picked from commit c2bd55d) Co-authored-by: Alexey Izbyshev <[email protected]> Co-authored-by: Kumar Aditya <[email protected]>
* main: (21 commits) pythongh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives in sub interpreters module (python#102472) pythongh-95672: Fix versionadded indentation of get_pagesize in test.rst (pythongh-102455) pythongh-102416: Do not memoize incorrectly loop rules in the parser (python#102467) pythonGH-101362: Optimise PurePath(PurePath(...)) (pythonGH-101667) pythonGH-101362: Check pathlib.Path flavour compatibility at import time (pythonGH-101664) pythonGH-101362: Call join() only when >1 argument supplied to pathlib.PurePath() (python#101665) pythongh-102444: Fix minor bugs in `test_typing` highlighted by pyflakes (python#102445) pythonGH-102341: Improve the test function for pow (python#102342) Fix unused classes in a typing test (pythonGH-102437) pythongh-101979: argparse: fix a bug where parentheses in metavar argument of add_argument() were dropped (python#102318) pythongh-102356: Add thrashcan macros to filter object dealloc (python#102426) Move around example in to_bytes() to avoid confusion (python#101595) pythonGH-97546: fix flaky asyncio `test_wait_for_race_condition` test (python#102421) pythongh-96821: Add config option `--with-strict-overflow` (python#96823) pythongh-101992: update pstlib module documentation (python#102133) pythongh-63301: Set exit code when tabnanny CLI exits on error (python#7699) pythongh-101863: Fix wrong comments in EUC-KR codec (pythongh-102417) pythongh-102302 Micro-optimize `inspect.Parameter.__hash__` (python#102303) pythongh-102179: Fix `os.dup2` error reporting for negative fds (python#102180) pythongh-101892: Fix `SystemError` when a callable iterator call exhausts the iterator (python#101896) ...
* main: (37 commits) pythongh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives in sub interpreters module (python#102472) pythongh-95672: Fix versionadded indentation of get_pagesize in test.rst (pythongh-102455) pythongh-102416: Do not memoize incorrectly loop rules in the parser (python#102467) pythonGH-101362: Optimise PurePath(PurePath(...)) (pythonGH-101667) pythonGH-101362: Check pathlib.Path flavour compatibility at import time (pythonGH-101664) pythonGH-101362: Call join() only when >1 argument supplied to pathlib.PurePath() (python#101665) pythongh-102444: Fix minor bugs in `test_typing` highlighted by pyflakes (python#102445) pythonGH-102341: Improve the test function for pow (python#102342) Fix unused classes in a typing test (pythonGH-102437) pythongh-101979: argparse: fix a bug where parentheses in metavar argument of add_argument() were dropped (python#102318) pythongh-102356: Add thrashcan macros to filter object dealloc (python#102426) Move around example in to_bytes() to avoid confusion (python#101595) pythonGH-97546: fix flaky asyncio `test_wait_for_race_condition` test (python#102421) pythongh-96821: Add config option `--with-strict-overflow` (python#96823) pythongh-101992: update pstlib module documentation (python#102133) pythongh-63301: Set exit code when tabnanny CLI exits on error (python#7699) pythongh-101863: Fix wrong comments in EUC-KR codec (pythongh-102417) pythongh-102302 Micro-optimize `inspect.Parameter.__hash__` (python#102303) pythongh-102179: Fix `os.dup2` error reporting for negative fds (python#102180) pythongh-101892: Fix `SystemError` when a callable iterator call exhausts the iterator (python#101896) ...
A remnant of old code manually checks the sign of fds, but doesn't set errno before raising OSError:
Remove the manual check altogether: the C library functions used to implement os.dup2() check fd validity anyway.