summaryrefslogtreecommitdiff
path: root/builder.py
diff options
context:
space:
mode:
authorPhil Schaf <flying-sheep@web.de>2013-11-25 18:34:58 +0100
committerPhil Schaf <flying-sheep@web.de>2013-11-25 18:34:58 +0100
commit982bfdf69aa34b039188be874c0d75c67dd74017 (patch)
tree19a004a8518d4af753a94b8b9d02d5289a7d016e /builder.py
parentf73645102c409efae359395bcd2ea674a4716090 (diff)
downloadastroid-git-982bfdf69aa34b039188be874c0d75c67dd74017.tar.gz
moved setting of module.file_encoding to _post_build()
Diffstat (limited to 'builder.py')
-rw-r--r--builder.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/builder.py b/builder.py
index e69ae97d..d4a9a8e0 100644
--- a/builder.py
+++ b/builder.py
@@ -124,18 +124,20 @@ class AstroidBuilder(InspectBuilder):
except ImportError:
modname = splitext(basename(path))[0]
# build astroid representation
- module = self._post_build(self._data_build(data, modname, path))
- module.file_encoding = encoding
- return module
+ module = self._data_build(data, modname, path)
+ return self._post_build(module, encoding)
def string_build(self, data, modname='', path=None):
"""build astroid from source code string and return rebuilded astroid"""
- module = self._post_build(self._data_build(data, modname, path))
+ module = self._data_build(data, modname, path)
module.file_bytes = data.encode('utf-8')
- module.file_encoding = 'utf-8'
- return module
+ return self._post_build(module, 'utf-8')
- def _post_build(self, module):
+ def _post_build(self, module, encoding):
+ """handles encoding and delayed nodes
+ after a module has been built
+ """
+ module.file_encoding = encoding
self._manager.astroid_cache[module.name] = module
# post tree building steps after we stored the module in the cache:
for from_node in module._from_nodes: