-
-
Notifications
You must be signed in to change notification settings - Fork 19
Support reloading namespaces #1035
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
74ca790 to
60c1c5c
Compare
99a86e0 to
913d188
Compare
| if (cached := self._cache.get(fullname)) is None: | ||
| spec = module.__spec__ | ||
| assert spec is not None, "Module must have a spec" | ||
| cached = {"spec": spec} | ||
| self._cache[spec.name] = cached |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I doubt this ever happens except in testing, but I was finding that calling monkeypatch.syspath_prepend that monkeypatch calls importlib.invalidate_caches() which was causing issues trying to access values from the cache without any guard. Now we just reconstruct the cache from the module if that does happen.
| ns_sym = sym.symbol(ns_name) | ||
| ns = self.get(ns_sym) | ||
| assert ns is not None, "Namespace must exist after being required" | ||
| self.add_alias(ns, ns_sym) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it was always my intent to add the fully-qualified name as an alias to the namespace, but it never mattered before now.
Fixes #1060