-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
py: Rename sys module to usys. #6164
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
Conversation
Thanks, I guess this makes sense to do. But would need to think about it considering the previous discussion (which included sys/usys) in #4370 |
Main reason for this PR is last line in the commit: I came across the need for From previous discussion it looks like the main argument against doing this is that |
Yes, that does make sense, that's what the u-module naming is for (actually the u-module naming is overloaded, it means both "subset of CPy" and "extension of CPy", which is why it's sometimes confusing...). But note there are quite a few test failures with qemu-arm and minimal unix, and this is because they are not enabling weak-links which would automatically search for |
Not really.. But all other modules like array also use the tests like that, and leaving weak links disabled should stay like that imo (minimalism, plus making sure that also has test coverage). So I'm inclined to change the tests. |
Agreed. But note that this change will break (custom) ports that do not enable weak links and use "import sys". In some places sys is used to detect uPy vs CPy via It would be easy to add a special weak link for sys->usys which is always enabled, and that would retain backwards compatibility (import sys still works). But that seems a bit messy.
Probably this is the right approach. There'll also need to be a notice in the release notes that sys is now gone... |
38ae8b7
to
c48d812
Compare
I've updated this now and changed to usys in all places (nearly all tests), except
Code which is meant to be ran using MicroPython will |
Note: no idea why the usyncaio_fair test fails. It doesn't seem to reach the after_failure stage, or that is skipped, so test failures are not printed (which is a problem by itself) and I cannot reproduce it locally nor on my own Travis builds. |
Rerunning the Travis job made it pass... |
See #6374 for a proposed fix to the uasyncio_fair test. |
uasyncio_fair test fix is pushed to master, so this could be rebased. |
This is consistent with the other 'micro' modules and allows implementing additional features via e.g. micropython-lib's sys. Note this change is not backwards compatible for ports which do not enable weak links as they used to be able to import sys but won't be able to do that anymore now, and need to use import usys.
I'm happy to make this change but IMO it should wait until after the impending v1.13 release. |
Sure, no problem. |
For cross-platform code to run on official firmware on ESPx or Pyboard, on the Unix build, or under CPython I use this: import sys
if sys.implementation.name == 'micropython':
# Running MicroPython
else:
# Running CPython Will this continue to work on Unix/hardware ports courtesy of weak links? |
This will keep on working for ports which have weak links enabled, and will fail with an I get that this is a drastic change, but, as usual, hard to tell how much code is actually going to be affected? |
IMHO quite a lot. So what is the strong reason for the change? |
Consistency with all other u-modules and being able to extend the sys module by having a sys.py, instead of having to extend it in C (also see comments at the beginning of this thread). From a quick search it looks like these ports are affected i.e. don't have weak links enabled:
|
Ok, merged in 40ad8f1 All of the main "production" ports should be OK, code should run unchanged on them. If issues come up we can address them. |
Thanks! |
This is consistent with the other 'micro' modules and allows
implementing additional features via e.g. micropython-lib's sys.