-
Notifications
You must be signed in to change notification settings - Fork 1.3k
io module gets initialized multiple times when opening files #557
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
You're on the right track with your fix, and that should fix the issue short-term, but I think the better solution would be to keep a HashMap of stdlib modules that have already been initialized in the VM, next to the |
It already kinda is in the The problem, as far as I can tell, was that any module should only be initialized by the import, never manually in any stdlib function. EDIT: in other words, when modules are imported using the proper |
Or better yet, held in the same HashMap with a |
Alright, that's valid. I thought it was done that way to prevent someone from replacing a built-in module through |
When experimenting with file IO, I found out that when opening a file, one always initializes the
io
module from scratch (and then, when importing it, one initializes it exactly once, no matter how many times it’s been already initialized), making checking if objects are instances of given classes from that module impossible, as those classes are represented by different memory objects, eg.:It seems this is the only module affected by this behaviour (all the other
mk_module(&ctx)
functions are afaik used only in themodule_inits
hash map used for import initialization).The text was updated successfully, but these errors were encountered: