Skip to content
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

fix potential circular import #215

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ChanceNCounter
Copy link
Contributor

Fixes potential circular import during the import-and-crawl phrase of localized function caching, where a localized file attempts to reference its parent. By initializing the rest of the parent file before attempting to populate the localized function dictionary, it seems to delay the whole thing (and therefore the import-and-crawl phrase) long enough to avoid the ImportError.

In reality, when the potential error hits, the parent file is still partially initialized. In other words, this could technically still be described as a circular import, but, because Python is Python, does not have the effect of one; whatever the localized file is attempting to reference in its parent, that function will necessarily already have been parsed before the localized function is imported.

This is known to work, because HelloChatterbox ran into the problem, and I've already tested the fix against their code.

@ChanceNCounter ChanceNCounter added the bug Something isn't working label Nov 10, 2021
@devs-mycroft devs-mycroft added the CLA: Yes Contributor License Agreement exists (see https://github.com/MycroftAI/contributors) label Nov 10, 2021
@ChanceNCounter
Copy link
Contributor Author

Note: this bug doesn't exist yet, but now it's impossible to write!

Additional note: Local unit tests are currently wonky because of #203, pending #209. However, there is no change in test status, either on GitHub or On My Computer. Moot point if #209 gets in before this does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working CLA: Yes Contributor License Agreement exists (see https://github.com/MycroftAI/contributors)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants