GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-102179: Fix os.dup2() error reporting for negative fds by izbyshev · Pull Request #102180 · python/cpython

Conversation

@izbyshev

@izbyshev izbyshev commented Feb 23, 2023 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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.

  • Issue: os.dup2() raises wrong OSError for negative fds #102179

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Alexey Izbyshev
pythongh-102179: Fix os.dup2() error reporting for negative fds
411107d
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.
@bedevere-bot bedevere-bot added the awaiting review label Feb 23, 2023
@bedevere-bot bedevere-bot mentioned this pull request Feb 23, 2023
os.dup2() raises wrong OSError for negative fds #102179
Closed
@arhadthedev arhadthedev added the extension-modules C modules in the Modules dir label Feb 25, 2023
kumaraditya303
kumaraditya303 approved these changes Mar 3, 2023
View reviewed changes
Comment thread Misc/NEWS.d/next/Library/2023-02-23-15-06-01.gh-issue-102179.P6KQ4c.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot added awaiting merge and removed awaiting review labels Mar 3, 2023
@kumaraditya303
Update Misc/NEWS.d/next/Library/2023-02-23-15-06-01.gh-issue-102179.P…
01df936
…6KQ4c.rst
@kumaraditya303 kumaraditya303 self-assigned this Mar 3, 2023
@kumaraditya303 kumaraditya303 added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Mar 3, 2023
@bedevere-bot

bedevere-bot commented Mar 3, 2023

Copy link
Copy Markdown

🤖 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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Mar 3, 2023
@kumaraditya303 kumaraditya303 added needs backport to 3.10 needs backport to 3.11 only security fixes labels Mar 3, 2023
@kumaraditya303

kumaraditya303 commented Mar 4, 2023

Copy link
Copy Markdown
Contributor

Remove the manual check altogether: the C library functions used to implement os.dup2() check fd validity anyway.

@izbyshev Looks like on wasm this check is not implemented. https://buildbot.python.org/all/#/builders/1060/builds/378/steps/10/logs/stdio

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@izbyshev

izbyshev commented Mar 4, 2023

Copy link
Copy Markdown
Contributor Author

@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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Alexey Izbyshev
Skip the test case on Emscripten
c32ea70
@izbyshev

izbyshev commented Mar 4, 2023

Copy link
Copy Markdown
Contributor Author

@kumaraditya303 I've described the situation with Emscripten in #102179 (comment).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kumaraditya303
kumaraditya303 approved these changes Mar 4, 2023
View reviewed changes
@kumaraditya303

kumaraditya303 commented Mar 4, 2023

Copy link
Copy Markdown
Contributor

I've described the situation with Emscripten in #102179 (comment).

Okay, thanks for investigating this!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kumaraditya303
kumaraditya303 merged commit c2bd55d into python:main Mar 4, 2023
@miss-islington

miss-islington commented Mar 4, 2023

Copy link
Copy Markdown
Contributor

Thanks @izbyshev for the PR, and @kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the awaiting merge label Mar 4, 2023
@miss-islington

miss-islington commented Mar 4, 2023

Copy link
Copy Markdown
Contributor

Sorry @izbyshev and @kumaraditya303, I had trouble checking out the 3.11 backport branch.
Please retry by removing and re-adding the "needs backport to 3.11" label.
Alternatively, you can backport using cherry_picker on the command line.
cherry_picker c2bd55d26f8eb2850eb9f9026b5d7f0ed1420b65 3.11

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot

bedevere-bot commented Mar 4, 2023

Copy link
Copy Markdown

GH-102419 is a backport of this pull request to the 3.10 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 4, 2023
Alexey Izbyshev @miss-islington
pythongh-102179: Fix os.dup2 error reporting for negative fds (pyth…
9f6df8c
…onGH-102180)

(cherry picked from commit c2bd55d)

Co-authored-by: Alexey Izbyshev <[email protected]>
@bedevere-bot bedevere-bot removed the needs backport to 3.10 label Mar 4, 2023
@kumaraditya303 kumaraditya303 added needs backport to 3.11 only security fixes and removed needs backport to 3.11 only security fixes labels Mar 4, 2023
@miss-islington

miss-islington commented Mar 4, 2023

Copy link
Copy Markdown
Contributor

Thanks @izbyshev for the PR, and @kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 4, 2023
Alexey Izbyshev @miss-islington
pythongh-102179: Fix os.dup2 error reporting for negative fds (pyth…
4ae023d
…onGH-102180)

(cherry picked from commit c2bd55d)

Co-authored-by: Alexey Izbyshev <[email protected]>
@bedevere-bot

bedevere-bot commented Mar 4, 2023

Copy link
Copy Markdown

GH-102420 is a backport of this pull request to the 3.11 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Mar 4, 2023
miss-islington added a commit that referenced this pull request Mar 4, 2023
@miss-islington Alexey Izbyshev
gh-102179: Fix os.dup2 error reporting for negative fds (GH-102180)
cc6ce90
(cherry picked from commit c2bd55d)

Co-authored-by: Alexey Izbyshev <[email protected]>
@izbyshev
izbyshev deleted the gh-102179-dup2-negative-fd branch March 4, 2023 15:18
kumaraditya303 added a commit that referenced this pull request Mar 4, 2023
@miss-islington Alexey Izbyshev @kumaraditya303
[3.10] gh-102179: Fix os.dup2 error reporting for negative fds (GH-…
925ebfb
…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]>
hugovk pushed a commit to hugovk/cpython that referenced this pull request Mar 6, 2023
Alexey Izbyshev @hugovk
pythongh-102179: Fix os.dup2 error reporting for negative fds (pyth…
1e09181
…on#102180)
carljm added a commit to carljm/cpython that referenced this pull request Mar 6, 2023
@carljm
Merge branch 'main' into nodeaddict
33dda2a
* 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)
  ...
carljm added a commit to carljm/cpython that referenced this pull request Mar 7, 2023
@carljm
Merge branch 'main' into inlinecomp2
ecb313c
* 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)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@kumaraditya303 kumaraditya303 kumaraditya303 approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@kumaraditya303 kumaraditya303

Labels

extension-modules C modules in the Modules dir

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@izbyshev @bedevere-bot @kumaraditya303 @miss-islington @arhadthedev
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.