summaryrefslogtreecommitdiff
path: root/builder.py
diff options
context:
space:
mode:
authorSylvain Thénault <thenault@gmail.com>2014-03-26 14:20:42 +0100
committerSylvain Thénault <thenault@gmail.com>2014-03-26 14:20:42 +0100
commitfa89464e61ca7636123c6cd267d3730ea5f61f30 (patch)
treebb05f4ee19ba64dba439f33ec77a17d469c01fa9 /builder.py
parent6cd480552017e6e44f0bc0c17687fc1c380fb9c7 (diff)
parent5d6c158ab8b2d2701bf22add64c2bf41b19f9a34 (diff)
downloadastroid-git-fa89464e61ca7636123c6cd267d3730ea5f61f30.tar.gz
Merged in flyingsheep/astroid (pull request #15)
AstroidBuilder.string_build was incompatible with file_stream
Diffstat (limited to 'builder.py')
-rw-r--r--builder.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/builder.py b/builder.py
index b088b205..0271f714 100644
--- a/builder.py
+++ b/builder.py
@@ -131,13 +131,20 @@ class AstroidBuilder(InspectBuilder):
except ImportError:
modname = splitext(basename(path))[0]
# build astroid representation
- node = self.string_build(data, modname, path)
- node.file_encoding = encoding
- return node
+ 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._data_build(data, modname, path)
+ module.file_bytes = data.encode('utf-8')
+ return self._post_build(module, 'utf-8')
+
+ 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: