Commits

Stephen Tu committed d44d132

make this shit compile

Comments (0)

Files changed (1)

pypy/interpreter/astcompiler/codegen.py

     }
 
     # methods on str objects
-    _StrObjFuncs = set([
+    _StrObjFuncs = [
       'captialize', 'center', 'count', 'decode', 'encode', 'endswith',
       'expandtabs', 'find', 'format', 'index', 'isalnum' 'isalpha', 'isdigit',
       'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower',
       'lstrip', 'partition', 'replace' 'rfind', 'rindex', 'rjust',
       'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith',
       'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill',
-    ])
+    ]
 
     # methods on list objects
-    _ListObjFuncs = set([
+    _ListObjFuncs = [
       'append', 'extend', 'count', 'index', 'insert', 'pop', 'remove',
       'reverse', 'sort',
-    ])
+    ]
 
     # methods on set objects
-    _SetObjFuncs = set([
+    _SetObjFuncs = [
       'isdisjoint', 'issubset', 'issuperset', 'union', 'intersection',
       'difference', 'symmetric_difference', 'copy', 'update',
       'intersection_update', 'difference_update',
       'symmetric_difference_update', 'add', 'remove', 'discard', 'pop',
       'clear',
-    ])
+    ]
 
     # methods on dict objects
-    _DictObjFuncs = set([
+    _DictObjFuncs = [
       'clear', 'copy', 'fromkeys', 'get', 'has_key', 'items', 'iteritems',
       'iterkeys', 'itervalues', 'keys', 'pop', 'popitem', 'setdefault',
       'update', 'values', 'viewitems', 'viewkeys', 'viewvalues',
-    ])
+    ]
 
     # methods on file objects
-    _FileObjFuncs = set([
+    _FileObjFuncs = [
       'close', 'flush', 'fileno', 'isatty', 'next', 'read', 'readlines',
       'seek', 'tell', 'truncate', 'write', 'writelines',
-    ])
+    ]
 
     def __init__(self, symbols, module):
         self.symbols = symbols
         suffix is guaranteed to never be empty
         '''
 
+        assert name
+
         r_suffix = ''
         i = len(name) - 1
         while i >= 0:
     def visit_Call(self, node):
         # check builtin arg
         dfunc = self._unravel_instr_sequence(node.func)
-        #self._break_if_file_matches('foobar.py')
-        if node.args and dfunc:
-            name = dfunc
-            try:
-                argmask = self._BuiltinsTrackArgs[name]
-                for idx in range(len(node.args)):
-                    arg = node.args[idx]
-                    if not ((1 << idx) & argmask):
-                        continue
-                    self._record_binary_feature(arg, 'used_as_builtin_%s_arg%d' % (name, idx))
-            except KeyError:
-                pass
-        dname_prefix, dname_func = self._split_last_dotted_name(dfunc)
-        if dname_prefix:
-            if (dname_func in self._StrObjFuncs) or \
-               (dname_func in self._ListObjFuncs) or \
-               (dname_func in self._SetObjFuncs) or \
-               (dname_func in self._DictObjFuncs) or \
-               (dname_func in self._FileObjFuncs):
-                 self._record_binary_feature_by_name(
-                     dname_prefix, 'method_%s_called' % (dname_func))
+        if dfunc:
+            if node.args:
+                name = dfunc
+                try:
+                    argmask = self._BuiltinsTrackArgs[name]
+                    for idx in range(len(node.args)):
+                        arg = node.args[idx]
+                        if not ((1 << idx) & argmask):
+                            continue
+                        self._record_binary_feature(arg, 'used_as_builtin_%s_arg%d' % (name, idx))
+                except KeyError:
+                    pass
+            dname_prefix, dname_func = self._split_last_dotted_name(dfunc)
+            if dname_prefix:
+                if (dname_func in self._StrObjFuncs) or \
+                   (dname_func in self._ListObjFuncs) or \
+                   (dname_func in self._SetObjFuncs) or \
+                   (dname_func in self._DictObjFuncs) or \
+                   (dname_func in self._FileObjFuncs):
+                     self._record_binary_feature_by_name(
+                         dname_prefix, 'method_%s_called' % (dname_func))
 
         self._record_binary_feature(node.func, 'used_as_callable')
         ast.GenericASTVisitor.visit_Call(self, node)