-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Module import not functioning as expected on STM #304
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
Comments
Oops, I just noticed issue #298 also references this topic. Apologies for duplicating stuff. |
One quick comment is that |
Oops. I apparently was wrong, it works. |
Thanks for report. This is definitely STM-specific issue, and is regression from #258 - I hoped that @dpgeorge will follow with changes for stm, but apparently, that slipped (I shouldn't have left it in such state). #309 posted which should fix the issue, but note that it's not tested (I don't work with bare-metal ports so far), so please help testing. |
Okay, I have tried this with the latest build and it works, with 1 change: I renamed Note that you can use CTRL-C at the minicom prompt to break out of the infinite loop. It'll then pop you into REPL. CTRL-D will then soft-reset, taking you back to the main.py program. |
I have also tried this and can confirm that it works when renaming the test module to Code sharingI know the topic of code sharing has been raised by @dhylands in #187 but in the light of this bug I would like to raise it here too. It doesn't make sense to me that importing works in the I've made it clear before that my knowledge of C is just enough to be dangerous so take what I say with a pinch of salt. In Java one would naturally make use of inheritance to deal with this issue. My 5 minutes of browsing showed me it isn't quite so easy in C but there does seem to be ways of dealing with this problem: http://stackoverflow.com/questions/415452/object-orientation-in-c/415536#415536 This is my 2c worth and I will leave it up to the C gurus to come up with something more robust than we currently have. |
It seems this Laurent Deniau chap is quite the guru in writing object oriented C code: Object Oriented Programming in C Chapter 4 (Inheritance — Code Reuse and Refinement) of his ?1993? book Object-Oriented Programming With ANSI-C seems to be just the thing we need. I'll read it and see whether I can figure out what he is on about. His more recent work seems to be pushing towards creating an entire object oriented framework for C which is probably a bit of an overkill for us: Overview of the C Object System ∗ But the rest of you probably knew all this already? |
@royemmerich: There's misunderstanding, import didn't work for STM not because it has different implementation if import comparing to Unix port, but because it had filesystem semantics differences from a normal POSIX filesystem. Specifically:
Per patch and comments above, search path issue is now resolved. So, let's close this ticket. Feel free to open separate tickets for other issues uncovered (like no support for long filenames on FS level). |
Some correction: support for current dir, etc. is subject to configuration of fatfs, more info: http://elm-chan.org/fsw/ff/en/filename.html Long filenames support was posted in #316. |
Following my statement in issue #284 that importing is not working and @pfalcon's reply that it is (apropos #282), I decided to write a simple test case to show my findings.
I am basing my test case on the assumption that an
import
call will look inside the following two folders on the micropython chip:/
/SRC
Case 1
/SRC
folder.MAIN.PY
v1Using:
minicom -D /dev/ttyACM0
I see a nice, steady counter printout to the console 👍
Case 2
/SRC
foldertest_module.py
and modified main.py to look like this:
MAIN.PY
v2which resulted in no compilation error and no counter printout to the minicom console 👎 .
From the commented out code you will see that I also tried the format
from <module_name> import <function>
and it also didn't work.
Am I not understanding something or is it just not working?
The text was updated successfully, but these errors were encountered: