Fix random import error when running scripts #2610
Open
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.
Addresses #2609
The underlying issue seemed to be some inconsistency with
__initialized__and__initializing__variables. I'm under the impression these are both Brython internals.It's possible these were separated on purpose.
I think the "from" import is potentially incorrect, or at least could be reorganized to make its intent clearer, but it looks like simply updating everything to
__initialized__fixed the VFS issue I was seeing. It's probably hiding an issue with the logic.I also changed the logic to what I thought it was trying to do and found that lazy (file based, not VFS) imports broke (see the revert here: 6a6a678)
I'm guessing this logic is important to keep as-is but didn't look into why. Having it also check for
__file__breaks this: