diff options
author | Phil Schaf <flying-sheep@web.de> | 2013-11-25 18:34:58 +0100 |
---|---|---|
committer | Phil Schaf <flying-sheep@web.de> | 2013-11-25 18:34:58 +0100 |
commit | 982bfdf69aa34b039188be874c0d75c67dd74017 (patch) | |
tree | 19a004a8518d4af753a94b8b9d02d5289a7d016e /builder.py | |
parent | f73645102c409efae359395bcd2ea674a4716090 (diff) | |
download | astroid-git-982bfdf69aa34b039188be874c0d75c67dd74017.tar.gz |
moved setting of module.file_encoding to _post_build()
Diffstat (limited to 'builder.py')
-rw-r--r-- | builder.py | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -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: |