Amaury Forgeot d'Arc avatar Amaury Forgeot d'Arc committed 3a915c3

Finally remove all __slots__ and fix translation

Comments (0)

Files changed (2)

pypy/interpreter/astcompiler/ast.py

 
     __metaclass__ = extendabletype
 
-    def __init__(self):
-        self.w_dict = None
-
     def walkabout(self, visitor):
         raise AssertionError("walkabout() implementation not provided")
 
 
 
 class mod(AST):
-
-    __slots__ = ()
+    pass
 
 class Module(mod):
 
-    __slots__ = ('body', 'w_body')
-
 
     def __init__(self, body):
         self.body = body
 
 class Interactive(mod):
 
-    __slots__ = ('body', 'w_body')
-
 
     def __init__(self, body):
         self.body = body
 
 class Expression(mod):
 
-    __slots__ = ('body')
-
 
     def __init__(self, body):
         self.body = body
 
 class Suite(mod):
 
-    __slots__ = ('body', 'w_body')
-
 
     def __init__(self, body):
         self.body = body
 
 
 class stmt(AST):
-
-    __slots__ = ('lineno', 'col_offset')
-
     def __init__(self, lineno, col_offset):
-        AST.__init__(self)
         self.lineno = lineno
         self.col_offset = col_offset
 
 class FunctionDef(stmt):
 
-    __slots__ = ('name', 'args', 'body', 'w_body', 'decorator_list', 'w_decorator_list')
-
     _lineno_mask = 16
     _col_offset_mask = 32
 
 
 class ClassDef(stmt):
 
-    __slots__ = ('name', 'bases', 'w_bases', 'body', 'w_body', 'decorator_list', 'w_decorator_list')
-
     _lineno_mask = 16
     _col_offset_mask = 32
 
 
 class Return(stmt):
 
-    __slots__ = ('value')
-
     _lineno_mask = 2
     _col_offset_mask = 4
 
 
 class Delete(stmt):
 
-    __slots__ = ('targets', 'w_targets')
-
     _lineno_mask = 2
     _col_offset_mask = 4
 
 
 class Assign(stmt):
 
-    __slots__ = ('targets', 'w_targets', 'value')
-
     _lineno_mask = 4
     _col_offset_mask = 8
 
 
 class AugAssign(stmt):
 
-    __slots__ = ('target', 'op', 'value')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class Print(stmt):
 
-    __slots__ = ('dest', 'values', 'w_values', 'nl')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class For(stmt):
 
-    __slots__ = ('target', 'iter', 'body', 'w_body', 'orelse', 'w_orelse')
-
     _lineno_mask = 16
     _col_offset_mask = 32
 
 
 class While(stmt):
 
-    __slots__ = ('test', 'body', 'w_body', 'orelse', 'w_orelse')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class If(stmt):
 
-    __slots__ = ('test', 'body', 'w_body', 'orelse', 'w_orelse')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class With(stmt):
 
-    __slots__ = ('context_expr', 'optional_vars', 'body', 'w_body')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class Raise(stmt):
 
-    __slots__ = ('type', 'inst', 'tback')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class TryExcept(stmt):
 
-    __slots__ = ('body', 'w_body', 'handlers', 'w_handlers', 'orelse', 'w_orelse')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class TryFinally(stmt):
 
-    __slots__ = ('body', 'w_body', 'finalbody', 'w_finalbody')
-
     _lineno_mask = 4
     _col_offset_mask = 8
 
 
 class Assert(stmt):
 
-    __slots__ = ('test', 'msg')
-
     _lineno_mask = 4
     _col_offset_mask = 8
 
 
 class Import(stmt):
 
-    __slots__ = ('names', 'w_names')
-
     _lineno_mask = 2
     _col_offset_mask = 4
 
 
 class ImportFrom(stmt):
 
-    __slots__ = ('module', 'names', 'w_names', 'level')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class Exec(stmt):
 
-    __slots__ = ('body', 'globals', 'locals')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class Global(stmt):
 
-    __slots__ = ('names', 'w_names')
-
     _lineno_mask = 2
     _col_offset_mask = 4
 
 
 class Expr(stmt):
 
-    __slots__ = ('value')
-
     _lineno_mask = 2
     _col_offset_mask = 4
 
 
 class Pass(stmt):
 
-    __slots__ = ()
-
     _lineno_mask = 1
     _col_offset_mask = 2
 
 
 class Break(stmt):
 
-    __slots__ = ()
-
     _lineno_mask = 1
     _col_offset_mask = 2
 
 
 class Continue(stmt):
 
-    __slots__ = ()
-
     _lineno_mask = 1
     _col_offset_mask = 2
 
 
 
 class expr(AST):
-
-    __slots__ = ('lineno', 'col_offset')
-
     def __init__(self, lineno, col_offset):
-        AST.__init__(self)
         self.lineno = lineno
         self.col_offset = col_offset
 
 class BoolOp(expr):
 
-    __slots__ = ('op', 'values', 'w_values')
-
     _lineno_mask = 4
     _col_offset_mask = 8
 
 
 class BinOp(expr):
 
-    __slots__ = ('left', 'op', 'right')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class UnaryOp(expr):
 
-    __slots__ = ('op', 'operand')
-
     _lineno_mask = 4
     _col_offset_mask = 8
 
 
 class Lambda(expr):
 
-    __slots__ = ('args', 'body')
-
     _lineno_mask = 4
     _col_offset_mask = 8
 
 
 class IfExp(expr):
 
-    __slots__ = ('test', 'body', 'orelse')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class Dict(expr):
 
-    __slots__ = ('keys', 'w_keys', 'values', 'w_values')
-
     _lineno_mask = 4
     _col_offset_mask = 8
 
 
 class Set(expr):
 
-    __slots__ = ('elts', 'w_elts')
-
     _lineno_mask = 2
     _col_offset_mask = 4
 
 
 class ListComp(expr):
 
-    __slots__ = ('elt', 'generators', 'w_generators')
-
     _lineno_mask = 4
     _col_offset_mask = 8
 
 
 class SetComp(expr):
 
-    __slots__ = ('elt', 'generators', 'w_generators')
-
     _lineno_mask = 4
     _col_offset_mask = 8
 
 
 class DictComp(expr):
 
-    __slots__ = ('key', 'value', 'generators', 'w_generators')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class GeneratorExp(expr):
 
-    __slots__ = ('elt', 'generators', 'w_generators')
-
     _lineno_mask = 4
     _col_offset_mask = 8
 
 
 class Yield(expr):
 
-    __slots__ = ('value')
-
     _lineno_mask = 2
     _col_offset_mask = 4
 
 
 class Compare(expr):
 
-    __slots__ = ('left', 'ops', 'w_ops', 'comparators', 'w_comparators')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class Call(expr):
 
-    __slots__ = ('func', 'args', 'w_args', 'keywords', 'w_keywords', 'starargs', 'kwargs')
-
     _lineno_mask = 32
     _col_offset_mask = 64
 
 
 class Repr(expr):
 
-    __slots__ = ('value')
-
     _lineno_mask = 2
     _col_offset_mask = 4
 
 
 class Num(expr):
 
-    __slots__ = ('n')
-
     _lineno_mask = 2
     _col_offset_mask = 4
 
 
 class Str(expr):
 
-    __slots__ = ('s')
-
     _lineno_mask = 2
     _col_offset_mask = 4
 
 
 class Attribute(expr):
 
-    __slots__ = ('value', 'attr', 'ctx')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class Subscript(expr):
 
-    __slots__ = ('value', 'slice', 'ctx')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class Name(expr):
 
-    __slots__ = ('id', 'ctx')
-
     _lineno_mask = 4
     _col_offset_mask = 8
 
 
 class List(expr):
 
-    __slots__ = ('elts', 'w_elts', 'ctx')
-
     _lineno_mask = 4
     _col_offset_mask = 8
 
 
 class Tuple(expr):
 
-    __slots__ = ('elts', 'w_elts', 'ctx')
-
     _lineno_mask = 4
     _col_offset_mask = 8
 
 
 class Const(expr):
 
-    __slots__ = ('value')
-
     _lineno_mask = 2
     _col_offset_mask = 4
 
 ]
 
 class slice(AST):
-
-    __slots__ = ()
+    pass
 
 class Ellipsis(slice):
 
-    __slots__ = ()
-
 
     def __init__(self):
-        AST.__init__(self)
         self.initialization_state = 0
 
     def walkabout(self, visitor):
 
 class Slice(slice):
 
-    __slots__ = ('lower', 'upper', 'step')
-
 
     def __init__(self, lower, upper, step):
         self.lower = lower
 
 class ExtSlice(slice):
 
-    __slots__ = ('dims', 'w_dims')
-
 
     def __init__(self, dims):
         self.dims = dims
 
 class Index(slice):
 
-    __slots__ = ('value')
-
 
     def __init__(self, value):
         self.value = value
 
 class comprehension(AST):
 
-    __slots__ = ('target', 'iter', 'ifs', 'w_ifs')
-
     def __init__(self, target, iter, ifs):
         self.target = target
         self.iter = iter
                 node.sync_app_attrs(space)
 
 class excepthandler(AST):
-
-    __slots__ = ('lineno', 'col_offset')
-
     def __init__(self, lineno, col_offset):
-        AST.__init__(self)
         self.lineno = lineno
         self.col_offset = col_offset
 
 class ExceptHandler(excepthandler):
 
-    __slots__ = ('type', 'name', 'body', 'w_body')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class arguments(AST):
 
-    __slots__ = ('args', 'w_args', 'vararg', 'kwarg', 'defaults', 'w_defaults')
-
     def __init__(self, args, vararg, kwarg, defaults):
         self.args = args
         self.w_args = None
 
 class keyword(AST):
 
-    __slots__ = ('arg', 'value')
-
     def __init__(self, arg, value):
         self.arg = arg
         self.value = value
 
 class alias(AST):
 
-    __slots__ = ('name', 'asname')
-
     def __init__(self, name, asname):
         self.name = name
         self.asname = asname

pypy/interpreter/astcompiler/tools/asdl_py.py

             self.emit("")
         else:
             self.emit("class %s(AST):" % (base,))
-            self.emit("")
-            slots = ", ".join(repr(attr.name.value) for attr in sum.attributes)
-            self.emit("__slots__ = (%s)" % (slots,), 1)
-            self.emit("")
             if sum.attributes:
                 args = ", ".join(attr.name.value for attr in sum.attributes)
                 self.emit("def __init__(self, %s):" % (args,), 1)
                 for attr in sum.attributes:
                     self.visit(attr)
                 self.emit("")
+            else:
+                self.emit("pass", 1)
+                self.emit("")
             for cons in sum.types:
                 self.visit(cons, base, sum.attributes)
                 self.emit("")
     def visitProduct(self, product, name):
         self.emit("class %s(AST):" % (name,))
         self.emit("")
-        slots = self.make_slots(product.fields)
-        self.emit("__slots__ = (%s)" % (slots,), 1)
-        self.emit("")
         self.make_constructor(product.fields, product)
         self.emit("")
         self.make_mutate_over(product, name)
         self.emit("")
         self.make_var_syncer(product.fields, product, name)
 
-    def make_slots(self, fields):
-        slots = []
-        for field in fields:
-            name = repr(field.name.value)
-            slots.append(name)
-            if field.seq:
-                slots.append("'w_%s'" % (field.name,))
-        return ", ".join(slots)
-
     def make_var_syncer(self, fields, node, name):
         self.emit("def sync_app_attrs(self, space):", 1)
         config = (self.data.optional_masks[node],
     def visitConstructor(self, cons, base, extra_attributes):
         self.emit("class %s(%s):" % (cons.name, base))
         self.emit("")
-        slots = self.make_slots(cons.fields)
-        self.emit("__slots__ = (%s)" % (slots,), 1)
-        self.emit("")
         for field in self.data.cons_attributes[cons]:
             subst = (field.name, self.data.field_masks[field])
             self.emit("_%s_mask = %i" % subst, 1)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.