Skip to content

Commit

Permalink
Merge branch 'master' into issue843
Browse files Browse the repository at this point in the history
  • Loading branch information
timmartin committed Oct 31, 2020
2 parents c89dc01 + 4629777 commit c9c5792
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Release Date: TBA

Fixes #843

* Reduce memory usage of astroid's module cache.

What's New in astroid 2.4.3?
============================
Expand Down
2 changes: 1 addition & 1 deletion astroid/interpreter/_import/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def _is_setuptools_namespace(location):
with open(os.path.join(location, "__init__.py"), "rb") as stream:
data = stream.read(4096)
except IOError:
pass
return None
else:
extend_path = b"pkgutil" in data and b"extend_path" in data
declare_namespace = (
Expand Down
6 changes: 4 additions & 2 deletions astroid/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,13 @@ def file_from_module_name(self, modname, contextfile):
value = exceptions.AstroidImportError(
"Failed to import module {modname} with error:\n{error}.",
modname=modname,
error=ex,
# we remove the traceback here to save on memory usage (since these exceptions are cached)
error=ex.with_traceback(None),
)
self._mod_file_cache[(modname, contextfile)] = value
if isinstance(value, exceptions.AstroidBuildingError):
raise value
# we remove the traceback here to save on memory usage (since these exceptions are cached)
raise value.with_traceback(None)
return value

def ast_from_module(self, module, modname=None):
Expand Down
2 changes: 1 addition & 1 deletion astroid/node_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ def next_sibling(self):
try:
return stmts[index + 1]
except IndexError:
pass
return None

def previous_sibling(self):
"""The previous sibling statement.
Expand Down

0 comments on commit c9c5792

Please sign in to comment.