diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-08-20 02:06:00 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-08-20 02:06:00 (GMT) |
commit | 9f9fc68b0fb279e5774d56bcee932d66d02ba369 (patch) | |
tree | 952a299913581e04125ff62b83ae8966bf60f456 /Lib | |
parent | 87069fd8fe8fae7409f313bd02faa65e9110ef66 (diff) | |
download | cpython-9f9fc68b0fb279e5774d56bcee932d66d02ba369.zip cpython-9f9fc68b0fb279e5774d56bcee932d66d02ba369.tar.gz cpython-9f9fc68b0fb279e5774d56bcee932d66d02ba369.tar.bz2 |
return sets instead of tuples from some symtable methods
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/symtable.py | 6 | ||||
-rw-r--r-- | Lib/test/test_symtable.py | 10 |
2 files changed, 8 insertions, 8 deletions
diff --git a/Lib/symtable.py b/Lib/symtable.py index 3d1775b..ac9396c 100644 --- a/Lib/symtable.py +++ b/Lib/symtable.py @@ -129,8 +129,8 @@ class Function(SymbolTable): __globals = None def __idents_matching(self, test_func): - return tuple([ident for ident in self.get_identifiers() - if test_func(self._table.symbols[ident])]) + return frozenset(ident for ident in self.get_identifiers() + if test_func(self._table.symbols[ident])) def get_parameters(self): if self.__params is None: @@ -165,7 +165,7 @@ class Class(SymbolTable): d = {} for st in self._table.children: d[st.name] = 1 - self.__methods = tuple(d) + self.__methods = frozenset(d) return self.__methods diff --git a/Lib/test/test_symtable.py b/Lib/test/test_symtable.py index 7e0206d..712eca7 100644 --- a/Lib/test/test_symtable.py +++ b/Lib/test/test_symtable.py @@ -80,11 +80,11 @@ class SymtableTest(unittest.TestCase): def test_function_info(self): func = self.spam - self.assertEqual(func.get_parameters(), ("a", "b", "kw", "var")) + self.assertEqual(func.get_parameters(), {"a", "b", "kw", "var"}) self.assertEqual(func.get_locals(), - ("a", "b", "bar", "glob", "internal", "kw", "var", "x")) - self.assertEqual(func.get_globals(), ("bar", "glob")) - self.assertEqual(self.internal.get_frees(), ("x",)) + {"a", "b", "bar", "glob", "internal", "kw", "var", "x"}) + self.assertEqual(func.get_globals(), {"bar", "glob"}) + self.assertEqual(self.internal.get_frees(), {"x"}) def test_globals(self): self.assertTrue(self.spam.lookup("glob").is_global()) @@ -142,7 +142,7 @@ class SymtableTest(unittest.TestCase): self.assertEqual(self.Mine.get_name(), "Mine") def test_class_info(self): - self.assertEqual(self.Mine.get_methods(), ('a_method',)) + self.assertEqual(self.Mine.get_methods(), {'a_method'}) def test_filename_correct(self): ### Bug tickler: SyntaxError file name correct whether error raised |