| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -24,6 +24,21 @@ def make_dummy_object(_): | |
| return MyObject() | ||
|
|
||
|
|
||
| # Used in test_swallows_falsey_exceptions | ||
| def raiser(exception, msg='std'): | ||
| raise exception(msg) | ||
|
|
||
|
|
||
| class FalseyBoolException(Exception): | ||
| def __bool__(self): | ||
| return False | ||
|
|
||
|
|
||
| class FalseyLenException(Exception): | ||
| def __len__(self): | ||
| return 0 | ||
|
|
||
|
|
||
| class ExecutorTest: | ||
|
|
||
| # Executor.shutdown() and context manager usage is tested by | ||
| Expand Down Expand Up | @@ -205,3 +220,16 @@ def test_free_reference(self): | |
| for _ in support.sleeping_retry(support.SHORT_TIMEOUT): | ||
| if wr() is None: | ||
| break | ||
|
|
||
| def test_swallows_falsey_exceptions(self): | ||
| # see gh-132063: Prevent exceptions that evaluate as falsey | ||
| # from being ignored. | ||
| # Recall: `x` is falsey if `len(x)` returns 0 or `bool(x)` returns False. | ||
|
|
||
| msg = 'boolbool' | ||
| with self.assertRaisesRegex(FalseyBoolException, msg): | ||
| self.executor.submit(raiser, FalseyBoolException, msg).result() | ||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThis 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.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityDoes this method return directy the result ?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThere is a follow-up with the TracebackExceptionclass which swallows __cause__ and __context__ content of falsey exceptions.
Sorry, something went wrong.
All reactions
|
||
|
|
||
| msg = 'lenlen' | ||
| with self.assertRaisesRegex(FalseyLenException, msg): | ||
| self.executor.submit(raiser, FalseyLenException, msg).result() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Prevent exceptions that evaluate as falsey (namely, when their ``__bool__`` method returns ``False`` or their ``__len__`` method returns 0) | ||
| from being ignored by :class:`concurrent.futures.ProcessPoolExecutor` and :class:`concurrent.futures.ThreadPoolExecutor`. |
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.