Skip to content

Commit

Permalink
gh-102251: Updates to test_imp Toward Fixing Some Refleaks (gh-102254)
Browse files Browse the repository at this point in the history
This is related to fixing the refleaks introduced by commit 096d009.  I haven't been able to find the leak yet, but these changes are a consequence of that effort.  This includes some cleanup, some tweaks to the existing tests, and a bunch of new test cases.  The only change here that might have impact outside the tests in question is in imp.py, where I update imp.load_dynamic() to use spec_from_file_location() instead of creating a ModuleSpec directly.

Also note that I've updated the tests to only skip if we're checking for refleaks (regrtest's --huntrleaks), whereas in gh-101969 I had skipped the tests entirely.  The tests will be useful for some upcoming work and I'd rather the refleaks not hold that up.  (It isn't clear how quickly we'll be able to fix the leaking code, though it will certainly be done in the short term.)

#102251
  • Loading branch information
ericsnowcurrently committed Feb 27, 2023
1 parent 0db6f44 commit bb0cf8f
Show file tree
Hide file tree
Showing 4 changed files with 952 additions and 299 deletions.
4 changes: 2 additions & 2 deletions Lib/imp.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ def load_dynamic(name, path, file=None):

# Issue #24748: Skip the sys.modules check in _load_module_shim;
# always load new extension
spec = importlib.machinery.ModuleSpec(
name=name, loader=loader, origin=path)
spec = importlib.util.spec_from_file_location(
name, path, loader=loader)
return _load(spec)

else:
Expand Down
Loading

0 comments on commit bb0cf8f

Please sign in to comment.