-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
py: clean up definition and use of mp_handle_pending()
#18672
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
base: master
Are you sure you want to change the base?
Conversation
In c57aebf `mp_handle_pending()` became a static-inline function. So these declarations in `mpconfigport.h` are incorrect and removed by this commit. Signed-off-by: Damien George <damien@micropython.org>
This is functionally a no-op, although will change compiled code due to the numerical values of the enums changing. This is needed for a follow-up commit, to remove the static-inline `mp_handle_pending(bool)` helper function. Signed-off-by: Damien George <damien@micropython.org>
This commit removes the static-inline `mp_handle_pending()` wrapper function, which was originally added for backwards compatibility. It replaces it with `mp_handle_pending_internal()` which is renamed to `mp_handle_pending()`, which has the same arguments. Signed-off-by: Damien George <damien@micropython.org>
This should be a no-op because the enum and bool have the same numeric value. Signed-off-by: Damien George <damien@micropython.org>
|
Code size report: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #18672 +/- ##
=======================================
Coverage 98.38% 98.38%
=======================================
Files 171 171
Lines 22298 22298
=======================================
Hits 21937 21937
Misses 361 361 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
This looks good to me. However, since you're making changes to all those files anyway, with the exception or unix port's main.c, shouldn't we just call |
You are right that we need to convert the remaining ports to use the new event functions, like But changing I would therefore like to convert the remaining ports one-by-one, to make sure they are properly tested. For now, this PR has much simpler scope, just to clean up |
Note that no port defines And with the exception of esp8266, renesas, no port defines |
No, that's not how it's supposed to work. The current design is:
If As I mentioned above, we need to convert (one by one) each port to use the new lower layer. The change in this PR is kind of orthogonal to that. |
|
I converted stm32 to the new scheme in #18679. If we convert all the ports first, then this PR becomes a lot simpler, although that might take some time to do. |
|
I converted the webassembly port to the new event scheme in #18682. |
|
I converted the zephyr port to the new event scheme in #18685. |
Summary
Commit c57aebf added more functionality to
mp_handle_pending(), passing in an enum instead of a bool to select whether exceptions are ignored, cleared or raised.That commit attempted to keep the original behaviour of
mp_handle_pending(bool)with a bool argument by making it static-inline, but that doesn't work in all cases (see #18663).This PR cleans up the definition and use of this function:
extern void mp_handle_pending(bool);inmpconfigport.htruemaps toMP_HANDLE_PENDING_CALLBACKS_AND_EXCEPTIONSandfalsemaps toMP_HANDLE_PENDING_CALLBACKS_AND_CLEAR_EXCEPTIONSmp_handle_pending_internal()tomp_handle_pending()Functionality should be unchanged, and backwards compatibility with
mp_handle_pending()should be retained.Fixes issue #18663.
Testing
Tested locally on PYBV10.
CI will also test the change (the unix port already has special coverage testing for
mp_handle_pending()).Trade-offs and Alternatives
This touches all code that calls
mp_handle_pending()but that's necessary to fully clean it up.The enum for
mp_handle_pending_behaviour_tnow defines the first and second values asfalseandtrue, which is a bit awkward but will explicitly retain backwards compatibility.