diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2014-04-02 16:44:50 +0300 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2014-04-02 16:44:50 +0300 |
commit | 6c2d06e155a7e1279bb52abc264b2adb853d2467 (patch) | |
tree | f770bb621238fe69de137b59bfd807bc95973e71 /scoped_nodes.py | |
parent | 90704dfbf9a0c21a0169f92f7e1a8ddcfcce186a (diff) | |
parent | fa89464e61ca7636123c6cd267d3730ea5f61f30 (diff) | |
download | astroid-git-6c2d06e155a7e1279bb52abc264b2adb853d2467.tar.gz |
Merged logilab/astroid into default
Diffstat (limited to 'scoped_nodes.py')
-rw-r--r-- | scoped_nodes.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/scoped_nodes.py b/scoped_nodes.py index 8d0a2349..b066cda7 100644 --- a/scoped_nodes.py +++ b/scoped_nodes.py @@ -25,6 +25,10 @@ __doctype__ = "restructuredtext en" import sys from itertools import chain +try: + from io import BytesIO +except ImportError: + from cStringIO import StringIO as BytesIO from logilab.common.compat import builtins from logilab.common.decorators import cached @@ -217,6 +221,8 @@ class Module(LocalsDictNodeNG): # the file from which as been extracted the astroid representation. It may # be None if the representation has been built from a built-in module file = None + # Alternatively, if built from a string/bytes, this can be set + file_bytes = None # encoding of python source file, so we can get unicode out of it (python2 # only) file_encoding = None @@ -245,6 +251,8 @@ class Module(LocalsDictNodeNG): @property def file_stream(self): + if self.file_bytes is not None: + return BytesIO(self.file_bytes) if self.file is not None: return open(self.file, 'rb') return None |