[Python-modules-commits] [astroid] 01/05: Import astroid_1.4.3.orig.tar.gz

Sandro Tosi morph at moszumanska.debian.org
Sun Jan 3 02:27:07 UTC 2016


This is an automated email from the git hooks/post-receive script.

morph pushed a commit to branch master
in repository astroid.

commit 47789771b1400fd18a015760ad5c747081ea720b
Author: Sandro Tosi <morph at debian.org>
Date:   Sun Jan 3 02:14:08 2016 +0000

    Import astroid_1.4.3.orig.tar.gz
---
 ChangeLog                              | 30 +++++++++++++++++++
 PKG-INFO                               |  2 +-
 README => README.rst                   |  0
 astroid.egg-info/PKG-INFO              |  2 +-
 astroid.egg-info/SOURCES.txt           |  2 +-
 astroid/__init__.py                    |  7 +++--
 astroid/__pkginfo__.py                 |  2 +-
 astroid/as_string.py                   | 12 ++++----
 astroid/bases.py                       |  2 +-
 astroid/brain/brain_gi.py              |  4 +--
 astroid/brain/brain_stdlib.py          | 22 +++++++++-----
 astroid/modutils.py                    | 53 +++++++++++++++++++++++++---------
 astroid/protocols.py                   | 31 ++++++++++++--------
 astroid/scoped_nodes.py                | 43 +++++++++++++++++++++------
 astroid/tests/unittest_brain.py        |  9 ++++++
 astroid/tests/unittest_manager.py      |  3 +-
 astroid/tests/unittest_modutils.py     |  5 ++++
 astroid/tests/unittest_nodes.py        |  6 +++-
 astroid/tests/unittest_protocols.py    | 22 ++++++++++++++
 astroid/tests/unittest_regrtest.py     | 17 +++++++++++
 astroid/tests/unittest_scoped_nodes.py | 35 ++++++++++++++++++++++
 setup.cfg                              |  2 +-
 setup.py                               | 20 +++++++++++--
 tox.ini                                |  5 +---
 24 files changed, 268 insertions(+), 68 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 494c09b..197d6f3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,36 @@
 Change log for the astroid package (used to be astng)
 =====================================================
 
+2015-12-24 -- 1.4.3
+
+    * pkg_resources brain tips are a bit more specific,
+      by specifiying proper returns.
+
+    * Standard library modules are properly detected by is_standard_module.
+
+      This should fix issues such as https://github.com/PyCQA/pylint/issues/725.
+
+2015-12-21 -- 1.4.2
+
+    * The slots() method conflates all the slots from the ancestors
+      into a list of current and parent slots.
+
+      We're doing this because this is the right semantics of slots,
+      they get inherited, as long as each parent defines a __slots__
+      entry.
+
+    * Revert to using printf-style formatting in as_string, in order
+      to avoid a potential problem with encodings when using .format.
+      Closes issue #273.
+
+    * assigned_stmts methods have the same signature from now on.
+      
+      They used to have different signatures and each one made
+      assumptions about what could be passed to other implementations,
+      leading to various possible crashes when one or more arguments
+      weren't given. Closes issue #277.
+    
+
 2015-11-29 -- 1.4.1
 
 
diff --git a/PKG-INFO b/PKG-INFO
index 4392e1e..7816049 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: astroid
-Version: 1.4.1
+Version: 1.4.3
 Summary: A abstract syntax tree for Python with inference support.
 Home-page: http://bitbucket.org/logilab/astroid
 Author: Logilab
diff --git a/README b/README.rst
similarity index 100%
rename from README
rename to README.rst
diff --git a/astroid.egg-info/PKG-INFO b/astroid.egg-info/PKG-INFO
index 4392e1e..7816049 100644
--- a/astroid.egg-info/PKG-INFO
+++ b/astroid.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: astroid
-Version: 1.4.1
+Version: 1.4.3
 Summary: A abstract syntax tree for Python with inference support.
 Home-page: http://bitbucket.org/logilab/astroid
 Author: Logilab
diff --git a/astroid.egg-info/SOURCES.txt b/astroid.egg-info/SOURCES.txt
index 00d4dc3..19e02b4 100644
--- a/astroid.egg-info/SOURCES.txt
+++ b/astroid.egg-info/SOURCES.txt
@@ -2,7 +2,7 @@ COPYING
 COPYING.LESSER
 ChangeLog
 MANIFEST.in
-README
+README.rst
 setup.cfg
 setup.py
 tox.ini
diff --git a/astroid/__init__.py b/astroid/__init__.py
index 8b7f73a..175dcb5 100644
--- a/astroid/__init__.py
+++ b/astroid/__init__.py
@@ -114,8 +114,11 @@ def inference_tip(infer_function):
 def register_module_extender(manager, module_name, get_extension_mod):
     def transform(node):
         extension_module = get_extension_mod()
-        for name, obj in extension_module._locals.items():
-            node._locals[name] = obj
+        for name, objs in extension_module._locals.items():
+            node._locals[name] = objs
+            for obj in objs:
+                if obj.parent is extension_module:
+                    obj.parent = node
 
     manager.register_transform(Module, transform, lambda n: n.name == module_name)
 
diff --git a/astroid/__pkginfo__.py b/astroid/__pkginfo__.py
index 055be0f..d3ce966 100644
--- a/astroid/__pkginfo__.py
+++ b/astroid/__pkginfo__.py
@@ -20,7 +20,7 @@ distname = 'astroid'
 
 modname = 'astroid'
 
-numversion = (1, 4, 1)
+numversion = (1, 4, 3)
 version = '.'.join([str(num) for num in numversion])
 
 install_requires = ['six', 'lazy_object_proxy', 'wrapt']
diff --git a/astroid/as_string.py b/astroid/as_string.py
index d7786fe..2b07200 100644
--- a/astroid/as_string.py
+++ b/astroid/as_string.py
@@ -287,13 +287,11 @@ class AsStringVisitor(object):
             trailer = return_annotation + ":"
         else:
             trailer = ":"
-        def_format = "\n{decorators}def {name}({args}){trailer}{docs}\n{body}"
-        return def_format.format(decorators=decorate,
-                                 name=node.name,
-                                 args=node.args.accept(self),
-                                 trailer=trailer,
-                                 docs=docs,
-                                 body=self._stmt_list(node.body))
+        def_format = "\n%sdef %s(%s)%s%s\n%s"
+        return def_format % (decorate, node.name,
+                             node.args.accept(self),
+                             trailer, docs,
+                             self._stmt_list(node.body))
 
     def visit_generatorexp(self, node):
         """return an astroid.GeneratorExp node as string"""
diff --git a/astroid/bases.py b/astroid/bases.py
index b90e1a4..8dfa812 100644
--- a/astroid/bases.py
+++ b/astroid/bases.py
@@ -47,7 +47,7 @@ PROPERTIES = {BUILTINS + '.property', 'abc.abstractproperty'}
 POSSIBLE_PROPERTIES = {"cached_property", "cachedproperty",
                        "lazyproperty", "lazy_property", "reify",
                        "lazyattribute", "lazy_attribute",
-                       "LazyProperty"}
+                       "LazyProperty", "lazy"}
 
 
 def _is_property(meth):
diff --git a/astroid/brain/brain_gi.py b/astroid/brain/brain_gi.py
index f8acb42..d9fc1b4 100644
--- a/astroid/brain/brain_gi.py
+++ b/astroid/brain/brain_gi.py
@@ -47,13 +47,13 @@ def _gi_build_stub(parent):
         elif (inspect.ismethod(obj) or
               inspect.ismethoddescriptor(obj)):
             methods[name] = obj
-        elif isinstance(obj, (int, str)):
-            constants[name] = obj
         elif (str(obj).startswith("<flags") or
               str(obj).startswith("<enum ") or
               str(obj).startswith("<GType ") or
               inspect.isdatadescriptor(obj)):
             constants[name] = 0
+        elif isinstance(obj, (int, str)):
+            constants[name] = obj
         elif callable(obj):
             # Fall back to a function for anything callable
             functions[name] = obj
diff --git a/astroid/brain/brain_stdlib.py b/astroid/brain/brain_stdlib.py
index bcd7f3b..cbc9736 100644
--- a/astroid/brain/brain_stdlib.py
+++ b/astroid/brain/brain_stdlib.py
@@ -156,30 +156,36 @@ class deque(object):
 
 def pkg_resources_transform():
     return AstroidBuilder(MANAGER).string_build('''
-
 def resource_exists(package_or_requirement, resource_name):
-    pass
+    return get_provider(package_or_requirement).has_resource(resource_name)
 
 def resource_isdir(package_or_requirement, resource_name):
-    pass
+    return get_provider(package_or_requirement).resource_isdir(
+        resource_name)
 
 def resource_filename(package_or_requirement, resource_name):
-    pass
+    return get_provider(package_or_requirement).get_resource_filename(
+        self, resource_name)
 
 def resource_stream(package_or_requirement, resource_name):
-    pass
+    return get_provider(package_or_requirement).get_resource_stream(
+        self, resource_name)
 
 def resource_string(package_or_requirement, resource_name):
-    pass
+    return get_provider(package_or_requirement).get_resource_string(
+        self, resource_name)
 
 def resource_listdir(package_or_requirement, resource_name):
-    pass
+    return get_provider(package_or_requirement).resource_listdir(
+        resource_name)
 
 def extraction_error():
     pass
 
 def get_cache_path(archive_name, names=()):
-    pass
+    extract_path = self.extraction_path or get_default_cache()
+    target_path = os.path.join(extract_path, archive_name+'-tmp', *names)
+    return target_path
 
 def postprocess(tempname, filename):
     pass
diff --git a/astroid/modutils.py b/astroid/modutils.py
index 2dd88c9..45c96f7 100644
--- a/astroid/modutils.py
+++ b/astroid/modutils.py
@@ -50,12 +50,7 @@ else:
     PY_SOURCE_EXTS = ('py',)
     PY_COMPILED_EXTS = ('so',)
 
-# Notes about STD_LIB_DIRS
-# Consider arch-specific installation for STD_LIB_DIRS definition
-# :mod:`distutils.sysconfig` contains to much hardcoded values to rely on
-#
-# :see: `Problems with /usr/lib64 builds <http://bugs.python.org/issue1294959>`_
-# :see: `FHS <http://www.pathname.com/fhs/pub/fhs-2.3.html#LIBLTQUALGTALTERNATEFORMATESSENTIAL>`_
+
 try:
     # The explicit sys.prefix is to work around a patch in virtualenv that
     # replaces the 'real' sys.prefix (i.e. the location of the binary)
@@ -67,18 +62,50 @@ try:
         # Take care of installations where exec_prefix != prefix.
         get_python_lib(standard_lib=True, prefix=sys.exec_prefix),
         get_python_lib(standard_lib=True)])
-    if os.name == 'nt':
-        STD_LIB_DIRS.add(os.path.join(sys.prefix, 'dlls'))
-        try:
-            # real_prefix is defined when running inside virtualenv.
-            STD_LIB_DIRS.add(os.path.join(sys.real_prefix, 'dlls'))
-        except AttributeError:
-            pass
 # get_python_lib(standard_lib=1) is not available on pypy, set STD_LIB_DIR to
 # non-valid path, see https://bugs.pypy.org/issue1164
 except DistutilsPlatformError:
     STD_LIB_DIRS = set()
 
+if os.name == 'nt':
+    STD_LIB_DIRS.add(os.path.join(sys.prefix, 'dlls'))
+    try:
+        # real_prefix is defined when running inside virtualenv.
+        STD_LIB_DIRS.add(os.path.join(sys.real_prefix, 'dlls'))
+    except AttributeError:
+        pass
+if platform.python_implementation() == 'PyPy':
+    _root = os.path.join(sys.prefix, 'lib_pypy')
+    STD_LIB_DIRS.add(_root)
+    try:
+        # real_prefix is defined when running inside virtualenv.
+        STD_LIB_DIRS.add(os.path.join(sys.real_prefix, 'lib_pypy'))
+    except AttributeError:
+        pass
+    del _root
+if os.name == 'posix':
+    # Need the real prefix is we're under a virtualenv, otherwise
+    # the usual one will do.
+    try:
+        prefix = sys.real_prefix
+    except AttributeError:
+        prefix = sys.prefix
+
+    def _posix_path(path):
+        base_python = 'python%d.%d' % sys.version_info[:2]
+        return os.path.join(prefix, path, base_python)
+
+    STD_LIB_DIRS.add(_posix_path('lib'))
+    if sys.maxsize > 2**32:
+        # This tries to fix a problem with /usr/lib64 builds,
+        # where systems are running both 32-bit and 64-bit code
+        # on the same machine, which reflects into the places where
+        # standard library could be found. More details can be found
+        # here http://bugs.python.org/issue1294959.
+        # An easy reproducing case would be
+        # https://github.com/PyCQA/pylint/issues/712#issuecomment-163178753
+        STD_LIB_DIRS.add(_posix_path('lib64'))
+
 EXT_LIB_DIR = get_python_lib()
 IS_JYTHON = platform.python_implementation() == 'Jython'
 BUILTIN_MODULES = dict.fromkeys(sys.builtin_module_names, True)
diff --git a/astroid/protocols.py b/astroid/protocols.py
index d92edac..6f15998 100644
--- a/astroid/protocols.py
+++ b/astroid/protocols.py
@@ -250,7 +250,7 @@ def _resolve_looppart(parts, asspath, context):
 
 
 @bases.raise_if_nothing_inferred
-def for_assigned_stmts(self, node, context=None, asspath=None):
+def for_assigned_stmts(self, node=None, context=None, asspath=None):
     if asspath is None:
         for lst in self.iter.infer(context):
             if isinstance(lst, (nodes.Tuple, nodes.List)):
@@ -265,18 +265,25 @@ nodes.For.assigned_stmts = for_assigned_stmts
 nodes.Comprehension.assigned_stmts = for_assigned_stmts
 
 
-def mulass_assigned_stmts(self, node, context=None, asspath=None):
+def sequence_assigned_stmts(self, node=None, context=None, asspath=None):
     if asspath is None:
         asspath = []
-    asspath.insert(0, self.elts.index(node))
-    return self.parent.assigned_stmts(self, context, asspath)
+    try:
+        index = self.elts.index(node)
+    except ValueError:
+         util.reraise(exceptions.InferenceError(
+             'Tried to retrieve a node {node!r} which does not exist',
+             node=self, assign_path=asspath, context=context))
+
+    asspath.insert(0, index)
+    return self.parent.assigned_stmts(node=self, context=context, asspath=asspath)
 
-nodes.Tuple.assigned_stmts = mulass_assigned_stmts
-nodes.List.assigned_stmts = mulass_assigned_stmts
+nodes.Tuple.assigned_stmts = sequence_assigned_stmts
+nodes.List.assigned_stmts = sequence_assigned_stmts
 
 
-def assend_assigned_stmts(self, context=None):
-    return self.parent.assigned_stmts(self, context=context)
+def assend_assigned_stmts(self, node=None, context=None, asspath=None):
+    return self.parent.assigned_stmts(node=self, context=context)
 nodes.AssignName.assigned_stmts = assend_assigned_stmts
 nodes.AssignAttr.assigned_stmts = assend_assigned_stmts
 
@@ -325,7 +332,7 @@ def _arguments_infer_argname(self, name, context):
         yield util.YES
 
 
-def arguments_assigned_stmts(self, node, context, asspath=None):
+def arguments_assigned_stmts(self, node=None, context=None, asspath=None):
     if context.callcontext:
         # reset call context/name
         callcontext = context.callcontext
@@ -339,7 +346,7 @@ nodes.Arguments.assigned_stmts = arguments_assigned_stmts
 
 
 @bases.raise_if_nothing_inferred
-def assign_assigned_stmts(self, node, context=None, asspath=None):
+def assign_assigned_stmts(self, node=None, context=None, asspath=None):
     if not asspath:
         yield self.value
         return
@@ -380,7 +387,7 @@ def _resolve_asspart(parts, asspath, context):
 
 
 @bases.raise_if_nothing_inferred
-def excepthandler_assigned_stmts(self, node, context=None, asspath=None):
+def excepthandler_assigned_stmts(self, node=None, context=None, asspath=None):
     for assigned in node_classes.unpack_infer(self.type):
         if isinstance(assigned, nodes.ClassDef):
             assigned = bases.Instance(assigned)
@@ -389,7 +396,7 @@ nodes.ExceptHandler.assigned_stmts = bases.raise_if_nothing_inferred(excepthandl
 
 
 @bases.raise_if_nothing_inferred
-def with_assigned_stmts(self, node, context=None, asspath=None):
+def with_assigned_stmts(self, node=None, context=None, asspath=None):
     if asspath is None:
         for _, vars in self.items:
             if vars is None:
diff --git a/astroid/scoped_nodes.py b/astroid/scoped_nodes.py
index ea1dbdb..c0b0179 100644
--- a/astroid/scoped_nodes.py
+++ b/astroid/scoped_nodes.py
@@ -535,6 +535,7 @@ class Module(LocalsDictNodeNG):
             all = self['__all__']
         except KeyError:
             return default
+
         try:
             explicit = next(all.assigned_stmts())
         except exceptions.InferenceError:
@@ -1578,6 +1579,22 @@ class ClassDef(mixins.FilterStmtsMixin, LocalsDictNodeNG, bases.Statement):
                 except exceptions.InferenceError:
                     continue
 
+    def _slots(self):
+        if not self.newstyle:
+            raise NotImplementedError(
+                "The concept of slots is undefined for old-style classes.")
+
+        slots = self._islots()
+        try:
+            first = next(slots)
+        except StopIteration as exc:
+            # The class doesn't have a __slots__ definition or empty slots.
+            if exc.args and exc.args[0] not in ('', None):
+                return exc.args[0]
+            return None
+        # pylint: disable=unsupported-binary-operation; false positive
+        return [first] + list(slots)
+
     # Cached, because inferring them all the time is expensive
     @decorators_mod.cached
     def slots(self):
@@ -1588,20 +1605,28 @@ class ClassDef(mixins.FilterStmtsMixin, LocalsDictNodeNG, bases.Statement):
         Also, it will return None in the case the slots weren't inferred.
         Otherwise, it will return a list of slot names.
         """
+        def grouped_slots():
+            # Not interested in object, since it can't have slots.
+            for cls in self.mro()[:-1]:
+                try:
+                    cls_slots = cls._slots()
+                except NotImplementedError:
+                    continue
+                if cls_slots is not None:
+                    for slot in cls_slots:
+                        yield slot
+                else:
+                    yield None
+
         if not self.newstyle:
             raise NotImplementedError(
                 "The concept of slots is undefined for old-style classes.")
 
-        slots = self._islots()
-        try:
-            first = next(slots)
-        except StopIteration as exc:
-            # The class doesn't have a __slots__ definition or empty slots.
-            if exc.args and exc.args[0] not in ('', None):
-                return exc.args[0]
+        slots = list(grouped_slots())
+        if not all(slot is not None for slot in slots):
             return None
-        # pylint: disable=unsupported-binary-operation; false positive
-        return [first] + list(slots)
+
+        return sorted(slots, key=lambda item: item.value)
 
     def _inferred_bases(self, context=None):
         # TODO(cpopa): really similar with .ancestors,
diff --git a/astroid/tests/unittest_brain.py b/astroid/tests/unittest_brain.py
index 81ad884..57d77ba 100644
--- a/astroid/tests/unittest_brain.py
+++ b/astroid/tests/unittest_brain.py
@@ -301,6 +301,15 @@ class MultiprocessingBrainTest(unittest.TestCase):
         else:
             self.assertIsInstance(cpu_count, astroid.BoundMethod)
 
+    def test_module_name(self):
+        module = test_utils.extract_node("""
+        import multiprocessing
+        multiprocessing.SyncManager()
+        """)
+        inferred_sync_mgr = next(module.infer())
+        module = inferred_sync_mgr.root()
+        self.assertEqual(module.name, 'multiprocessing.managers')
+
     def test_multiprocessing_manager(self):
         # Test that we have the proper attributes
         # for a multiprocessing.managers.SyncManager
diff --git a/astroid/tests/unittest_manager.py b/astroid/tests/unittest_manager.py
index 2bbd053..452b759 100644
--- a/astroid/tests/unittest_manager.py
+++ b/astroid/tests/unittest_manager.py
@@ -35,8 +35,9 @@ def _get_file_from_object(obj):
         return obj.__file__.split("$py.class")[0] + ".py"
     if sys.version_info > (3, 0):
         return obj.__file__
-    else:
+    if not obj.__file__.endswith(".py"):
         return obj.__file__[:-1]
+    return obj.__file__
 
 
 class AstroidManagerTest(resources.SysPathSetup,
diff --git a/astroid/tests/unittest_modutils.py b/astroid/tests/unittest_modutils.py
index 07dbebe..dffc3b8 100644
--- a/astroid/tests/unittest_modutils.py
+++ b/astroid/tests/unittest_modutils.py
@@ -176,6 +176,11 @@ class StandardLibModuleTest(resources.SysPathSetup, unittest.TestCase):
     library
     """
 
+    def test_datetime(self):
+        # This is an interesting example, since datetime, on pypy,
+        # is under lib_pypy, rather than the usual Lib directory.
+        self.assertTrue(modutils.is_standard_module('datetime'))
+
     def test_builtins(self):
         if sys.version_info < (3, 0):
             self.assertEqual(modutils.is_standard_module('__builtin__'), True)
diff --git a/astroid/tests/unittest_nodes.py b/astroid/tests/unittest_nodes.py
index d1d12e4..6fa4b6f 100644
--- a/astroid/tests/unittest_nodes.py
+++ b/astroid/tests/unittest_nodes.py
@@ -534,6 +534,7 @@ class BoundMethodNodeTest(unittest.TestCase):
             pass
         def lazyproperty():
             pass
+        def lazy(): pass
         class A(object):
             @property
             def builtin_property(self):
@@ -550,6 +551,8 @@ class BoundMethodNodeTest(unittest.TestCase):
             @lazyproperty
             def lazyprop(self): return 42
             def not_prop(self): pass
+            @lazy
+            def decorated_with_lazy(self): return 42
 
         cls = A()
         builtin_property = cls.builtin_property
@@ -559,9 +562,10 @@ class BoundMethodNodeTest(unittest.TestCase):
         not_prop = cls.not_prop
         lazy_prop = cls.lazy_prop
         lazyprop = cls.lazyprop
+        decorated_with_lazy = cls.decorated_with_lazy
         ''')
         for prop in ('builtin_property', 'abc_property', 'cached_p', 'reified',
-                     'lazy_prop', 'lazyprop'):
+                     'lazy_prop', 'lazyprop', 'decorated_with_lazy'):
             inferred = next(ast[prop].infer())
             self.assertIsInstance(inferred, nodes.Const, prop)
             self.assertEqual(inferred.value, 42, prop)
diff --git a/astroid/tests/unittest_protocols.py b/astroid/tests/unittest_protocols.py
index 9ba4f6a..1674512 100644
--- a/astroid/tests/unittest_protocols.py
+++ b/astroid/tests/unittest_protocols.py
@@ -16,8 +16,10 @@
 # You should have received a copy of the GNU Lesser General Public License along
 # with astroid. If not, see <http://www.gnu.org/licenses/>.
 
+import contextlib
 import unittest
 
+import astroid
 from astroid.test_utils import extract_node, require_version
 from astroid import InferenceError
 from astroid import nodes
@@ -25,6 +27,15 @@ from astroid import util
 from astroid.node_classes import AssignName, Const, Name, Starred
 
 
+ at contextlib.contextmanager
+def _add_transform(manager, node, transform, predicate=None):
+    manager.register_transform(node, transform, predicate)
+    try:
+        yield
+    finally:
+        manager.unregister_transform(node, transform, predicate)
+
+
 class ProtocolTests(unittest.TestCase):
 
     def assertConstNodesEqual(self, nodes_list_expected, nodes_list_got):
@@ -149,6 +160,17 @@ class ProtocolTests(unittest.TestCase):
         assigned = list(simple_mul_assnode_2.assigned_stmts())
         self.assertNameNodesEqual(['c'], assigned)
 
+    def test_sequence_assigned_stmts_not_accepting_empty_node(self):
+        def transform(node):
+            node.root().locals['__all__'] = [node.value]
+
+        manager = astroid.MANAGER
+        with _add_transform(manager, astroid.Assign, transform):
+            module = astroid.parse('''
+            __all__ = ['a']
+            ''')
+            module.wildcard_import_names()
+
 
 if __name__ == '__main__':
     unittest.main()
diff --git a/astroid/tests/unittest_regrtest.py b/astroid/tests/unittest_regrtest.py
index 3e22152..181c60c 100644
--- a/astroid/tests/unittest_regrtest.py
+++ b/astroid/tests/unittest_regrtest.py
@@ -282,6 +282,23 @@ def test():
         ''')
         self.assertRaises(exceptions.InferenceError, next, node.infer())
 
+    def test_unicode_in_docstring(self):
+        # Crashed for astroid==1.4.1
+        # Test for https://bitbucket.org/logilab/astroid/issues/273/
+
+        # In a regular file, "coding: utf-8" would have been used.
+        node = extract_node(u'''
+        from __future__ import unicode_literals
+
+        class MyClass(object):
+            def method(self):
+                "With unicode : %s "
+
+        instance = MyClass()
+        ''' % u"\u2019")
+
+        next(node.value.infer()).as_string()
+
 
 class Whatever(object):
     a = property(lambda x: x, lambda x: x)
diff --git a/astroid/tests/unittest_scoped_nodes.py b/astroid/tests/unittest_scoped_nodes.py
index 470a53d..9a7c99a 100644
--- a/astroid/tests/unittest_scoped_nodes.py
+++ b/astroid/tests/unittest_scoped_nodes.py
@@ -1203,6 +1203,41 @@ class ClassNodeTest(ModuleLoader, unittest.TestCase):
             module['OldStyle'].slots()
         self.assertEqual(str(cm.exception), msg)
 
+    def test_slots_empty_list_of_slots(self):
+        module = builder.parse("""
+        class Klass(object):
+            __slots__ = ()
+        """)
+        cls = module['Klass']
+        self.assertEqual(cls.slots(), [])
+
+    def test_slots_taken_from_parents(self):
+        module = builder.parse('''
+        class FirstParent(object):
+            __slots__ = ('a', 'b', 'c')
+        class SecondParent(FirstParent):
+            __slots__ = ('d', 'e')
+        class Third(SecondParent):
+            __slots__ = ('d', )
+        ''')
+        cls = module['Third']
+        slots = cls.slots()
+        self.assertEqual(sorted(set(slot.value for slot in slots)),
+                         ['a', 'b', 'c', 'd', 'e'])
+
+    def test_all_ancestors_need_slots(self):
+        module = builder.parse('''
+        class A(object):
+            __slots__ = ('a', )
+        class B(A): pass
+        class C(B):
+            __slots__ = ('a', )
+        ''')
+        cls = module['C']
+        self.assertIsNone(cls.slots())
+        cls = module['B']
+        self.assertIsNone(cls.slots())
+
     def assertEqualMro(self, klass, expected_mro):
         self.assertEqual(
             [member.name for member in klass.mro()],
diff --git a/setup.cfg b/setup.cfg
index 3115f15..caf8563 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -2,7 +2,7 @@
 universal = 1
 
 [egg_info]
+tag_date = 0
 tag_svn_revision = 0
 tag_build = 
-tag_date = 0
 
diff --git a/setup.py b/setup.py
index e03d643..2150d1c 100644
--- a/setup.py
+++ b/setup.py
@@ -20,14 +20,18 @@
 """Setup script for astroid."""
 import os
 from setuptools import setup, find_packages
+from setuptools.command import easy_install
 from setuptools.command import install_lib
 
-pkginfo = 'astroid/__pkginfo__.py'
+
+real_path = os.path.realpath(__file__)
+astroid_dir = os.path.dirname(real_path)
+pkginfo = os.path.join(astroid_dir, 'astroid', '__pkginfo__.py')
 
 with open(pkginfo, 'rb') as fobj:
     exec(compile(fobj.read(), pkginfo, 'exec'), locals())
 
-with open('README') as fobj:
+with open(os.path.join(astroid_dir, 'README.rst')) as fobj:
     long_description = fobj.read()
 
 class AstroidInstallLib(install_lib.install_lib):
@@ -37,6 +41,15 @@ class AstroidInstallLib(install_lib.install_lib):
         install_lib.install_lib.byte_compile(self, files)
 
 
+class AstroidEasyInstallLib(easy_install.easy_install):
+    # override this since pip/easy_install attempt to byte compile
+    # test data files, some of them being syntactically wrong by design,
+    # and this scares the end-user
+    def byte_compile(self, files):
+        test_datadir = os.path.join('astroid', 'tests', 'testdata')
+        files = [f for f in files if test_datadir not in f]
+        easy_install.easy_install.byte_compile(self, files)
+
 
 def install():
     return setup(name = distname,
@@ -51,7 +64,8 @@ def install():
                  include_package_data = True,
                  install_requires = install_requires,
                  packages = find_packages(),
-                 cmdclass={'install_lib': AstroidInstallLib}
+                 cmdclass={'install_lib': AstroidInstallLib,
+                           'easy_install': AstroidEasyInstallLib}
                  )
 
 
diff --git a/tox.ini b/tox.ini
index 93cfb64..d1a6be4 100644
--- a/tox.ini
+++ b/tox.ini
@@ -3,9 +3,6 @@ envlist = py27, py33, py34, py35, pypy, jython, pylint
 skip_missing_interpreters = true
 
 [testenv:pylint]
-deps =
-  hg+https://bitbucket.org/logilab/astroid@1.4.0
-  hg+https://bitbucket.org/logilab/pylint@1.5.0
 commands = pylint -rn --rcfile={toxinidir}/pylintrc {envsitepackagesdir}/astroid
 
 [testenv]
@@ -19,5 +16,5 @@ deps =
   py27,py33,pypy,jython: singledispatch
   six
   wrapt
-  pylint: hg+https://bitbucket.org/logilab/pylint
+  pylint: git+https://github.com/pycqa/pylint@1.5.0
 commands = python -m unittest discover -s {envsitepackagesdir}/astroid/tests -p "unittest*.py"

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/astroid.git



More information about the Python-modules-commits mailing list