Skip to content

gh-132063: ProcessPoolExecutor swallows falsy Exceptions #132129

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

Conversation

YvesDup
Copy link
Contributor

@YvesDup YvesDup commented Apr 5, 2025

ProcessPoolExecutor and ThreadPoolExecutor swallows falsy exception.

Fix tests about exception variable in 2 files of /Lib/concurrent/futures

  • _base.py
  • process.py

Changes 2 tests as below:

Replace if exception: with if exception is not None:

@python-cla-bot
Copy link

python-cla-bot bot commented Apr 6, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

I never sent my review.

@YvesDup
Copy link
Contributor Author

YvesDup commented Apr 7, 2025

After more tests, I found that __cause__, __context__ attributes in falsey exceptions are ignored.

if (e and e.__cause__ is not None

if (e and e.__context__ is not None

And falsey BaseExceptionGroup exception is ignored too.
if e and isinstance(e, BaseExceptionGroup):

Should we open a new issue with these bugs or integrate them to this PR ?

EDIT: please ignore this comment

Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

Some nits and LGTM.


msg = 'boolbool'
with self.assertRaisesRegex(FalseyBoolException, msg):
self.executor.submit(raiser, FalseyBoolException, msg).result()
Copy link
Member

Choose a reason for hiding this comment

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

This is for a possible follow-up but this kind of call makes me wonder whether the base class shouldn't have some def submit_and_fetch(self) method that does this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does this method return directy the result ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a follow-up with the TracebackExceptionclass which swallows __cause__ and __context__ content of falsey exceptions.
I will post a new issue about this.

@picnixz picnixz enabled auto-merge (squash) April 8, 2025 14:55
@picnixz picnixz added the needs backport to 3.13 bugs and security fixes label Apr 8, 2025
@picnixz picnixz merged commit 933c665 into python:main Apr 8, 2025
41 checks passed
@miss-islington-app
Copy link

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 8, 2025
…alsey exceptions (pythonGH-132129)

(cherry picked from commit 933c665)

Co-authored-by: Duprat <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Apr 8, 2025

GH-132275 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 Apr 8, 2025
picnixz pushed a commit that referenced this pull request Apr 8, 2025
…falsey exceptions (GH-132129) (#132275)

gh-132063: ensure that `ProcessPoolExecutor` does not swallow falsey exceptions (GH-132129)
(cherry picked from commit 933c665)

Co-authored-by: Duprat <[email protected]>
seehwan pushed a commit to seehwan/cpython that referenced this pull request Apr 16, 2025
@YvesDup YvesDup deleted the ProcessPoolExecutor-swallows-flasy-exception branch May 16, 2025 10:06
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.

3 participants