Skip to content

Commit

Permalink
fix: Avoid ImportWarning when using _ImportRedirect
Browse files Browse the repository at this point in the history
This is an incomplete fix as it does not implement `exec_module()`, which means `importlib.reload()` would not have any effect.  I'm planning to deprecate the `bottle.ext.whatever -> bottle_whatever` import hack anyway, though.

Fixes #1435
  • Loading branch information
defnull committed Sep 5, 2024
1 parent 0213798 commit 90d749b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bottle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2086,6 +2086,12 @@ def find_module(self, fullname, path=None):
if fullname.rsplit('.', 1)[0] != self.name: return
return self

def create_module(self, spec):
return self.load_module(spec.name)

def exec_module(self, module):
pass # This probably breaks importlib.reload() :/

def load_module(self, fullname):
if fullname in sys.modules: return sys.modules[fullname]
modname = fullname.rsplit('.', 1)[1]
Expand Down

0 comments on commit 90d749b

Please sign in to comment.