Repository navigation
mip: Avoid str.rpartition for limited builds. - #1174
Open
mattytrentini wants to merge 1 commit into
Open
mattytrentini wants to merge 1 commit into
mattytrentini wants to merge 1 commit into
Conversation
ESP8266 disables str.partition and str.rpartition to save flash, so installing a package manifest currently fails when deriving its base URL. Use rfind and slicing instead, preserving the empty prefix when no slash is present. This avoids requiring partition support on limited builds without removing the on-device package installer. Bump mip to version 0.5.1. See micropython/micropython#19844 Signed-off-by: Matt Trentini <matt.trentini@gmail.com>
Josverl
reviewed
Nov 3, 2026
| return False | ||
| base_url = package_json_url.rpartition("/")[0] | ||
| # str.rpartition is not available on all builds. | ||
| slash = package_json_url.rfind("/") |
Contributor
There was a problem hiding this comment.
is there a reason not to use package_json_url.split("/",1)[0] ?
That would leave the code simpler and I assume the memory fragmentation is not that much worse
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The ESP8266 port disables
str.partitionandstr.rpartition(withMICROPY_PY_BUILTINS_STR_PARTITION) to save flash. mip usesstr.rpartitionso mip fails when running on an ESP8266. This PR usesrfindand slicing instead ofrpartitionso mip operates on the ESP8266.Bump mip to version 0.5.1 (from 0.5.0).
Testing
Tested on the unix port to ensure mip continues to work correctly.
Not tested on the ESP8266 yet.
Trade-offs and Alternatives
The initial workaround was to remove onboard mip from the ESP8266 port. See #19844.
Generative AI
I used generative AI tools when creating this PR, but a human has checked the code and is responsible for the code and the description above.