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

Adding find_spec to ModuleImporterFromVariables #536

Merged
merged 2 commits into from
Aug 28, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion sh.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# ===============================================================================
__version__ = "1.13.1"
__version__ = "1.13.2"
__project_url__ = "https://github.com/amoffat/sh"

from collections import deque, Mapping
Expand Down Expand Up @@ -3627,6 +3627,9 @@ def find_module(self, mod_fullname, path=None):

parent_frame = inspect.currentframe().f_back

if parent_frame and parent_frame.f_code.co_name == "find_spec":
parent_frame = parent_frame.f_back

while parent_frame and in_importlib(parent_frame):
parent_frame = parent_frame.f_back

Expand All @@ -3651,6 +3654,13 @@ def find_module(self, mod_fullname, path=None):

return self

def find_spec(self, fullname, path=None, target=None):
"find_module() is deprecated since Python 3.4 in favor of find_spec()"

from importlib.machinery import ModuleSpec
found = self.find_module(fullname, path)
return ModuleSpec(fullname, found) if found is not None else None

def load_module(self, mod_fullname):
parent_frame = inspect.currentframe().f_back

Expand Down