diff options
| author | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-01-03 23:38:45 +0200 |
|---|---|---|
| committer | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-01-03 23:38:45 +0200 |
| commit | d5ab86bbe2baf4a07d0f3fc00a8b6389ffd6d2d2 (patch) | |
| tree | 58fe9197d22601d6382ff1486ee14fa9aa1a6ba0 | |
| parent | 6f6e5f5b85a0f61b985d4d6b4116baceb5dbe2bb (diff) | |
| download | astroid-git-d5ab86bbe2baf4a07d0f3fc00a8b6389ffd6d2d2.tar.gz | |
.slots() can contain unicode strings on Python 2.
| -rw-r--r-- | ChangeLog | 2 | ||||
| -rw-r--r-- | astroid/scoped_nodes.py | 3 | ||||
| -rw-r--r-- | astroid/tests/unittest_scoped_nodes.py | 12 |
3 files changed, 16 insertions, 1 deletions
@@ -30,6 +30,8 @@ Change log for the astroid package (used to be astng) * Improve the detection for functions decorated with decorators which returns static or class methods. + * .slots() can contain unicode strings on Python 2. + 2014-11-22 -- 1.3.2 diff --git a/astroid/scoped_nodes.py b/astroid/scoped_nodes.py index 898361dd..372cd9c2 100644 --- a/astroid/scoped_nodes.py +++ b/astroid/scoped_nodes.py @@ -1366,7 +1366,8 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin): if infered is YES: continue if (not isinstance(infered, Const) or - not isinstance(infered.value, str)): + not isinstance(infered.value, + six.string_types)): continue if not infered.value: continue diff --git a/astroid/tests/unittest_scoped_nodes.py b/astroid/tests/unittest_scoped_nodes.py index c01adae2..9b622130 100644 --- a/astroid/tests/unittest_scoped_nodes.py +++ b/astroid/tests/unittest_scoped_nodes.py @@ -1084,6 +1084,18 @@ class ClassNodeTest(ModuleLoader, unittest.TestCase): [slot.value for slot in tenth_slots], ["a", "c"]) + @test_utils.require_version(maxver='3.0') + def test_slots_py2(self): + module = test_utils.build_module(""" + class UnicodeSlots(object): + __slots__ = (u"a", u"b", "c") + """) + slots = module['UnicodeSlots'].slots() + self.assertEqual(len(slots), 3) + self.assertEqual(slots[0].value, "a") + self.assertEqual(slots[1].value, "b") + self.assertEqual(slots[2].value, "c") + def assertEqualMro(self, klass, expected_mro): self.assertEqual( [member.name for member in klass.mro()], |
