[pypy-commit] pypy win64-stage1: Merge with default (2 mon ago)
ctismer
noreply at buildbot.pypy.org
Mon Mar 12 23:56:29 CET 2012
Author: Christian Tismer <tismer at stackless.com>
Branch: win64-stage1
Changeset: r53374:95992789fca7
Date: 2012-03-12 15:55 -0700
http://bitbucket.org/pypy/pypy/changeset/95992789fca7/
Log: Merge with default (2 mon ago)
diff --git a/pypy/interpreter/astcompiler/ast.py b/pypy/interpreter/astcompiler/ast.py
--- a/pypy/interpreter/astcompiler/ast.py
+++ b/pypy/interpreter/astcompiler/ast.py
@@ -51,6 +51,24 @@
space.setattr(self, w_name,
space.getitem(w_state, w_name))
+ def missing_field(self, space, required, host):
+ "Find which required field is missing."
+ state = self.initialization_state
+ for i in range(len(required)):
+ if (state >> i) & 1:
+ continue # field is present
+ missing = required[i]
+ if missing is None:
+ continue # field is optional
+ w_obj = self.getdictvalue(space, missing)
+ if w_obj is None:
+ err = "required field \"%s\" missing from %s"
+ raise operationerrfmt(space.w_TypeError, err, missing, host)
+ else:
+ err = "incorrect type for field \"%s\" in %s"
+ raise operationerrfmt(space.w_TypeError, err, missing, host)
+ raise AssertionError("should not reach here")
+
class NodeVisitorNotImplemented(Exception):
pass
@@ -94,17 +112,6 @@
)
-def missing_field(space, state, required, host):
- "Find which required field is missing."
- for i in range(len(required)):
- if not (state >> i) & 1:
- missing = required[i]
- if missing is not None:
- err = "required field \"%s\" missing from %s"
- err = err % (missing, host)
- w_err = space.wrap(err)
- raise OperationError(space.w_TypeError, w_err)
- raise AssertionError("should not reach here")
class mod(AST):
@@ -112,7 +119,6 @@
class Module(mod):
-
def __init__(self, body):
self.body = body
self.w_body = None
@@ -128,7 +134,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 1:
- missing_field(space, self.initialization_state, ['body'], 'Module')
+ self.missing_field(space, ['body'], 'Module')
else:
pass
w_list = self.w_body
@@ -145,7 +151,6 @@
class Interactive(mod):
-
def __init__(self, body):
self.body = body
self.w_body = None
@@ -161,7 +166,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 1:
- missing_field(space, self.initialization_state, ['body'], 'Interactive')
+ self.missing_field(space, ['body'], 'Interactive')
else:
pass
w_list = self.w_body
@@ -178,7 +183,6 @@
class Expression(mod):
-
def __init__(self, body):
self.body = body
self.initialization_state = 1
@@ -192,7 +196,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 1:
- missing_field(space, self.initialization_state, ['body'], 'Expression')
+ self.missing_field(space, ['body'], 'Expression')
else:
pass
self.body.sync_app_attrs(space)
@@ -200,7 +204,6 @@
class Suite(mod):
-
def __init__(self, body):
self.body = body
self.w_body = None
@@ -216,7 +219,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 1:
- missing_field(space, self.initialization_state, ['body'], 'Suite')
+ self.missing_field(space, ['body'], 'Suite')
else:
pass
w_list = self.w_body
@@ -232,15 +235,13 @@
class stmt(AST):
+
def __init__(self, lineno, col_offset):
self.lineno = lineno
self.col_offset = col_offset
class FunctionDef(stmt):
- _lineno_mask = 16
- _col_offset_mask = 32
-
def __init__(self, name, args, body, decorator_list, lineno, col_offset):
self.name = name
self.args = args
@@ -264,7 +265,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 63:
- missing_field(space, self.initialization_state, ['name', 'args', 'body', 'decorator_list', 'lineno', 'col_offset'], 'FunctionDef')
+ self.missing_field(space, ['lineno', 'col_offset', 'name', 'args', 'body', 'decorator_list'], 'FunctionDef')
else:
pass
self.args.sync_app_attrs(space)
@@ -292,9 +293,6 @@
class ClassDef(stmt):
- _lineno_mask = 16
- _col_offset_mask = 32
-
def __init__(self, name, bases, body, decorator_list, lineno, col_offset):
self.name = name
self.bases = bases
@@ -320,7 +318,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 63:
- missing_field(space, self.initialization_state, ['name', 'bases', 'body', 'decorator_list', 'lineno', 'col_offset'], 'ClassDef')
+ self.missing_field(space, ['lineno', 'col_offset', 'name', 'bases', 'body', 'decorator_list'], 'ClassDef')
else:
pass
w_list = self.w_bases
@@ -357,9 +355,6 @@
class Return(stmt):
- _lineno_mask = 2
- _col_offset_mask = 4
-
def __init__(self, value, lineno, col_offset):
self.value = value
stmt.__init__(self, lineno, col_offset)
@@ -374,10 +369,10 @@
return visitor.visit_Return(self)
def sync_app_attrs(self, space):
- if (self.initialization_state & ~1) ^ 6:
- missing_field(space, self.initialization_state, [None, 'lineno', 'col_offset'], 'Return')
+ if (self.initialization_state & ~4) ^ 3:
+ self.missing_field(space, ['lineno', 'col_offset', None], 'Return')
else:
- if not self.initialization_state & 1:
+ if not self.initialization_state & 4:
self.value = None
if self.value:
self.value.sync_app_attrs(space)
@@ -385,9 +380,6 @@
class Delete(stmt):
- _lineno_mask = 2
- _col_offset_mask = 4
-
def __init__(self, targets, lineno, col_offset):
self.targets = targets
self.w_targets = None
@@ -404,7 +396,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 7:
- missing_field(space, self.initialization_state, ['targets', 'lineno', 'col_offset'], 'Delete')
+ self.missing_field(space, ['lineno', 'col_offset', 'targets'], 'Delete')
else:
pass
w_list = self.w_targets
@@ -421,9 +413,6 @@
class Assign(stmt):
- _lineno_mask = 4
- _col_offset_mask = 8
-
def __init__(self, targets, value, lineno, col_offset):
self.targets = targets
self.w_targets = None
@@ -442,7 +431,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 15:
- missing_field(space, self.initialization_state, ['targets', 'value', 'lineno', 'col_offset'], 'Assign')
+ self.missing_field(space, ['lineno', 'col_offset', 'targets', 'value'], 'Assign')
else:
pass
w_list = self.w_targets
@@ -460,9 +449,6 @@
class AugAssign(stmt):
- _lineno_mask = 8
- _col_offset_mask = 16
-
def __init__(self, target, op, value, lineno, col_offset):
self.target = target
self.op = op
@@ -480,7 +466,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 31:
- missing_field(space, self.initialization_state, ['target', 'op', 'value', 'lineno', 'col_offset'], 'AugAssign')
+ self.missing_field(space, ['lineno', 'col_offset', 'target', 'op', 'value'], 'AugAssign')
else:
pass
self.target.sync_app_attrs(space)
@@ -489,9 +475,6 @@
class Print(stmt):
- _lineno_mask = 8
- _col_offset_mask = 16
-
def __init__(self, dest, values, nl, lineno, col_offset):
self.dest = dest
self.values = values
@@ -511,10 +494,10 @@
return visitor.visit_Print(self)
def sync_app_attrs(self, space):
- if (self.initialization_state & ~1) ^ 30:
- missing_field(space, self.initialization_state, [None, 'values', 'nl', 'lineno', 'col_offset'], 'Print')
+ if (self.initialization_state & ~4) ^ 27:
+ self.missing_field(space, ['lineno', 'col_offset', None, 'values', 'nl'], 'Print')
else:
- if not self.initialization_state & 1:
+ if not self.initialization_state & 4:
self.dest = None
if self.dest:
self.dest.sync_app_attrs(space)
@@ -532,9 +515,6 @@
class For(stmt):
- _lineno_mask = 16
- _col_offset_mask = 32
-
def __init__(self, target, iter, body, orelse, lineno, col_offset):
self.target = target
self.iter = iter
@@ -559,7 +539,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 63:
- missing_field(space, self.initialization_state, ['target', 'iter', 'body', 'orelse', 'lineno', 'col_offset'], 'For')
+ self.missing_field(space, ['lineno', 'col_offset', 'target', 'iter', 'body', 'orelse'], 'For')
else:
pass
self.target.sync_app_attrs(space)
@@ -588,9 +568,6 @@
class While(stmt):
- _lineno_mask = 8
- _col_offset_mask = 16
-
def __init__(self, test, body, orelse, lineno, col_offset):
self.test = test
self.body = body
@@ -613,7 +590,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 31:
- missing_field(space, self.initialization_state, ['test', 'body', 'orelse', 'lineno', 'col_offset'], 'While')
+ self.missing_field(space, ['lineno', 'col_offset', 'test', 'body', 'orelse'], 'While')
else:
pass
self.test.sync_app_attrs(space)
@@ -641,9 +618,6 @@
class If(stmt):
- _lineno_mask = 8
- _col_offset_mask = 16
-
def __init__(self, test, body, orelse, lineno, col_offset):
self.test = test
self.body = body
@@ -666,7 +640,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 31:
- missing_field(space, self.initialization_state, ['test', 'body', 'orelse', 'lineno', 'col_offset'], 'If')
+ self.missing_field(space, ['lineno', 'col_offset', 'test', 'body', 'orelse'], 'If')
else:
pass
self.test.sync_app_attrs(space)
@@ -694,9 +668,6 @@
class With(stmt):
- _lineno_mask = 8
- _col_offset_mask = 16
-
def __init__(self, context_expr, optional_vars, body, lineno, col_offset):
self.context_expr = context_expr
self.optional_vars = optional_vars
@@ -717,10 +688,10 @@
return visitor.visit_With(self)
def sync_app_attrs(self, space):
- if (self.initialization_state & ~2) ^ 29:
- missing_field(space, self.initialization_state, ['context_expr', None, 'body', 'lineno', 'col_offset'], 'With')
+ if (self.initialization_state & ~8) ^ 23:
+ self.missing_field(space, ['lineno', 'col_offset', 'context_expr', None, 'body'], 'With')
else:
- if not self.initialization_state & 2:
+ if not self.initialization_state & 8:
self.optional_vars = None
self.context_expr.sync_app_attrs(space)
if self.optional_vars:
@@ -739,9 +710,6 @@
class Raise(stmt):
- _lineno_mask = 8
- _col_offset_mask = 16
-
def __init__(self, type, inst, tback, lineno, col_offset):
self.type = type
self.inst = inst
@@ -762,14 +730,14 @@
return visitor.visit_Raise(self)
def sync_app_attrs(self, space):
- if (self.initialization_state & ~7) ^ 24:
- missing_field(space, self.initialization_state, [None, None, None, 'lineno', 'col_offset'], 'Raise')
+ if (self.initialization_state & ~28) ^ 3:
+ self.missing_field(space, ['lineno', 'col_offset', None, None, None], 'Raise')
else:
- if not self.initialization_state & 1:
+ if not self.initialization_state & 4:
self.type = None
- if not self.initialization_state & 2:
+ if not self.initialization_state & 8:
self.inst = None
- if not self.initialization_state & 4:
+ if not self.initialization_state & 16:
self.tback = None
if self.type:
self.type.sync_app_attrs(space)
@@ -781,9 +749,6 @@
class TryExcept(stmt):
- _lineno_mask = 8
- _col_offset_mask = 16
-
def __init__(self, body, handlers, orelse, lineno, col_offset):
self.body = body
self.w_body = None
@@ -808,7 +773,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 31:
- missing_field(space, self.initialization_state, ['body', 'handlers', 'orelse', 'lineno', 'col_offset'], 'TryExcept')
+ self.missing_field(space, ['lineno', 'col_offset', 'body', 'handlers', 'orelse'], 'TryExcept')
else:
pass
w_list = self.w_body
@@ -845,9 +810,6 @@
class TryFinally(stmt):
- _lineno_mask = 4
- _col_offset_mask = 8
-
def __init__(self, body, finalbody, lineno, col_offset):
self.body = body
self.w_body = None
@@ -868,7 +830,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 15:
- missing_field(space, self.initialization_state, ['body', 'finalbody', 'lineno', 'col_offset'], 'TryFinally')
+ self.missing_field(space, ['lineno', 'col_offset', 'body', 'finalbody'], 'TryFinally')
else:
pass
w_list = self.w_body
@@ -895,9 +857,6 @@
class Assert(stmt):
- _lineno_mask = 4
- _col_offset_mask = 8
-
def __init__(self, test, msg, lineno, col_offset):
self.test = test
self.msg = msg
@@ -914,10 +873,10 @@
return visitor.visit_Assert(self)
def sync_app_attrs(self, space):
- if (self.initialization_state & ~2) ^ 13:
- missing_field(space, self.initialization_state, ['test', None, 'lineno', 'col_offset'], 'Assert')
+ if (self.initialization_state & ~8) ^ 7:
+ self.missing_field(space, ['lineno', 'col_offset', 'test', None], 'Assert')
else:
- if not self.initialization_state & 2:
+ if not self.initialization_state & 8:
self.msg = None
self.test.sync_app_attrs(space)
if self.msg:
@@ -926,9 +885,6 @@
class Import(stmt):
- _lineno_mask = 2
- _col_offset_mask = 4
-
def __init__(self, names, lineno, col_offset):
self.names = names
self.w_names = None
@@ -945,7 +901,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 7:
- missing_field(space, self.initialization_state, ['names', 'lineno', 'col_offset'], 'Import')
+ self.missing_field(space, ['lineno', 'col_offset', 'names'], 'Import')
else:
pass
w_list = self.w_names
@@ -962,9 +918,6 @@
class ImportFrom(stmt):
- _lineno_mask = 8
- _col_offset_mask = 16
-
def __init__(self, module, names, level, lineno, col_offset):
self.module = module
self.names = names
@@ -982,12 +935,12 @@
return visitor.visit_ImportFrom(self)
def sync_app_attrs(self, space):
- if (self.initialization_state & ~5) ^ 26:
- missing_field(space, self.initialization_state, [None, 'names', None, 'lineno', 'col_offset'], 'ImportFrom')
+ if (self.initialization_state & ~20) ^ 11:
+ self.missing_field(space, ['lineno', 'col_offset', None, 'names', None], 'ImportFrom')
else:
- if not self.initialization_state & 1:
+ if not self.initialization_state & 4:
self.module = None
- if not self.initialization_state & 4:
+ if not self.initialization_state & 16:
self.level = 0
w_list = self.w_names
if w_list is not None:
@@ -1003,9 +956,6 @@
class Exec(stmt):
- _lineno_mask = 8
- _col_offset_mask = 16
-
def __init__(self, body, globals, locals, lineno, col_offset):
self.body = body
self.globals = globals
@@ -1025,12 +975,12 @@
return visitor.visit_Exec(self)
def sync_app_attrs(self, space):
- if (self.initialization_state & ~6) ^ 25:
- missing_field(space, self.initialization_state, ['body', None, None, 'lineno', 'col_offset'], 'Exec')
+ if (self.initialization_state & ~24) ^ 7:
+ self.missing_field(space, ['lineno', 'col_offset', 'body', None, None], 'Exec')
else:
- if not self.initialization_state & 2:
+ if not self.initialization_state & 8:
self.globals = None
- if not self.initialization_state & 4:
+ if not self.initialization_state & 16:
self.locals = None
self.body.sync_app_attrs(space)
if self.globals:
@@ -1041,9 +991,6 @@
class Global(stmt):
- _lineno_mask = 2
- _col_offset_mask = 4
-
def __init__(self, names, lineno, col_offset):
self.names = names
self.w_names = None
@@ -1058,7 +1005,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 7:
- missing_field(space, self.initialization_state, ['names', 'lineno', 'col_offset'], 'Global')
+ self.missing_field(space, ['lineno', 'col_offset', 'names'], 'Global')
else:
pass
w_list = self.w_names
@@ -1072,9 +1019,6 @@
class Expr(stmt):
- _lineno_mask = 2
- _col_offset_mask = 4
-
def __init__(self, value, lineno, col_offset):
self.value = value
stmt.__init__(self, lineno, col_offset)
@@ -1089,7 +1033,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 7:
- missing_field(space, self.initialization_state, ['value', 'lineno', 'col_offset'], 'Expr')
+ self.missing_field(space, ['lineno', 'col_offset', 'value'], 'Expr')
else:
pass
self.value.sync_app_attrs(space)
@@ -1097,9 +1041,6 @@
class Pass(stmt):
- _lineno_mask = 1
- _col_offset_mask = 2
-
def __init__(self, lineno, col_offset):
stmt.__init__(self, lineno, col_offset)
self.initialization_state = 3
@@ -1112,16 +1053,13 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 3:
- missing_field(space, self.initialization_state, ['lineno', 'col_offset'], 'Pass')
+ self.missing_field(space, ['lineno', 'col_offset'], 'Pass')
else:
pass
class Break(stmt):
- _lineno_mask = 1
- _col_offset_mask = 2
-
def __init__(self, lineno, col_offset):
stmt.__init__(self, lineno, col_offset)
self.initialization_state = 3
@@ -1134,16 +1072,13 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 3:
- missing_field(space, self.initialization_state, ['lineno', 'col_offset'], 'Break')
+ self.missing_field(space, ['lineno', 'col_offset'], 'Break')
else:
pass
class Continue(stmt):
- _lineno_mask = 1
- _col_offset_mask = 2
-
def __init__(self, lineno, col_offset):
stmt.__init__(self, lineno, col_offset)
self.initialization_state = 3
@@ -1156,21 +1091,19 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 3:
- missing_field(space, self.initialization_state, ['lineno', 'col_offset'], 'Continue')
+ self.missing_field(space, ['lineno', 'col_offset'], 'Continue')
else:
pass
class expr(AST):
+
def __init__(self, lineno, col_offset):
self.lineno = lineno
self.col_offset = col_offset
class BoolOp(expr):
- _lineno_mask = 4
- _col_offset_mask = 8
-
def __init__(self, op, values, lineno, col_offset):
self.op = op
self.values = values
@@ -1188,7 +1121,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 15:
- missing_field(space, self.initialization_state, ['op', 'values', 'lineno', 'col_offset'], 'BoolOp')
+ self.missing_field(space, ['lineno', 'col_offset', 'op', 'values'], 'BoolOp')
else:
pass
w_list = self.w_values
@@ -1205,9 +1138,6 @@
class BinOp(expr):
- _lineno_mask = 8
- _col_offset_mask = 16
-
def __init__(self, left, op, right, lineno, col_offset):
self.left = left
self.op = op
@@ -1225,7 +1155,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 31:
- missing_field(space, self.initialization_state, ['left', 'op', 'right', 'lineno', 'col_offset'], 'BinOp')
+ self.missing_field(space, ['lineno', 'col_offset', 'left', 'op', 'right'], 'BinOp')
else:
pass
self.left.sync_app_attrs(space)
@@ -1234,9 +1164,6 @@
class UnaryOp(expr):
- _lineno_mask = 4
- _col_offset_mask = 8
-
def __init__(self, op, operand, lineno, col_offset):
self.op = op
self.operand = operand
@@ -1252,7 +1179,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 15:
- missing_field(space, self.initialization_state, ['op', 'operand', 'lineno', 'col_offset'], 'UnaryOp')
+ self.missing_field(space, ['lineno', 'col_offset', 'op', 'operand'], 'UnaryOp')
else:
pass
self.operand.sync_app_attrs(space)
@@ -1260,9 +1187,6 @@
class Lambda(expr):
- _lineno_mask = 4
- _col_offset_mask = 8
-
def __init__(self, args, body, lineno, col_offset):
self.args = args
self.body = body
@@ -1279,7 +1203,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 15:
- missing_field(space, self.initialization_state, ['args', 'body', 'lineno', 'col_offset'], 'Lambda')
+ self.missing_field(space, ['lineno', 'col_offset', 'args', 'body'], 'Lambda')
else:
pass
self.args.sync_app_attrs(space)
@@ -1288,9 +1212,6 @@
class IfExp(expr):
- _lineno_mask = 8
- _col_offset_mask = 16
-
def __init__(self, test, body, orelse, lineno, col_offset):
self.test = test
self.body = body
@@ -1309,7 +1230,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 31:
- missing_field(space, self.initialization_state, ['test', 'body', 'orelse', 'lineno', 'col_offset'], 'IfExp')
+ self.missing_field(space, ['lineno', 'col_offset', 'test', 'body', 'orelse'], 'IfExp')
else:
pass
self.test.sync_app_attrs(space)
@@ -1319,9 +1240,6 @@
class Dict(expr):
- _lineno_mask = 4
- _col_offset_mask = 8
-
def __init__(self, keys, values, lineno, col_offset):
self.keys = keys
self.w_keys = None
@@ -1342,7 +1260,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 15:
- missing_field(space, self.initialization_state, ['keys', 'values', 'lineno', 'col_offset'], 'Dict')
+ self.missing_field(space, ['lineno', 'col_offset', 'keys', 'values'], 'Dict')
else:
pass
w_list = self.w_keys
@@ -1369,9 +1287,6 @@
class Set(expr):
- _lineno_mask = 2
- _col_offset_mask = 4
-
def __init__(self, elts, lineno, col_offset):
self.elts = elts
self.w_elts = None
@@ -1388,7 +1303,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 7:
- missing_field(space, self.initialization_state, ['elts', 'lineno', 'col_offset'], 'Set')
+ self.missing_field(space, ['lineno', 'col_offset', 'elts'], 'Set')
else:
pass
w_list = self.w_elts
@@ -1405,9 +1320,6 @@
class ListComp(expr):
- _lineno_mask = 4
- _col_offset_mask = 8
-
def __init__(self, elt, generators, lineno, col_offset):
self.elt = elt
self.generators = generators
@@ -1426,7 +1338,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 15:
- missing_field(space, self.initialization_state, ['elt', 'generators', 'lineno', 'col_offset'], 'ListComp')
+ self.missing_field(space, ['lineno', 'col_offset', 'elt', 'generators'], 'ListComp')
else:
pass
self.elt.sync_app_attrs(space)
@@ -1444,9 +1356,6 @@
class SetComp(expr):
- _lineno_mask = 4
- _col_offset_mask = 8
-
def __init__(self, elt, generators, lineno, col_offset):
self.elt = elt
self.generators = generators
@@ -1465,7 +1374,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 15:
- missing_field(space, self.initialization_state, ['elt', 'generators', 'lineno', 'col_offset'], 'SetComp')
+ self.missing_field(space, ['lineno', 'col_offset', 'elt', 'generators'], 'SetComp')
else:
pass
self.elt.sync_app_attrs(space)
@@ -1483,9 +1392,6 @@
class DictComp(expr):
- _lineno_mask = 8
- _col_offset_mask = 16
-
def __init__(self, key, value, generators, lineno, col_offset):
self.key = key
self.value = value
@@ -1506,7 +1412,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 31:
- missing_field(space, self.initialization_state, ['key', 'value', 'generators', 'lineno', 'col_offset'], 'DictComp')
+ self.missing_field(space, ['lineno', 'col_offset', 'key', 'value', 'generators'], 'DictComp')
else:
pass
self.key.sync_app_attrs(space)
@@ -1525,9 +1431,6 @@
class GeneratorExp(expr):
- _lineno_mask = 4
- _col_offset_mask = 8
-
def __init__(self, elt, generators, lineno, col_offset):
self.elt = elt
self.generators = generators
@@ -1546,7 +1449,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 15:
- missing_field(space, self.initialization_state, ['elt', 'generators', 'lineno', 'col_offset'], 'GeneratorExp')
+ self.missing_field(space, ['lineno', 'col_offset', 'elt', 'generators'], 'GeneratorExp')
else:
pass
self.elt.sync_app_attrs(space)
@@ -1564,9 +1467,6 @@
class Yield(expr):
- _lineno_mask = 2
- _col_offset_mask = 4
-
def __init__(self, value, lineno, col_offset):
self.value = value
expr.__init__(self, lineno, col_offset)
@@ -1581,10 +1481,10 @@
return visitor.visit_Yield(self)
def sync_app_attrs(self, space):
- if (self.initialization_state & ~1) ^ 6:
- missing_field(space, self.initialization_state, [None, 'lineno', 'col_offset'], 'Yield')
+ if (self.initialization_state & ~4) ^ 3:
+ self.missing_field(space, ['lineno', 'col_offset', None], 'Yield')
else:
- if not self.initialization_state & 1:
+ if not self.initialization_state & 4:
self.value = None
if self.value:
self.value.sync_app_attrs(space)
@@ -1592,9 +1492,6 @@
class Compare(expr):
- _lineno_mask = 8
- _col_offset_mask = 16
-
def __init__(self, left, ops, comparators, lineno, col_offset):
self.left = left
self.ops = ops
@@ -1615,7 +1512,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 31:
- missing_field(space, self.initialization_state, ['left', 'ops', 'comparators', 'lineno', 'col_offset'], 'Compare')
+ self.missing_field(space, ['lineno', 'col_offset', 'left', 'ops', 'comparators'], 'Compare')
else:
pass
self.left.sync_app_attrs(space)
@@ -1640,9 +1537,6 @@
class Call(expr):
- _lineno_mask = 32
- _col_offset_mask = 64
-
def __init__(self, func, args, keywords, starargs, kwargs, lineno, col_offset):
self.func = func
self.args = args
@@ -1670,12 +1564,12 @@
return visitor.visit_Call(self)
def sync_app_attrs(self, space):
- if (self.initialization_state & ~24) ^ 103:
- missing_field(space, self.initialization_state, ['func', 'args', 'keywords', None, None, 'lineno', 'col_offset'], 'Call')
+ if (self.initialization_state & ~96) ^ 31:
+ self.missing_field(space, ['lineno', 'col_offset', 'func', 'args', 'keywords', None, None], 'Call')
else:
- if not self.initialization_state & 8:
+ if not self.initialization_state & 32:
self.starargs = None
- if not self.initialization_state & 16:
+ if not self.initialization_state & 64:
self.kwargs = None
self.func.sync_app_attrs(space)
w_list = self.w_args
@@ -1706,9 +1600,6 @@
class Repr(expr):
- _lineno_mask = 2
- _col_offset_mask = 4
-
def __init__(self, value, lineno, col_offset):
self.value = value
expr.__init__(self, lineno, col_offset)
@@ -1723,7 +1614,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 7:
- missing_field(space, self.initialization_state, ['value', 'lineno', 'col_offset'], 'Repr')
+ self.missing_field(space, ['lineno', 'col_offset', 'value'], 'Repr')
else:
pass
self.value.sync_app_attrs(space)
@@ -1731,9 +1622,6 @@
class Num(expr):
- _lineno_mask = 2
- _col_offset_mask = 4
-
def __init__(self, n, lineno, col_offset):
self.n = n
expr.__init__(self, lineno, col_offset)
@@ -1747,16 +1635,13 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 7:
- missing_field(space, self.initialization_state, ['n', 'lineno', 'col_offset'], 'Num')
+ self.missing_field(space, ['lineno', 'col_offset', 'n'], 'Num')
else:
pass
class Str(expr):
- _lineno_mask = 2
- _col_offset_mask = 4
-
def __init__(self, s, lineno, col_offset):
self.s = s
expr.__init__(self, lineno, col_offset)
@@ -1770,16 +1655,13 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 7:
- missing_field(space, self.initialization_state, ['s', 'lineno', 'col_offset'], 'Str')
+ self.missing_field(space, ['lineno', 'col_offset', 's'], 'Str')
else:
pass
class Attribute(expr):
- _lineno_mask = 8
- _col_offset_mask = 16
-
def __init__(self, value, attr, ctx, lineno, col_offset):
self.value = value
self.attr = attr
@@ -1796,7 +1678,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 31:
- missing_field(space, self.initialization_state, ['value', 'attr', 'ctx', 'lineno', 'col_offset'], 'Attribute')
+ self.missing_field(space, ['lineno', 'col_offset', 'value', 'attr', 'ctx'], 'Attribute')
else:
pass
self.value.sync_app_attrs(space)
@@ -1804,9 +1686,6 @@
class Subscript(expr):
- _lineno_mask = 8
- _col_offset_mask = 16
-
def __init__(self, value, slice, ctx, lineno, col_offset):
self.value = value
self.slice = slice
@@ -1824,7 +1703,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 31:
- missing_field(space, self.initialization_state, ['value', 'slice', 'ctx', 'lineno', 'col_offset'], 'Subscript')
+ self.missing_field(space, ['lineno', 'col_offset', 'value', 'slice', 'ctx'], 'Subscript')
else:
pass
self.value.sync_app_attrs(space)
@@ -1833,9 +1712,6 @@
class Name(expr):
- _lineno_mask = 4
- _col_offset_mask = 8
-
def __init__(self, id, ctx, lineno, col_offset):
self.id = id
self.ctx = ctx
@@ -1850,16 +1726,13 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 15:
- missing_field(space, self.initialization_state, ['id', 'ctx', 'lineno', 'col_offset'], 'Name')
+ self.missing_field(space, ['lineno', 'col_offset', 'id', 'ctx'], 'Name')
else:
pass
class List(expr):
- _lineno_mask = 4
- _col_offset_mask = 8
-
def __init__(self, elts, ctx, lineno, col_offset):
self.elts = elts
self.w_elts = None
@@ -1877,7 +1750,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 15:
- missing_field(space, self.initialization_state, ['elts', 'ctx', 'lineno', 'col_offset'], 'List')
+ self.missing_field(space, ['lineno', 'col_offset', 'elts', 'ctx'], 'List')
else:
pass
w_list = self.w_elts
@@ -1894,9 +1767,6 @@
class Tuple(expr):
- _lineno_mask = 4
- _col_offset_mask = 8
-
def __init__(self, elts, ctx, lineno, col_offset):
self.elts = elts
self.w_elts = None
@@ -1914,7 +1784,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 15:
- missing_field(space, self.initialization_state, ['elts', 'ctx', 'lineno', 'col_offset'], 'Tuple')
+ self.missing_field(space, ['lineno', 'col_offset', 'elts', 'ctx'], 'Tuple')
else:
pass
w_list = self.w_elts
@@ -1931,9 +1801,6 @@
class Const(expr):
- _lineno_mask = 2
- _col_offset_mask = 4
-
def __init__(self, value, lineno, col_offset):
self.value = value
expr.__init__(self, lineno, col_offset)
@@ -1947,7 +1814,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 7:
- missing_field(space, self.initialization_state, ['value', 'lineno', 'col_offset'], 'Const')
+ self.missing_field(space, ['lineno', 'col_offset', 'value'], 'Const')
else:
pass
@@ -2009,7 +1876,6 @@
class Ellipsis(slice):
-
def __init__(self):
self.initialization_state = 0
@@ -2021,14 +1887,13 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 0:
- missing_field(space, self.initialization_state, [], 'Ellipsis')
+ self.missing_field(space, [], 'Ellipsis')
else:
pass
class Slice(slice):
-
def __init__(self, lower, upper, step):
self.lower = lower
self.upper = upper
@@ -2049,7 +1914,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~7) ^ 0:
- missing_field(space, self.initialization_state, [None, None, None], 'Slice')
+ self.missing_field(space, [None, None, None], 'Slice')
else:
if not self.initialization_state & 1:
self.lower = None
@@ -2067,7 +1932,6 @@
class ExtSlice(slice):
-
def __init__(self, dims):
self.dims = dims
self.w_dims = None
@@ -2083,7 +1947,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 1:
- missing_field(space, self.initialization_state, ['dims'], 'ExtSlice')
+ self.missing_field(space, ['dims'], 'ExtSlice')
else:
pass
w_list = self.w_dims
@@ -2100,7 +1964,6 @@
class Index(slice):
-
def __init__(self, value):
self.value = value
self.initialization_state = 1
@@ -2114,7 +1977,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 1:
- missing_field(space, self.initialization_state, ['value'], 'Index')
+ self.missing_field(space, ['value'], 'Index')
else:
pass
self.value.sync_app_attrs(space)
@@ -2377,7 +2240,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 7:
- missing_field(space, self.initialization_state, ['target', 'iter', 'ifs'], 'comprehension')
+ self.missing_field(space, ['target', 'iter', 'ifs'], 'comprehension')
else:
pass
self.target.sync_app_attrs(space)
@@ -2394,15 +2257,13 @@
node.sync_app_attrs(space)
class excepthandler(AST):
+
def __init__(self, lineno, col_offset):
self.lineno = lineno
self.col_offset = col_offset
class ExceptHandler(excepthandler):
- _lineno_mask = 8
- _col_offset_mask = 16
-
def __init__(self, type, name, body, lineno, col_offset):
self.type = type
self.name = name
@@ -2424,12 +2285,12 @@
return visitor.visit_ExceptHandler(self)
def sync_app_attrs(self, space):
- if (self.initialization_state & ~3) ^ 28:
- missing_field(space, self.initialization_state, [None, None, 'body', 'lineno', 'col_offset'], 'ExceptHandler')
+ if (self.initialization_state & ~12) ^ 19:
+ self.missing_field(space, ['lineno', 'col_offset', None, None, 'body'], 'ExceptHandler')
else:
- if not self.initialization_state & 1:
+ if not self.initialization_state & 4:
self.type = None
- if not self.initialization_state & 2:
+ if not self.initialization_state & 8:
self.name = None
if self.type:
self.type.sync_app_attrs(space)
@@ -2470,7 +2331,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~6) ^ 9:
- missing_field(space, self.initialization_state, ['args', None, None, 'defaults'], 'arguments')
+ self.missing_field(space, ['args', None, None, 'defaults'], 'arguments')
else:
if not self.initialization_state & 2:
self.vararg = None
@@ -2513,7 +2374,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~0) ^ 3:
- missing_field(space, self.initialization_state, ['arg', 'value'], 'keyword')
+ self.missing_field(space, ['arg', 'value'], 'keyword')
else:
pass
self.value.sync_app_attrs(space)
@@ -2533,7 +2394,7 @@
def sync_app_attrs(self, space):
if (self.initialization_state & ~2) ^ 1:
- missing_field(space, self.initialization_state, ['name', None], 'alias')
+ self.missing_field(space, ['name', None], 'alias')
else:
if not self.initialization_state & 2:
self.asname = None
@@ -3019,6 +2880,8 @@
def Expression_set_body(space, w_self, w_new_value):
try:
w_self.body = space.interp_w(expr, w_new_value, False)
+ if type(w_self.body) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
@@ -3098,7 +2961,7 @@
w_obj = w_self.getdictvalue(space, 'lineno')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & w_self._lineno_mask:
+ if not w_self.initialization_state & 1:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'lineno')
return space.wrap(w_self.lineno)
@@ -3112,14 +2975,14 @@
w_self.setdictvalue(space, 'lineno', w_new_value)
return
w_self.deldictvalue(space, 'lineno')
- w_self.initialization_state |= w_self._lineno_mask
+ w_self.initialization_state |= 1
def stmt_get_col_offset(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'col_offset')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & w_self._col_offset_mask:
+ if not w_self.initialization_state & 2:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'col_offset')
return space.wrap(w_self.col_offset)
@@ -3133,7 +2996,7 @@
w_self.setdictvalue(space, 'col_offset', w_new_value)
return
w_self.deldictvalue(space, 'col_offset')
- w_self.initialization_state |= w_self._col_offset_mask
+ w_self.initialization_state |= 2
stmt.typedef = typedef.TypeDef("stmt",
AST.typedef,
@@ -3149,7 +3012,7 @@
w_obj = w_self.getdictvalue(space, 'name')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'name')
return space.wrap(w_self.name)
@@ -3163,14 +3026,14 @@
w_self.setdictvalue(space, 'name', w_new_value)
return
w_self.deldictvalue(space, 'name')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def FunctionDef_get_args(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'args')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'args')
return space.wrap(w_self.args)
@@ -3184,10 +3047,10 @@
w_self.setdictvalue(space, 'args', w_new_value)
return
w_self.deldictvalue(space, 'args')
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
def FunctionDef_get_body(space, w_self):
- if not w_self.initialization_state & 4:
+ if not w_self.initialization_state & 16:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
if w_self.w_body is None:
@@ -3201,10 +3064,10 @@
def FunctionDef_set_body(space, w_self, w_new_value):
w_self.w_body = w_new_value
- w_self.initialization_state |= 4
+ w_self.initialization_state |= 16
def FunctionDef_get_decorator_list(space, w_self):
- if not w_self.initialization_state & 8:
+ if not w_self.initialization_state & 32:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'decorator_list')
if w_self.w_decorator_list is None:
@@ -3218,7 +3081,7 @@
def FunctionDef_set_decorator_list(space, w_self, w_new_value):
w_self.w_decorator_list = w_new_value
- w_self.initialization_state |= 8
+ w_self.initialization_state |= 32
_FunctionDef_field_unroller = unrolling_iterable(['name', 'args', 'body', 'decorator_list'])
def FunctionDef_init(space, w_self, __args__):
@@ -3254,7 +3117,7 @@
w_obj = w_self.getdictvalue(space, 'name')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'name')
return space.wrap(w_self.name)
@@ -3268,10 +3131,10 @@
w_self.setdictvalue(space, 'name', w_new_value)
return
w_self.deldictvalue(space, 'name')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def ClassDef_get_bases(space, w_self):
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'bases')
if w_self.w_bases is None:
@@ -3285,10 +3148,10 @@
def ClassDef_set_bases(space, w_self, w_new_value):
w_self.w_bases = w_new_value
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
def ClassDef_get_body(space, w_self):
- if not w_self.initialization_state & 4:
+ if not w_self.initialization_state & 16:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
if w_self.w_body is None:
@@ -3302,10 +3165,10 @@
def ClassDef_set_body(space, w_self, w_new_value):
w_self.w_body = w_new_value
- w_self.initialization_state |= 4
+ w_self.initialization_state |= 16
def ClassDef_get_decorator_list(space, w_self):
- if not w_self.initialization_state & 8:
+ if not w_self.initialization_state & 32:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'decorator_list')
if w_self.w_decorator_list is None:
@@ -3319,7 +3182,7 @@
def ClassDef_set_decorator_list(space, w_self, w_new_value):
w_self.w_decorator_list = w_new_value
- w_self.initialization_state |= 8
+ w_self.initialization_state |= 32
_ClassDef_field_unroller = unrolling_iterable(['name', 'bases', 'body', 'decorator_list'])
def ClassDef_init(space, w_self, __args__):
@@ -3356,7 +3219,7 @@
w_obj = w_self.getdictvalue(space, 'value')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
return space.wrap(w_self.value)
@@ -3364,13 +3227,15 @@
def Return_set_value(space, w_self, w_new_value):
try:
w_self.value = space.interp_w(expr, w_new_value, True)
+ if type(w_self.value) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'value', w_new_value)
return
w_self.deldictvalue(space, 'value')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
_Return_field_unroller = unrolling_iterable(['value'])
def Return_init(space, w_self, __args__):
@@ -3397,7 +3262,7 @@
)
def Delete_get_targets(space, w_self):
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'targets')
if w_self.w_targets is None:
@@ -3411,7 +3276,7 @@
def Delete_set_targets(space, w_self, w_new_value):
w_self.w_targets = w_new_value
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
_Delete_field_unroller = unrolling_iterable(['targets'])
def Delete_init(space, w_self, __args__):
@@ -3439,7 +3304,7 @@
)
def Assign_get_targets(space, w_self):
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'targets')
if w_self.w_targets is None:
@@ -3453,14 +3318,14 @@
def Assign_set_targets(space, w_self, w_new_value):
w_self.w_targets = w_new_value
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def Assign_get_value(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'value')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
return space.wrap(w_self.value)
@@ -3468,13 +3333,15 @@
def Assign_set_value(space, w_self, w_new_value):
try:
w_self.value = space.interp_w(expr, w_new_value, False)
+ if type(w_self.value) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'value', w_new_value)
return
w_self.deldictvalue(space, 'value')
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
_Assign_field_unroller = unrolling_iterable(['targets', 'value'])
def Assign_init(space, w_self, __args__):
@@ -3507,7 +3374,7 @@
w_obj = w_self.getdictvalue(space, 'target')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'target')
return space.wrap(w_self.target)
@@ -3515,20 +3382,22 @@
def AugAssign_set_target(space, w_self, w_new_value):
try:
w_self.target = space.interp_w(expr, w_new_value, False)
+ if type(w_self.target) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'target', w_new_value)
return
w_self.deldictvalue(space, 'target')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def AugAssign_get_op(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'op')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'op')
return operator_to_class[w_self.op - 1]()
@@ -3544,14 +3413,14 @@
return
# need to save the original object too
w_self.setdictvalue(space, 'op', w_new_value)
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
def AugAssign_get_value(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'value')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 4:
+ if not w_self.initialization_state & 16:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
return space.wrap(w_self.value)
@@ -3559,13 +3428,15 @@
def AugAssign_set_value(space, w_self, w_new_value):
try:
w_self.value = space.interp_w(expr, w_new_value, False)
+ if type(w_self.value) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'value', w_new_value)
return
w_self.deldictvalue(space, 'value')
- w_self.initialization_state |= 4
+ w_self.initialization_state |= 16
_AugAssign_field_unroller = unrolling_iterable(['target', 'op', 'value'])
def AugAssign_init(space, w_self, __args__):
@@ -3598,7 +3469,7 @@
w_obj = w_self.getdictvalue(space, 'dest')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'dest')
return space.wrap(w_self.dest)
@@ -3606,16 +3477,18 @@
def Print_set_dest(space, w_self, w_new_value):
try:
w_self.dest = space.interp_w(expr, w_new_value, True)
+ if type(w_self.dest) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'dest', w_new_value)
return
w_self.deldictvalue(space, 'dest')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def Print_get_values(space, w_self):
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'values')
if w_self.w_values is None:
@@ -3629,14 +3502,14 @@
def Print_set_values(space, w_self, w_new_value):
w_self.w_values = w_new_value
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
def Print_get_nl(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'nl')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 4:
+ if not w_self.initialization_state & 16:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'nl')
return space.wrap(w_self.nl)
@@ -3650,7 +3523,7 @@
w_self.setdictvalue(space, 'nl', w_new_value)
return
w_self.deldictvalue(space, 'nl')
- w_self.initialization_state |= 4
+ w_self.initialization_state |= 16
_Print_field_unroller = unrolling_iterable(['dest', 'values', 'nl'])
def Print_init(space, w_self, __args__):
@@ -3684,7 +3557,7 @@
w_obj = w_self.getdictvalue(space, 'target')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'target')
return space.wrap(w_self.target)
@@ -3692,20 +3565,22 @@
def For_set_target(space, w_self, w_new_value):
try:
w_self.target = space.interp_w(expr, w_new_value, False)
+ if type(w_self.target) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'target', w_new_value)
return
w_self.deldictvalue(space, 'target')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def For_get_iter(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'iter')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'iter')
return space.wrap(w_self.iter)
@@ -3713,16 +3588,18 @@
def For_set_iter(space, w_self, w_new_value):
try:
w_self.iter = space.interp_w(expr, w_new_value, False)
+ if type(w_self.iter) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'iter', w_new_value)
return
w_self.deldictvalue(space, 'iter')
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
def For_get_body(space, w_self):
- if not w_self.initialization_state & 4:
+ if not w_self.initialization_state & 16:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
if w_self.w_body is None:
@@ -3736,10 +3613,10 @@
def For_set_body(space, w_self, w_new_value):
w_self.w_body = w_new_value
- w_self.initialization_state |= 4
+ w_self.initialization_state |= 16
def For_get_orelse(space, w_self):
- if not w_self.initialization_state & 8:
+ if not w_self.initialization_state & 32:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'orelse')
if w_self.w_orelse is None:
@@ -3753,7 +3630,7 @@
def For_set_orelse(space, w_self, w_new_value):
w_self.w_orelse = w_new_value
- w_self.initialization_state |= 8
+ w_self.initialization_state |= 32
_For_field_unroller = unrolling_iterable(['target', 'iter', 'body', 'orelse'])
def For_init(space, w_self, __args__):
@@ -3789,7 +3666,7 @@
w_obj = w_self.getdictvalue(space, 'test')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'test')
return space.wrap(w_self.test)
@@ -3797,16 +3674,18 @@
def While_set_test(space, w_self, w_new_value):
try:
w_self.test = space.interp_w(expr, w_new_value, False)
+ if type(w_self.test) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'test', w_new_value)
return
w_self.deldictvalue(space, 'test')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def While_get_body(space, w_self):
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
if w_self.w_body is None:
@@ -3820,10 +3699,10 @@
def While_set_body(space, w_self, w_new_value):
w_self.w_body = w_new_value
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
def While_get_orelse(space, w_self):
- if not w_self.initialization_state & 4:
+ if not w_self.initialization_state & 16:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'orelse')
if w_self.w_orelse is None:
@@ -3837,7 +3716,7 @@
def While_set_orelse(space, w_self, w_new_value):
w_self.w_orelse = w_new_value
- w_self.initialization_state |= 4
+ w_self.initialization_state |= 16
_While_field_unroller = unrolling_iterable(['test', 'body', 'orelse'])
def While_init(space, w_self, __args__):
@@ -3872,7 +3751,7 @@
w_obj = w_self.getdictvalue(space, 'test')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'test')
return space.wrap(w_self.test)
@@ -3880,16 +3759,18 @@
def If_set_test(space, w_self, w_new_value):
try:
w_self.test = space.interp_w(expr, w_new_value, False)
+ if type(w_self.test) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'test', w_new_value)
return
w_self.deldictvalue(space, 'test')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def If_get_body(space, w_self):
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
if w_self.w_body is None:
@@ -3903,10 +3784,10 @@
def If_set_body(space, w_self, w_new_value):
w_self.w_body = w_new_value
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
def If_get_orelse(space, w_self):
- if not w_self.initialization_state & 4:
+ if not w_self.initialization_state & 16:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'orelse')
if w_self.w_orelse is None:
@@ -3920,7 +3801,7 @@
def If_set_orelse(space, w_self, w_new_value):
w_self.w_orelse = w_new_value
- w_self.initialization_state |= 4
+ w_self.initialization_state |= 16
_If_field_unroller = unrolling_iterable(['test', 'body', 'orelse'])
def If_init(space, w_self, __args__):
@@ -3955,7 +3836,7 @@
w_obj = w_self.getdictvalue(space, 'context_expr')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'context_expr')
return space.wrap(w_self.context_expr)
@@ -3963,20 +3844,22 @@
def With_set_context_expr(space, w_self, w_new_value):
try:
w_self.context_expr = space.interp_w(expr, w_new_value, False)
+ if type(w_self.context_expr) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'context_expr', w_new_value)
return
w_self.deldictvalue(space, 'context_expr')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def With_get_optional_vars(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'optional_vars')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'optional_vars')
return space.wrap(w_self.optional_vars)
@@ -3984,16 +3867,18 @@
def With_set_optional_vars(space, w_self, w_new_value):
try:
w_self.optional_vars = space.interp_w(expr, w_new_value, True)
+ if type(w_self.optional_vars) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'optional_vars', w_new_value)
return
w_self.deldictvalue(space, 'optional_vars')
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
def With_get_body(space, w_self):
- if not w_self.initialization_state & 4:
+ if not w_self.initialization_state & 16:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
if w_self.w_body is None:
@@ -4007,7 +3892,7 @@
def With_set_body(space, w_self, w_new_value):
w_self.w_body = w_new_value
- w_self.initialization_state |= 4
+ w_self.initialization_state |= 16
_With_field_unroller = unrolling_iterable(['context_expr', 'optional_vars', 'body'])
def With_init(space, w_self, __args__):
@@ -4041,7 +3926,7 @@
w_obj = w_self.getdictvalue(space, 'type')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'type')
return space.wrap(w_self.type)
@@ -4049,20 +3934,22 @@
def Raise_set_type(space, w_self, w_new_value):
try:
w_self.type = space.interp_w(expr, w_new_value, True)
+ if type(w_self.type) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'type', w_new_value)
return
w_self.deldictvalue(space, 'type')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def Raise_get_inst(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'inst')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'inst')
return space.wrap(w_self.inst)
@@ -4070,20 +3957,22 @@
def Raise_set_inst(space, w_self, w_new_value):
try:
w_self.inst = space.interp_w(expr, w_new_value, True)
+ if type(w_self.inst) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'inst', w_new_value)
return
w_self.deldictvalue(space, 'inst')
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
def Raise_get_tback(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'tback')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 4:
+ if not w_self.initialization_state & 16:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'tback')
return space.wrap(w_self.tback)
@@ -4091,13 +3980,15 @@
def Raise_set_tback(space, w_self, w_new_value):
try:
w_self.tback = space.interp_w(expr, w_new_value, True)
+ if type(w_self.tback) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'tback', w_new_value)
return
w_self.deldictvalue(space, 'tback')
- w_self.initialization_state |= 4
+ w_self.initialization_state |= 16
_Raise_field_unroller = unrolling_iterable(['type', 'inst', 'tback'])
def Raise_init(space, w_self, __args__):
@@ -4126,7 +4017,7 @@
)
def TryExcept_get_body(space, w_self):
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
if w_self.w_body is None:
@@ -4140,10 +4031,10 @@
def TryExcept_set_body(space, w_self, w_new_value):
w_self.w_body = w_new_value
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def TryExcept_get_handlers(space, w_self):
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'handlers')
if w_self.w_handlers is None:
@@ -4157,10 +4048,10 @@
def TryExcept_set_handlers(space, w_self, w_new_value):
w_self.w_handlers = w_new_value
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
def TryExcept_get_orelse(space, w_self):
- if not w_self.initialization_state & 4:
+ if not w_self.initialization_state & 16:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'orelse')
if w_self.w_orelse is None:
@@ -4174,7 +4065,7 @@
def TryExcept_set_orelse(space, w_self, w_new_value):
w_self.w_orelse = w_new_value
- w_self.initialization_state |= 4
+ w_self.initialization_state |= 16
_TryExcept_field_unroller = unrolling_iterable(['body', 'handlers', 'orelse'])
def TryExcept_init(space, w_self, __args__):
@@ -4206,7 +4097,7 @@
)
def TryFinally_get_body(space, w_self):
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
if w_self.w_body is None:
@@ -4220,10 +4111,10 @@
def TryFinally_set_body(space, w_self, w_new_value):
w_self.w_body = w_new_value
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def TryFinally_get_finalbody(space, w_self):
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'finalbody')
if w_self.w_finalbody is None:
@@ -4237,7 +4128,7 @@
def TryFinally_set_finalbody(space, w_self, w_new_value):
w_self.w_finalbody = w_new_value
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
_TryFinally_field_unroller = unrolling_iterable(['body', 'finalbody'])
def TryFinally_init(space, w_self, __args__):
@@ -4271,7 +4162,7 @@
w_obj = w_self.getdictvalue(space, 'test')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'test')
return space.wrap(w_self.test)
@@ -4279,20 +4170,22 @@
def Assert_set_test(space, w_self, w_new_value):
try:
w_self.test = space.interp_w(expr, w_new_value, False)
+ if type(w_self.test) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'test', w_new_value)
return
w_self.deldictvalue(space, 'test')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def Assert_get_msg(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'msg')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'msg')
return space.wrap(w_self.msg)
@@ -4300,13 +4193,15 @@
def Assert_set_msg(space, w_self, w_new_value):
try:
w_self.msg = space.interp_w(expr, w_new_value, True)
+ if type(w_self.msg) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'msg', w_new_value)
return
w_self.deldictvalue(space, 'msg')
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
_Assert_field_unroller = unrolling_iterable(['test', 'msg'])
def Assert_init(space, w_self, __args__):
@@ -4334,7 +4229,7 @@
)
def Import_get_names(space, w_self):
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'names')
if w_self.w_names is None:
@@ -4348,7 +4243,7 @@
def Import_set_names(space, w_self, w_new_value):
w_self.w_names = w_new_value
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
_Import_field_unroller = unrolling_iterable(['names'])
def Import_init(space, w_self, __args__):
@@ -4380,7 +4275,7 @@
w_obj = w_self.getdictvalue(space, 'module')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'module')
return space.wrap(w_self.module)
@@ -4397,10 +4292,10 @@
w_self.setdictvalue(space, 'module', w_new_value)
return
w_self.deldictvalue(space, 'module')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def ImportFrom_get_names(space, w_self):
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'names')
if w_self.w_names is None:
@@ -4414,14 +4309,14 @@
def ImportFrom_set_names(space, w_self, w_new_value):
w_self.w_names = w_new_value
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
def ImportFrom_get_level(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'level')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 4:
+ if not w_self.initialization_state & 16:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'level')
return space.wrap(w_self.level)
@@ -4435,7 +4330,7 @@
w_self.setdictvalue(space, 'level', w_new_value)
return
w_self.deldictvalue(space, 'level')
- w_self.initialization_state |= 4
+ w_self.initialization_state |= 16
_ImportFrom_field_unroller = unrolling_iterable(['module', 'names', 'level'])
def ImportFrom_init(space, w_self, __args__):
@@ -4469,7 +4364,7 @@
w_obj = w_self.getdictvalue(space, 'body')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
return space.wrap(w_self.body)
@@ -4477,20 +4372,22 @@
def Exec_set_body(space, w_self, w_new_value):
try:
w_self.body = space.interp_w(expr, w_new_value, False)
+ if type(w_self.body) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'body', w_new_value)
return
w_self.deldictvalue(space, 'body')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def Exec_get_globals(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'globals')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'globals')
return space.wrap(w_self.globals)
@@ -4498,20 +4395,22 @@
def Exec_set_globals(space, w_self, w_new_value):
try:
w_self.globals = space.interp_w(expr, w_new_value, True)
+ if type(w_self.globals) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'globals', w_new_value)
return
w_self.deldictvalue(space, 'globals')
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
def Exec_get_locals(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'locals')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 4:
+ if not w_self.initialization_state & 16:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'locals')
return space.wrap(w_self.locals)
@@ -4519,13 +4418,15 @@
def Exec_set_locals(space, w_self, w_new_value):
try:
w_self.locals = space.interp_w(expr, w_new_value, True)
+ if type(w_self.locals) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'locals', w_new_value)
return
w_self.deldictvalue(space, 'locals')
- w_self.initialization_state |= 4
+ w_self.initialization_state |= 16
_Exec_field_unroller = unrolling_iterable(['body', 'globals', 'locals'])
def Exec_init(space, w_self, __args__):
@@ -4554,7 +4455,7 @@
)
def Global_get_names(space, w_self):
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'names')
if w_self.w_names is None:
@@ -4568,7 +4469,7 @@
def Global_set_names(space, w_self, w_new_value):
w_self.w_names = w_new_value
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
_Global_field_unroller = unrolling_iterable(['names'])
def Global_init(space, w_self, __args__):
@@ -4600,7 +4501,7 @@
w_obj = w_self.getdictvalue(space, 'value')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
return space.wrap(w_self.value)
@@ -4608,13 +4509,15 @@
def Expr_set_value(space, w_self, w_new_value):
try:
w_self.value = space.interp_w(expr, w_new_value, False)
+ if type(w_self.value) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'value', w_new_value)
return
w_self.deldictvalue(space, 'value')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
_Expr_field_unroller = unrolling_iterable(['value'])
def Expr_init(space, w_self, __args__):
@@ -4696,7 +4599,7 @@
w_obj = w_self.getdictvalue(space, 'lineno')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & w_self._lineno_mask:
+ if not w_self.initialization_state & 1:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'lineno')
return space.wrap(w_self.lineno)
@@ -4710,14 +4613,14 @@
w_self.setdictvalue(space, 'lineno', w_new_value)
return
w_self.deldictvalue(space, 'lineno')
- w_self.initialization_state |= w_self._lineno_mask
+ w_self.initialization_state |= 1
def expr_get_col_offset(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'col_offset')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & w_self._col_offset_mask:
+ if not w_self.initialization_state & 2:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'col_offset')
return space.wrap(w_self.col_offset)
@@ -4731,7 +4634,7 @@
w_self.setdictvalue(space, 'col_offset', w_new_value)
return
w_self.deldictvalue(space, 'col_offset')
- w_self.initialization_state |= w_self._col_offset_mask
+ w_self.initialization_state |= 2
expr.typedef = typedef.TypeDef("expr",
AST.typedef,
@@ -4747,7 +4650,7 @@
w_obj = w_self.getdictvalue(space, 'op')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'op')
return boolop_to_class[w_self.op - 1]()
@@ -4763,10 +4666,10 @@
return
# need to save the original object too
w_self.setdictvalue(space, 'op', w_new_value)
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def BoolOp_get_values(space, w_self):
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'values')
if w_self.w_values is None:
@@ -4780,7 +4683,7 @@
def BoolOp_set_values(space, w_self, w_new_value):
w_self.w_values = w_new_value
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
_BoolOp_field_unroller = unrolling_iterable(['op', 'values'])
def BoolOp_init(space, w_self, __args__):
@@ -4813,7 +4716,7 @@
w_obj = w_self.getdictvalue(space, 'left')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'left')
return space.wrap(w_self.left)
@@ -4821,20 +4724,22 @@
def BinOp_set_left(space, w_self, w_new_value):
try:
w_self.left = space.interp_w(expr, w_new_value, False)
+ if type(w_self.left) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'left', w_new_value)
return
w_self.deldictvalue(space, 'left')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def BinOp_get_op(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'op')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'op')
return operator_to_class[w_self.op - 1]()
@@ -4850,14 +4755,14 @@
return
# need to save the original object too
w_self.setdictvalue(space, 'op', w_new_value)
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
def BinOp_get_right(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'right')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 4:
+ if not w_self.initialization_state & 16:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'right')
return space.wrap(w_self.right)
@@ -4865,13 +4770,15 @@
def BinOp_set_right(space, w_self, w_new_value):
try:
w_self.right = space.interp_w(expr, w_new_value, False)
+ if type(w_self.right) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'right', w_new_value)
return
w_self.deldictvalue(space, 'right')
- w_self.initialization_state |= 4
+ w_self.initialization_state |= 16
_BinOp_field_unroller = unrolling_iterable(['left', 'op', 'right'])
def BinOp_init(space, w_self, __args__):
@@ -4904,7 +4811,7 @@
w_obj = w_self.getdictvalue(space, 'op')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'op')
return unaryop_to_class[w_self.op - 1]()
@@ -4920,14 +4827,14 @@
return
# need to save the original object too
w_self.setdictvalue(space, 'op', w_new_value)
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def UnaryOp_get_operand(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'operand')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'operand')
return space.wrap(w_self.operand)
@@ -4935,13 +4842,15 @@
def UnaryOp_set_operand(space, w_self, w_new_value):
try:
w_self.operand = space.interp_w(expr, w_new_value, False)
+ if type(w_self.operand) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'operand', w_new_value)
return
w_self.deldictvalue(space, 'operand')
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
_UnaryOp_field_unroller = unrolling_iterable(['op', 'operand'])
def UnaryOp_init(space, w_self, __args__):
@@ -4973,7 +4882,7 @@
w_obj = w_self.getdictvalue(space, 'args')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'args')
return space.wrap(w_self.args)
@@ -4987,14 +4896,14 @@
w_self.setdictvalue(space, 'args', w_new_value)
return
w_self.deldictvalue(space, 'args')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def Lambda_get_body(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'body')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
return space.wrap(w_self.body)
@@ -5002,13 +4911,15 @@
def Lambda_set_body(space, w_self, w_new_value):
try:
w_self.body = space.interp_w(expr, w_new_value, False)
+ if type(w_self.body) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'body', w_new_value)
return
w_self.deldictvalue(space, 'body')
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
_Lambda_field_unroller = unrolling_iterable(['args', 'body'])
def Lambda_init(space, w_self, __args__):
@@ -5040,7 +4951,7 @@
w_obj = w_self.getdictvalue(space, 'test')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'test')
return space.wrap(w_self.test)
@@ -5048,20 +4959,22 @@
def IfExp_set_test(space, w_self, w_new_value):
try:
w_self.test = space.interp_w(expr, w_new_value, False)
+ if type(w_self.test) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'test', w_new_value)
return
w_self.deldictvalue(space, 'test')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def IfExp_get_body(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'body')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
return space.wrap(w_self.body)
@@ -5069,20 +4982,22 @@
def IfExp_set_body(space, w_self, w_new_value):
try:
w_self.body = space.interp_w(expr, w_new_value, False)
+ if type(w_self.body) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'body', w_new_value)
return
w_self.deldictvalue(space, 'body')
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
def IfExp_get_orelse(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'orelse')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 4:
+ if not w_self.initialization_state & 16:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'orelse')
return space.wrap(w_self.orelse)
@@ -5090,13 +5005,15 @@
def IfExp_set_orelse(space, w_self, w_new_value):
try:
w_self.orelse = space.interp_w(expr, w_new_value, False)
+ if type(w_self.orelse) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'orelse', w_new_value)
return
w_self.deldictvalue(space, 'orelse')
- w_self.initialization_state |= 4
+ w_self.initialization_state |= 16
_IfExp_field_unroller = unrolling_iterable(['test', 'body', 'orelse'])
def IfExp_init(space, w_self, __args__):
@@ -5125,7 +5042,7 @@
)
def Dict_get_keys(space, w_self):
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'keys')
if w_self.w_keys is None:
@@ -5139,10 +5056,10 @@
def Dict_set_keys(space, w_self, w_new_value):
w_self.w_keys = w_new_value
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def Dict_get_values(space, w_self):
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'values')
if w_self.w_values is None:
@@ -5156,7 +5073,7 @@
def Dict_set_values(space, w_self, w_new_value):
w_self.w_values = w_new_value
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
_Dict_field_unroller = unrolling_iterable(['keys', 'values'])
def Dict_init(space, w_self, __args__):
@@ -5186,7 +5103,7 @@
)
def Set_get_elts(space, w_self):
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'elts')
if w_self.w_elts is None:
@@ -5200,7 +5117,7 @@
def Set_set_elts(space, w_self, w_new_value):
w_self.w_elts = w_new_value
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
_Set_field_unroller = unrolling_iterable(['elts'])
def Set_init(space, w_self, __args__):
@@ -5232,7 +5149,7 @@
w_obj = w_self.getdictvalue(space, 'elt')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'elt')
return space.wrap(w_self.elt)
@@ -5240,16 +5157,18 @@
def ListComp_set_elt(space, w_self, w_new_value):
try:
w_self.elt = space.interp_w(expr, w_new_value, False)
+ if type(w_self.elt) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'elt', w_new_value)
return
w_self.deldictvalue(space, 'elt')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def ListComp_get_generators(space, w_self):
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'generators')
if w_self.w_generators is None:
@@ -5263,7 +5182,7 @@
def ListComp_set_generators(space, w_self, w_new_value):
w_self.w_generators = w_new_value
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
_ListComp_field_unroller = unrolling_iterable(['elt', 'generators'])
def ListComp_init(space, w_self, __args__):
@@ -5296,7 +5215,7 @@
w_obj = w_self.getdictvalue(space, 'elt')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'elt')
return space.wrap(w_self.elt)
@@ -5304,16 +5223,18 @@
def SetComp_set_elt(space, w_self, w_new_value):
try:
w_self.elt = space.interp_w(expr, w_new_value, False)
+ if type(w_self.elt) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'elt', w_new_value)
return
w_self.deldictvalue(space, 'elt')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def SetComp_get_generators(space, w_self):
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'generators')
if w_self.w_generators is None:
@@ -5327,7 +5248,7 @@
def SetComp_set_generators(space, w_self, w_new_value):
w_self.w_generators = w_new_value
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
_SetComp_field_unroller = unrolling_iterable(['elt', 'generators'])
def SetComp_init(space, w_self, __args__):
@@ -5360,7 +5281,7 @@
w_obj = w_self.getdictvalue(space, 'key')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'key')
return space.wrap(w_self.key)
@@ -5368,20 +5289,22 @@
def DictComp_set_key(space, w_self, w_new_value):
try:
w_self.key = space.interp_w(expr, w_new_value, False)
+ if type(w_self.key) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'key', w_new_value)
return
w_self.deldictvalue(space, 'key')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def DictComp_get_value(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'value')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
return space.wrap(w_self.value)
@@ -5389,16 +5312,18 @@
def DictComp_set_value(space, w_self, w_new_value):
try:
w_self.value = space.interp_w(expr, w_new_value, False)
+ if type(w_self.value) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'value', w_new_value)
return
w_self.deldictvalue(space, 'value')
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
def DictComp_get_generators(space, w_self):
- if not w_self.initialization_state & 4:
+ if not w_self.initialization_state & 16:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'generators')
if w_self.w_generators is None:
@@ -5412,7 +5337,7 @@
def DictComp_set_generators(space, w_self, w_new_value):
w_self.w_generators = w_new_value
- w_self.initialization_state |= 4
+ w_self.initialization_state |= 16
_DictComp_field_unroller = unrolling_iterable(['key', 'value', 'generators'])
def DictComp_init(space, w_self, __args__):
@@ -5446,7 +5371,7 @@
w_obj = w_self.getdictvalue(space, 'elt')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'elt')
return space.wrap(w_self.elt)
@@ -5454,16 +5379,18 @@
def GeneratorExp_set_elt(space, w_self, w_new_value):
try:
w_self.elt = space.interp_w(expr, w_new_value, False)
+ if type(w_self.elt) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'elt', w_new_value)
return
w_self.deldictvalue(space, 'elt')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def GeneratorExp_get_generators(space, w_self):
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'generators')
if w_self.w_generators is None:
@@ -5477,7 +5404,7 @@
def GeneratorExp_set_generators(space, w_self, w_new_value):
w_self.w_generators = w_new_value
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
_GeneratorExp_field_unroller = unrolling_iterable(['elt', 'generators'])
def GeneratorExp_init(space, w_self, __args__):
@@ -5510,7 +5437,7 @@
w_obj = w_self.getdictvalue(space, 'value')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
return space.wrap(w_self.value)
@@ -5518,13 +5445,15 @@
def Yield_set_value(space, w_self, w_new_value):
try:
w_self.value = space.interp_w(expr, w_new_value, True)
+ if type(w_self.value) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'value', w_new_value)
return
w_self.deldictvalue(space, 'value')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
_Yield_field_unroller = unrolling_iterable(['value'])
def Yield_init(space, w_self, __args__):
@@ -5555,7 +5484,7 @@
w_obj = w_self.getdictvalue(space, 'left')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'left')
return space.wrap(w_self.left)
@@ -5563,16 +5492,18 @@
def Compare_set_left(space, w_self, w_new_value):
try:
w_self.left = space.interp_w(expr, w_new_value, False)
+ if type(w_self.left) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'left', w_new_value)
return
w_self.deldictvalue(space, 'left')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def Compare_get_ops(space, w_self):
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'ops')
if w_self.w_ops is None:
@@ -5586,10 +5517,10 @@
def Compare_set_ops(space, w_self, w_new_value):
w_self.w_ops = w_new_value
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
def Compare_get_comparators(space, w_self):
- if not w_self.initialization_state & 4:
+ if not w_self.initialization_state & 16:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'comparators')
if w_self.w_comparators is None:
@@ -5603,7 +5534,7 @@
def Compare_set_comparators(space, w_self, w_new_value):
w_self.w_comparators = w_new_value
- w_self.initialization_state |= 4
+ w_self.initialization_state |= 16
_Compare_field_unroller = unrolling_iterable(['left', 'ops', 'comparators'])
def Compare_init(space, w_self, __args__):
@@ -5638,7 +5569,7 @@
w_obj = w_self.getdictvalue(space, 'func')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'func')
return space.wrap(w_self.func)
@@ -5646,16 +5577,18 @@
def Call_set_func(space, w_self, w_new_value):
try:
w_self.func = space.interp_w(expr, w_new_value, False)
+ if type(w_self.func) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'func', w_new_value)
return
w_self.deldictvalue(space, 'func')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def Call_get_args(space, w_self):
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'args')
if w_self.w_args is None:
@@ -5669,10 +5602,10 @@
def Call_set_args(space, w_self, w_new_value):
w_self.w_args = w_new_value
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
def Call_get_keywords(space, w_self):
- if not w_self.initialization_state & 4:
+ if not w_self.initialization_state & 16:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'keywords')
if w_self.w_keywords is None:
@@ -5686,14 +5619,14 @@
def Call_set_keywords(space, w_self, w_new_value):
w_self.w_keywords = w_new_value
- w_self.initialization_state |= 4
+ w_self.initialization_state |= 16
def Call_get_starargs(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'starargs')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 8:
+ if not w_self.initialization_state & 32:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'starargs')
return space.wrap(w_self.starargs)
@@ -5701,20 +5634,22 @@
def Call_set_starargs(space, w_self, w_new_value):
try:
w_self.starargs = space.interp_w(expr, w_new_value, True)
+ if type(w_self.starargs) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'starargs', w_new_value)
return
w_self.deldictvalue(space, 'starargs')
- w_self.initialization_state |= 8
+ w_self.initialization_state |= 32
def Call_get_kwargs(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'kwargs')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 16:
+ if not w_self.initialization_state & 64:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'kwargs')
return space.wrap(w_self.kwargs)
@@ -5722,13 +5657,15 @@
def Call_set_kwargs(space, w_self, w_new_value):
try:
w_self.kwargs = space.interp_w(expr, w_new_value, True)
+ if type(w_self.kwargs) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'kwargs', w_new_value)
return
w_self.deldictvalue(space, 'kwargs')
- w_self.initialization_state |= 16
+ w_self.initialization_state |= 64
_Call_field_unroller = unrolling_iterable(['func', 'args', 'keywords', 'starargs', 'kwargs'])
def Call_init(space, w_self, __args__):
@@ -5765,7 +5702,7 @@
w_obj = w_self.getdictvalue(space, 'value')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
return space.wrap(w_self.value)
@@ -5773,13 +5710,15 @@
def Repr_set_value(space, w_self, w_new_value):
try:
w_self.value = space.interp_w(expr, w_new_value, False)
+ if type(w_self.value) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'value', w_new_value)
return
w_self.deldictvalue(space, 'value')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
_Repr_field_unroller = unrolling_iterable(['value'])
def Repr_init(space, w_self, __args__):
@@ -5810,7 +5749,7 @@
w_obj = w_self.getdictvalue(space, 'n')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'n')
return w_self.n
@@ -5824,7 +5763,7 @@
w_self.setdictvalue(space, 'n', w_new_value)
return
w_self.deldictvalue(space, 'n')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
_Num_field_unroller = unrolling_iterable(['n'])
def Num_init(space, w_self, __args__):
@@ -5855,7 +5794,7 @@
w_obj = w_self.getdictvalue(space, 's')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 's')
return w_self.s
@@ -5869,7 +5808,7 @@
w_self.setdictvalue(space, 's', w_new_value)
return
w_self.deldictvalue(space, 's')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
_Str_field_unroller = unrolling_iterable(['s'])
def Str_init(space, w_self, __args__):
@@ -5900,7 +5839,7 @@
w_obj = w_self.getdictvalue(space, 'value')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
return space.wrap(w_self.value)
@@ -5908,20 +5847,22 @@
def Attribute_set_value(space, w_self, w_new_value):
try:
w_self.value = space.interp_w(expr, w_new_value, False)
+ if type(w_self.value) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'value', w_new_value)
return
w_self.deldictvalue(space, 'value')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def Attribute_get_attr(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'attr')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'attr')
return space.wrap(w_self.attr)
@@ -5935,14 +5876,14 @@
w_self.setdictvalue(space, 'attr', w_new_value)
return
w_self.deldictvalue(space, 'attr')
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
def Attribute_get_ctx(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'ctx')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 4:
+ if not w_self.initialization_state & 16:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'ctx')
return expr_context_to_class[w_self.ctx - 1]()
@@ -5958,7 +5899,7 @@
return
# need to save the original object too
w_self.setdictvalue(space, 'ctx', w_new_value)
- w_self.initialization_state |= 4
+ w_self.initialization_state |= 16
_Attribute_field_unroller = unrolling_iterable(['value', 'attr', 'ctx'])
def Attribute_init(space, w_self, __args__):
@@ -5991,7 +5932,7 @@
w_obj = w_self.getdictvalue(space, 'value')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
return space.wrap(w_self.value)
@@ -5999,20 +5940,22 @@
def Subscript_set_value(space, w_self, w_new_value):
try:
w_self.value = space.interp_w(expr, w_new_value, False)
+ if type(w_self.value) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'value', w_new_value)
return
w_self.deldictvalue(space, 'value')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def Subscript_get_slice(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'slice')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'slice')
return space.wrap(w_self.slice)
@@ -6020,20 +5963,22 @@
def Subscript_set_slice(space, w_self, w_new_value):
try:
w_self.slice = space.interp_w(slice, w_new_value, False)
+ if type(w_self.slice) is slice:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'slice', w_new_value)
return
w_self.deldictvalue(space, 'slice')
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
def Subscript_get_ctx(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'ctx')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 4:
+ if not w_self.initialization_state & 16:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'ctx')
return expr_context_to_class[w_self.ctx - 1]()
@@ -6049,7 +5994,7 @@
return
# need to save the original object too
w_self.setdictvalue(space, 'ctx', w_new_value)
- w_self.initialization_state |= 4
+ w_self.initialization_state |= 16
_Subscript_field_unroller = unrolling_iterable(['value', 'slice', 'ctx'])
def Subscript_init(space, w_self, __args__):
@@ -6082,7 +6027,7 @@
w_obj = w_self.getdictvalue(space, 'id')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'id')
return space.wrap(w_self.id)
@@ -6096,14 +6041,14 @@
w_self.setdictvalue(space, 'id', w_new_value)
return
w_self.deldictvalue(space, 'id')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def Name_get_ctx(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'ctx')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'ctx')
return expr_context_to_class[w_self.ctx - 1]()
@@ -6119,7 +6064,7 @@
return
# need to save the original object too
w_self.setdictvalue(space, 'ctx', w_new_value)
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
_Name_field_unroller = unrolling_iterable(['id', 'ctx'])
def Name_init(space, w_self, __args__):
@@ -6147,7 +6092,7 @@
)
def List_get_elts(space, w_self):
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'elts')
if w_self.w_elts is None:
@@ -6161,14 +6106,14 @@
def List_set_elts(space, w_self, w_new_value):
w_self.w_elts = w_new_value
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def List_get_ctx(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'ctx')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'ctx')
return expr_context_to_class[w_self.ctx - 1]()
@@ -6184,7 +6129,7 @@
return
# need to save the original object too
w_self.setdictvalue(space, 'ctx', w_new_value)
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
_List_field_unroller = unrolling_iterable(['elts', 'ctx'])
def List_init(space, w_self, __args__):
@@ -6213,7 +6158,7 @@
)
def Tuple_get_elts(space, w_self):
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'elts')
if w_self.w_elts is None:
@@ -6227,14 +6172,14 @@
def Tuple_set_elts(space, w_self, w_new_value):
w_self.w_elts = w_new_value
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def Tuple_get_ctx(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'ctx')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'ctx')
return expr_context_to_class[w_self.ctx - 1]()
@@ -6250,7 +6195,7 @@
return
# need to save the original object too
w_self.setdictvalue(space, 'ctx', w_new_value)
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
_Tuple_field_unroller = unrolling_iterable(['elts', 'ctx'])
def Tuple_init(space, w_self, __args__):
@@ -6283,7 +6228,7 @@
w_obj = w_self.getdictvalue(space, 'value')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
return w_self.value
@@ -6297,7 +6242,7 @@
w_self.setdictvalue(space, 'value', w_new_value)
return
w_self.deldictvalue(space, 'value')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
_Const_field_unroller = unrolling_iterable(['value'])
def Const_init(space, w_self, __args__):
@@ -6409,6 +6354,8 @@
def Slice_set_lower(space, w_self, w_new_value):
try:
w_self.lower = space.interp_w(expr, w_new_value, True)
+ if type(w_self.lower) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
@@ -6430,6 +6377,8 @@
def Slice_set_upper(space, w_self, w_new_value):
try:
w_self.upper = space.interp_w(expr, w_new_value, True)
+ if type(w_self.upper) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
@@ -6451,6 +6400,8 @@
def Slice_set_step(space, w_self, w_new_value):
try:
w_self.step = space.interp_w(expr, w_new_value, True)
+ if type(w_self.step) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
@@ -6540,6 +6491,8 @@
def Index_set_value(space, w_self, w_new_value):
try:
w_self.value = space.interp_w(expr, w_new_value, False)
+ if type(w_self.value) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
@@ -6809,6 +6762,8 @@
def comprehension_set_target(space, w_self, w_new_value):
try:
w_self.target = space.interp_w(expr, w_new_value, False)
+ if type(w_self.target) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
@@ -6830,6 +6785,8 @@
def comprehension_set_iter(space, w_self, w_new_value):
try:
w_self.iter = space.interp_w(expr, w_new_value, False)
+ if type(w_self.iter) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
@@ -6887,7 +6844,7 @@
w_obj = w_self.getdictvalue(space, 'lineno')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & w_self._lineno_mask:
+ if not w_self.initialization_state & 1:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'lineno')
return space.wrap(w_self.lineno)
@@ -6901,14 +6858,14 @@
w_self.setdictvalue(space, 'lineno', w_new_value)
return
w_self.deldictvalue(space, 'lineno')
- w_self.initialization_state |= w_self._lineno_mask
+ w_self.initialization_state |= 1
def excepthandler_get_col_offset(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'col_offset')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & w_self._col_offset_mask:
+ if not w_self.initialization_state & 2:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'col_offset')
return space.wrap(w_self.col_offset)
@@ -6922,7 +6879,7 @@
w_self.setdictvalue(space, 'col_offset', w_new_value)
return
w_self.deldictvalue(space, 'col_offset')
- w_self.initialization_state |= w_self._col_offset_mask
+ w_self.initialization_state |= 2
excepthandler.typedef = typedef.TypeDef("excepthandler",
AST.typedef,
@@ -6938,7 +6895,7 @@
w_obj = w_self.getdictvalue(space, 'type')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 1:
+ if not w_self.initialization_state & 4:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'type')
return space.wrap(w_self.type)
@@ -6946,20 +6903,22 @@
def ExceptHandler_set_type(space, w_self, w_new_value):
try:
w_self.type = space.interp_w(expr, w_new_value, True)
+ if type(w_self.type) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'type', w_new_value)
return
w_self.deldictvalue(space, 'type')
- w_self.initialization_state |= 1
+ w_self.initialization_state |= 4
def ExceptHandler_get_name(space, w_self):
if w_self.w_dict is not None:
w_obj = w_self.getdictvalue(space, 'name')
if w_obj is not None:
return w_obj
- if not w_self.initialization_state & 2:
+ if not w_self.initialization_state & 8:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'name')
return space.wrap(w_self.name)
@@ -6967,16 +6926,18 @@
def ExceptHandler_set_name(space, w_self, w_new_value):
try:
w_self.name = space.interp_w(expr, w_new_value, True)
+ if type(w_self.name) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
w_self.setdictvalue(space, 'name', w_new_value)
return
w_self.deldictvalue(space, 'name')
- w_self.initialization_state |= 2
+ w_self.initialization_state |= 8
def ExceptHandler_get_body(space, w_self):
- if not w_self.initialization_state & 4:
+ if not w_self.initialization_state & 16:
typename = space.type(w_self).getname(space)
raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
if w_self.w_body is None:
@@ -6990,7 +6951,7 @@
def ExceptHandler_set_body(space, w_self, w_new_value):
w_self.w_body = w_new_value
- w_self.initialization_state |= 4
+ w_self.initialization_state |= 16
_ExceptHandler_field_unroller = unrolling_iterable(['type', 'name', 'body'])
def ExceptHandler_init(space, w_self, __args__):
@@ -7164,6 +7125,8 @@
def keyword_set_value(space, w_self, w_new_value):
try:
w_self.value = space.interp_w(expr, w_new_value, False)
+ if type(w_self.value) is expr:
+ raise OperationError(space.w_TypeError, space.w_None)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
diff --git a/pypy/interpreter/astcompiler/tools/asdl_py.py b/pypy/interpreter/astcompiler/tools/asdl_py.py
--- a/pypy/interpreter/astcompiler/tools/asdl_py.py
+++ b/pypy/interpreter/astcompiler/tools/asdl_py.py
@@ -79,6 +79,7 @@
else:
self.emit("class %s(AST):" % (base,))
if sum.attributes:
+ self.emit("")
args = ", ".join(attr.name.value for attr in sum.attributes)
self.emit("def __init__(self, %s):" % (args,), 1)
for attr in sum.attributes:
@@ -114,7 +115,7 @@
else:
names.append(repr(field.name.value))
sub = (", ".join(names), name.value)
- self.emit("missing_field(space, self.initialization_state, [%s], %r)"
+ self.emit("self.missing_field(space, [%s], %r)"
% sub, 3)
self.emit("else:", 2)
# Fill in all the default fields.
@@ -195,17 +196,13 @@
def visitConstructor(self, cons, base, extra_attributes):
self.emit("class %s(%s):" % (cons.name, base))
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)
- self.emit("")
self.make_constructor(cons.fields, cons, extra_attributes, base)
self.emit("")
self.emit("def walkabout(self, visitor):", 1)
self.emit("visitor.visit_%s(self)" % (cons.name,), 2)
self.emit("")
self.make_mutate_over(cons, cons.name)
- self.make_var_syncer(cons.fields + self.data.cons_attributes[cons],
+ self.make_var_syncer(self.data.cons_attributes[cons] + cons.fields,
cons, cons.name)
def visitField(self, field):
@@ -324,7 +321,7 @@
def visitSum(self, sum, name):
for field in sum.attributes:
- self.make_property(field, name, True)
+ self.make_property(field, name)
self.make_typedef(name, "AST", sum.attributes,
fields_name="_attributes")
if not is_simple_sum(sum):
@@ -400,13 +397,10 @@
def visitField(self, field, name):
self.make_property(field, name)
- def make_property(self, field, name, different_masks=False):
+ def make_property(self, field, name):
func = "def %s_get_%s(space, w_self):" % (name, field.name)
self.emit(func)
- if different_masks:
- flag = "w_self._%s_mask" % (field.name,)
- else:
- flag = self.data.field_masks[field]
+ flag = self.data.field_masks[field]
if not field.seq:
self.emit("if w_self.w_dict is not None:", 1)
self.emit(" w_obj = w_self.getdictvalue(space, '%s')" % (field.name,), 1)
@@ -458,6 +452,11 @@
config = (field.name, field.type, repr(field.opt))
self.emit("w_self.%s = space.interp_w(%s, w_new_value, %s)" %
config, 2)
+ if field.type.value not in self.data.prod_simple:
+ self.emit("if type(w_self.%s) is %s:" % (
+ field.name, field.type), 2)
+ self.emit("raise OperationError(space.w_TypeError, "
+ "space.w_None)", 3)
else:
level = 2
if field.opt and field.type.value != "int":
@@ -505,7 +504,10 @@
optional_mask = 0
for i, field in enumerate(fields):
flag = 1 << i
- field_masks[field] = flag
+ if field not in field_masks:
+ field_masks[field] = flag
+ else:
+ assert field_masks[field] == flag
if field.opt:
optional_mask |= flag
else:
@@ -518,9 +520,9 @@
if is_simple_sum(sum):
simple_types.add(tp.name.value)
else:
+ attrs = [field for field in sum.attributes]
for cons in sum.types:
- attrs = [copy_field(field) for field in sum.attributes]
- add_masks(cons.fields + attrs, cons)
+ add_masks(attrs + cons.fields, cons)
cons_attributes[cons] = attrs
else:
prod = tp.value
@@ -588,6 +590,24 @@
space.setattr(self, w_name,
space.getitem(w_state, w_name))
+ def missing_field(self, space, required, host):
+ "Find which required field is missing."
+ state = self.initialization_state
+ for i in range(len(required)):
+ if (state >> i) & 1:
+ continue # field is present
+ missing = required[i]
+ if missing is None:
+ continue # field is optional
+ w_obj = self.getdictvalue(space, missing)
+ if w_obj is None:
+ err = "required field \\"%s\\" missing from %s"
+ raise operationerrfmt(space.w_TypeError, err, missing, host)
+ else:
+ err = "incorrect type for field \\"%s\\" in %s"
+ raise operationerrfmt(space.w_TypeError, err, missing, host)
+ raise AssertionError("should not reach here")
+
class NodeVisitorNotImplemented(Exception):
pass
@@ -631,15 +651,6 @@
)
-def missing_field(space, state, required, host):
- "Find which required field is missing."
- for i in range(len(required)):
- if not (state >> i) & 1:
- missing = required[i]
- if missing is not None:
- err = "required field \\"%s\\" missing from %s"
- raise operationerrfmt(space.w_TypeError, err, missing, host)
- raise AssertionError("should not reach here")
"""
diff --git a/pypy/jit/backend/x86/test/test_jump.py b/pypy/jit/backend/x86/test/test_jump.py
--- a/pypy/jit/backend/x86/test/test_jump.py
+++ b/pypy/jit/backend/x86/test/test_jump.py
@@ -249,7 +249,7 @@
while len(result) < count:
x = fn()
keys = [x._getregkey()]
- if isinstance(x, StackLoc) and x.width > WORD:
+ if isinstance(x, StackLoc) and x.get_width() > WORD:
keys.append(keys[0] + WORD)
for key in keys:
if key in seen:
@@ -267,7 +267,7 @@
for i, loc in enumerate(locations):
if isinstance(loc, RegLoc):
if loc.is_xmm:
- if loc.width > WORD:
+ if loc.get_width() > WORD:
newvalue = ('value-xmm-%d' % i,
'value-xmm-hiword-%d' % i)
else:
@@ -276,8 +276,8 @@
else:
regs1[loc.value] = 'value-int-%d' % i
elif isinstance(loc, StackLoc):
- stack[loc.value] = 'value-width%d-%d' % (loc.width, i)
- if loc.width > WORD:
+ stack[loc.value] = 'value-width%d-%d' % (loc.get_width(), i)
+ if loc.get_width() > WORD:
stack[loc.value+WORD] = 'value-hiword-%d' % i
else:
assert isinstance(loc, ImmedLoc)
@@ -299,7 +299,7 @@
#
def read(loc, expected_width=None):
if expected_width is not None:
- assert loc.width == expected_width
+ assert loc.get_width() == expected_width
if isinstance(loc, RegLoc):
if loc.is_xmm:
return regs2[loc.value]
@@ -307,7 +307,7 @@
return regs1[loc.value]
if isinstance(loc, StackLoc):
got = stack[loc.value]
- if loc.width > WORD:
+ if loc.get_width() > WORD:
got = (got, stack[loc.value+WORD])
return got
if isinstance(loc, ImmedLoc):
@@ -321,7 +321,7 @@
else:
regs1[loc.value] = newvalue
elif isinstance(loc, StackLoc):
- if loc.width > WORD:
+ if loc.get_width() > WORD:
newval1, newval2 = newvalue
stack[loc.value] = newval1
stack[loc.value+WORD] = newval2
diff --git a/pypy/jit/metainterp/optimizeopt/heap.py b/pypy/jit/metainterp/optimizeopt/heap.py
--- a/pypy/jit/metainterp/optimizeopt/heap.py
+++ b/pypy/jit/metainterp/optimizeopt/heap.py
@@ -246,15 +246,16 @@
self.force_lazy_setfields_and_arrayitems_for_guard())
return
opnum = op.getopnum()
- if (opnum == rop.SETFIELD_GC or # handled specially
- opnum == rop.SETFIELD_RAW or # no effect on GC struct/array
- opnum == rop.SETARRAYITEM_GC or # handled specially
- opnum == rop.SETARRAYITEM_RAW or # no effect on GC struct
- opnum == rop.STRSETITEM or # no effect on GC struct/array
- opnum == rop.UNICODESETITEM or # no effect on GC struct/array
- opnum == rop.DEBUG_MERGE_POINT or # no effect whatsoever
- opnum == rop.COPYSTRCONTENT or # no effect on GC struct/array
- opnum == rop.COPYUNICODECONTENT): # no effect on GC struct/array
+ if (opnum == rop.SETFIELD_GC or # handled specially
+ opnum == rop.SETFIELD_RAW or # no effect on GC struct/array
+ opnum == rop.SETARRAYITEM_GC or # handled specially
+ opnum == rop.SETARRAYITEM_RAW or # no effect on GC struct
+ opnum == rop.SETINTERIORFIELD_RAW or # no effect on GC struct
+ opnum == rop.STRSETITEM or # no effect on GC struct/array
+ opnum == rop.UNICODESETITEM or # no effect on GC struct/array
+ opnum == rop.DEBUG_MERGE_POINT or # no effect whatsoever
+ opnum == rop.COPYSTRCONTENT or # no effect on GC struct/array
+ opnum == rop.COPYUNICODECONTENT): # no effect on GC struct/array
return
assert opnum != rop.CALL_PURE
if (opnum == rop.CALL or
diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
@@ -7755,6 +7755,22 @@
"""
self.optimize_loop(ops, expected)
+ def test_setinteriorfield_should_not_clear_cache(self):
+ ops = """
+ [i0, p0]
+ i2 = getfield_gc(p0, descr=adescr)
+ i3 = call(i2, descr=nonwritedescr)
+ setinteriorfield_raw(i0, i2, i3)
+ jump(i0, p0)
+ """
+ expected = """
+ [i0, p0, i2]
+ i3 = call(i2, descr=nonwritedescr)
+ setinteriorfield_raw(i0, i2, i3)
+ jump(i0, p0, i2)
+ """
+ self.optimize_loop(ops, expected)
+
class TestLLtype(OptimizeOptTest, LLtypeMixin):
pass
diff --git a/pypy/module/_ast/test/test_ast.py b/pypy/module/_ast/test/test_ast.py
--- a/pypy/module/_ast/test/test_ast.py
+++ b/pypy/module/_ast/test/test_ast.py
@@ -285,3 +285,10 @@
[], lineno=1, col_offset=0)
])
exec compile(body, '<string>', 'exec')
+
+ def test_invalid_sum(self):
+ import _ast as ast
+ pos = dict(lineno=2, col_offset=3)
+ m = ast.Module([ast.Expr(ast.expr(**pos), **pos)])
+ exc = raises(TypeError, compile, m, "<test>", "exec")
+
diff --git a/pypy/module/_weakref/interp__weakref.py b/pypy/module/_weakref/interp__weakref.py
--- a/pypy/module/_weakref/interp__weakref.py
+++ b/pypy/module/_weakref/interp__weakref.py
@@ -329,11 +329,16 @@
special_ops = {'repr': True, 'userdel': True, 'hash': True}
for opname, _, arity, special_methods in ObjSpace.MethodTable:
- if opname in special_ops:
+ if opname in special_ops or not special_methods:
continue
nonspaceargs = ", ".join(["w_obj%s" % i for i in range(arity)])
code = "def func(space, %s):\n '''%s'''\n" % (nonspaceargs, opname)
- for i in range(arity):
+ assert arity >= len(special_methods)
+ forcing_count = len(special_methods)
+ if opname.startswith('inplace_'):
+ assert arity == 2
+ forcing_count = arity
+ for i in range(forcing_count):
code += " w_obj%s = force(space, w_obj%s)\n" % (i, i)
code += " return space.%s(%s)" % (opname, nonspaceargs)
exec py.code.Source(code).compile()
diff --git a/pypy/module/_weakref/test/test_weakref.py b/pypy/module/_weakref/test/test_weakref.py
--- a/pypy/module/_weakref/test/test_weakref.py
+++ b/pypy/module/_weakref/test/test_weakref.py
@@ -466,3 +466,44 @@
# No exception should be raised here
gc.collect()
+ def test_add(self):
+ import _weakref
+ class A(object):
+ def __add__(self, other):
+ return other
+ a1 = A()
+ a2 = A()
+ p1 = _weakref.proxy(a1)
+ p2 = _weakref.proxy(a2)
+ a3 = p1 + p2
+ assert a3 is a2
+
+ def test_inplace_add(self):
+ import _weakref
+ class A(object):
+ def __add__(self, other):
+ return other
+ a1 = A()
+ a2 = A()
+ p1 = _weakref.proxy(a1)
+ p2 = _weakref.proxy(a2)
+ p1 += p2
+ assert p1 is a2
+
+ def test_setattr(self):
+ import _weakref
+ class A(object):
+ def __setitem__(self, key, value):
+ self.setkey = key
+ self.setvalue = value
+ a1 = A()
+ a2 = A()
+ p1 = _weakref.proxy(a1)
+ p2 = _weakref.proxy(a2)
+ p1[p2] = 42
+ assert a1.setkey is p2
+ assert a1.setvalue == 42
+ #
+ p1[42] = p2
+ assert a1.setkey == 42
+ assert a1.setvalue is p2
diff --git a/pypy/module/micronumpy/app_numpy.py b/pypy/module/micronumpy/app_numpy.py
--- a/pypy/module/micronumpy/app_numpy.py
+++ b/pypy/module/micronumpy/app_numpy.py
@@ -53,7 +53,6 @@
i = start
for j in range(arr.size):
arr[j] = i
- j += 1
i += step
return arr
diff --git a/pypy/module/micronumpy/interp_boxes.py b/pypy/module/micronumpy/interp_boxes.py
--- a/pypy/module/micronumpy/interp_boxes.py
+++ b/pypy/module/micronumpy/interp_boxes.py
@@ -133,7 +133,7 @@
descr__new__, get_dtype = new_dtype_getter("long")
class W_ULongBox(W_UnsignedIntegerBox, PrimitiveBox):
- pass
+ descr__new__, get_dtype = new_dtype_getter("ulong")
class W_Int64Box(W_SignedIntegerBox, PrimitiveBox):
descr__new__, get_dtype = new_dtype_getter("int64")
diff --git a/pypy/module/micronumpy/interp_support.py b/pypy/module/micronumpy/interp_support.py
--- a/pypy/module/micronumpy/interp_support.py
+++ b/pypy/module/micronumpy/interp_support.py
@@ -1,34 +1,90 @@
-from pypy.interpreter.error import OperationError
+from pypy.interpreter.error import OperationError, operationerrfmt
from pypy.interpreter.gateway import unwrap_spec
-from pypy.module.micronumpy.interp_dtype import get_dtype_cache
-from pypy.rlib.rstruct.runpack import runpack
from pypy.rpython.lltypesystem import lltype, rffi
+from pypy.module.micronumpy import interp_dtype
+from pypy.objspace.std.strutil import strip_spaces
FLOAT_SIZE = rffi.sizeof(lltype.Float)
- at unwrap_spec(s=str)
-def fromstring(space, s):
+def _fromstring_text(space, s, count, sep, length, dtype):
from pypy.module.micronumpy.interp_numarray import W_NDimArray
+
+ sep_stripped = strip_spaces(sep)
+ skip_bad_vals = len(sep_stripped) == 0
+
+ items = []
+ num_items = 0
+ idx = 0
+
+ while (num_items < count or count == -1) and idx < len(s):
+ nextidx = s.find(sep, idx)
+ if nextidx < 0:
+ nextidx = length
+ piece = strip_spaces(s[idx:nextidx])
+ if len(piece) > 0 or not skip_bad_vals:
+ if len(piece) == 0 and not skip_bad_vals:
+ val = dtype.itemtype.default_fromstring(space)
+ else:
+ try:
+ val = dtype.coerce(space, space.wrap(piece))
+ except OperationError, e:
+ if not e.match(space, space.w_ValueError):
+ raise
+ gotit = False
+ while not gotit and len(piece) > 0:
+ piece = piece[:-1]
+ try:
+ val = dtype.coerce(space, space.wrap(piece))
+ gotit = True
+ except OperationError, e:
+ if not e.match(space, space.w_ValueError):
+ raise
+ if not gotit:
+ val = dtype.itemtype.default_fromstring(space)
+ nextidx = length
+ items.append(val)
+ num_items += 1
+ idx = nextidx + 1
+
+ if count > num_items:
+ raise OperationError(space.w_ValueError, space.wrap(
+ "string is smaller than requested size"))
+
+ a = W_NDimArray(num_items, [num_items], dtype=dtype)
+ for i, val in enumerate(items):
+ a.dtype.setitem(a.storage, i, val)
+
+ return space.wrap(a)
+
+def _fromstring_bin(space, s, count, length, dtype):
+ from pypy.module.micronumpy.interp_numarray import W_NDimArray
+
+ itemsize = dtype.itemtype.get_element_size()
+ if count == -1:
+ count = length / itemsize
+ if length % itemsize != 0:
+ raise operationerrfmt(space.w_ValueError,
+ "string length %d not divisable by item size %d",
+ length, itemsize)
+ if count * itemsize > length:
+ raise OperationError(space.w_ValueError, space.wrap(
+ "string is smaller than requested size"))
+
+ a = W_NDimArray(count, [count], dtype=dtype)
+ for i in range(count):
+ val = dtype.itemtype.runpack_str(s[i*itemsize:i*itemsize + itemsize])
+ a.dtype.setitem(a.storage, i, val)
+
+ return space.wrap(a)
+
+ at unwrap_spec(s=str, count=int, sep=str)
+def fromstring(space, s, w_dtype=None, count=-1, sep=''):
+ dtype = space.interp_w(interp_dtype.W_Dtype,
+ space.call_function(space.gettypefor(interp_dtype.W_Dtype), w_dtype)
+ )
length = len(s)
-
- if length % FLOAT_SIZE == 0:
- number = length/FLOAT_SIZE
+ if sep == '':
+ return _fromstring_bin(space, s, count, length, dtype)
else:
- raise OperationError(space.w_ValueError, space.wrap(
- "string length %d not divisable by %d" % (length, FLOAT_SIZE)))
-
- dtype = get_dtype_cache(space).w_float64dtype
- a = W_NDimArray(number, [number], dtype=dtype)
-
- start = 0
- end = FLOAT_SIZE
- i = 0
- while i < number:
- part = s[start:end]
- a.dtype.setitem(a.storage, i, dtype.box(runpack('d', part)))
- i += 1
- start += FLOAT_SIZE
- end += FLOAT_SIZE
-
- return space.wrap(a)
+ return _fromstring_text(space, s, count, sep, length, dtype)
diff --git a/pypy/module/micronumpy/test/test_numarray.py b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -1194,13 +1194,110 @@
import struct
BaseNumpyAppTest.setup_class.im_func(cls)
cls.w_data = cls.space.wrap(struct.pack('dddd', 1, 2, 3, 4))
+ cls.w_fdata = cls.space.wrap(struct.pack('f', 2.3))
+ cls.w_float32val = cls.space.wrap(struct.pack('f', 5.2))
+ cls.w_float64val = cls.space.wrap(struct.pack('d', 300.4))
+ cls.w_ulongval = cls.space.wrap(struct.pack('L', 12))
def test_fromstring(self):
- from numpypy import fromstring
+ import sys
+ from numpypy import fromstring, array, uint8, float32, int32
+
a = fromstring(self.data)
for i in range(4):
assert a[i] == i + 1
- raises(ValueError, fromstring, "abc")
+ b = fromstring('\x01\x02', dtype=uint8)
+ assert a[0] == 1
+ assert a[1] == 2
+ c = fromstring(self.fdata, dtype=float32)
+ assert c[0] == float32(2.3)
+ d = fromstring("1 2", sep=' ', count=2, dtype=uint8)
+ assert len(d) == 2
+ assert d[0] == 1
+ assert d[1] == 2
+ e = fromstring('3, 4,5', dtype=uint8, sep=',')
+ assert len(e) == 3
+ assert e[0] == 3
+ assert e[1] == 4
+ assert e[2] == 5
+ f = fromstring('\x01\x02\x03\x04\x05', dtype=uint8, count=3)
+ assert len(f) == 3
+ assert f[0] == 1
+ assert f[1] == 2
+ assert f[2] == 3
+ g = fromstring("1 2 3 ", dtype=uint8, sep=" ")
+ assert len(g) == 3
+ assert g[0] == 1
+ assert g[1] == 2
+ assert g[2] == 3
+ h = fromstring("1, , 2, 3", dtype=uint8, sep=",")
+ assert (h == [1,0,2,3]).all()
+ i = fromstring("1 2 3", dtype=uint8, sep=" ")
+ assert (i == [1,2,3]).all()
+ j = fromstring("1\t\t\t\t2\t3", dtype=uint8, sep="\t")
+ assert (j == [1,2,3]).all()
+ k = fromstring("1,x,2,3", dtype=uint8, sep=",")
+ assert (k == [1,0]).all()
+ l = fromstring("1,x,2,3", dtype='float32', sep=",")
+ assert (l == [1.0,-1.0]).all()
+ m = fromstring("1,,2,3", sep=",")
+ assert (m == [1.0,-1.0,2.0,3.0]).all()
+ n = fromstring("3.4 2.0 3.8 2.2", dtype=int32, sep=" ")
+ assert (n == [3]).all()
+ o = fromstring("1.0 2f.0f 3.8 2.2", dtype=float32, sep=" ")
+ assert len(o) == 2
+ assert o[0] == 1.0
+ assert o[1] == 2.0
+ p = fromstring("1.0,,2.0,3.0", sep=",")
+ assert (p == [1.0, -1.0, 2.0, 3.0]).all()
+ q = fromstring("1.0,,2.0,3.0", sep=" ")
+ assert (q == [1.0]).all()
+ r = fromstring("\x01\x00\x02", dtype='bool')
+ assert (r == [True, False, True]).all()
+ s = fromstring("1,2,3,,5", dtype=bool, sep=",")
+ assert (s == [True, True, True, False, True]).all()
+ t = fromstring("", bool)
+ assert (t == []).all()
+ u = fromstring("\x01\x00\x00\x00\x00\x00\x00\x00", dtype=int)
+ if sys.maxint > 2 ** 31 - 1:
+ assert (u == [1]).all()
+ else:
+ assert (u == [1, 0]).all()
+
+ def test_fromstring_types(self):
+ from numpypy import (fromstring, int8, int16, int32, int64, uint8,
+ uint16, uint32, float32, float64)
+
+ a = fromstring('\xFF', dtype=int8)
+ assert a[0] == -1
+ b = fromstring('\xFF', dtype=uint8)
+ assert b[0] == 255
+ c = fromstring('\xFF\xFF', dtype=int16)
+ assert c[0] == -1
+ d = fromstring('\xFF\xFF', dtype=uint16)
+ assert d[0] == 65535
+ e = fromstring('\xFF\xFF\xFF\xFF', dtype=int32)
+ assert e[0] == -1
+ f = fromstring('\xFF\xFF\xFF\xFF', dtype=uint32)
+ assert repr(f[0]) == '4294967295'
+ g = fromstring('\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF', dtype=int64)
+ assert g[0] == -1
+ h = fromstring(self.float32val, dtype=float32)
+ assert h[0] == float32(5.2)
+ i = fromstring(self.float64val, dtype=float64)
+ assert i[0] == float64(300.4)
+ j = fromstring(self.ulongval, dtype='L')
+ assert j[0] == 12
+
+
+ def test_fromstring_invalid(self):
+ from numpypy import fromstring, uint16, uint8, int32
+ #default dtype is 64-bit float, so 3 bytes should fail
+ raises(ValueError, fromstring, "\x01\x02\x03")
+ #3 bytes is not modulo 2 bytes (int16)
+ raises(ValueError, fromstring, "\x01\x03\x03", dtype=uint16)
+ #5 bytes is larger than 3 bytes
+ raises(ValueError, fromstring, "\x01\x02\x03", count=5, dtype=uint8)
class AppTestRepr(BaseNumpyAppTest):
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -8,6 +8,7 @@
from pypy.rlib.objectmodel import specialize
from pypy.rlib.rarithmetic import LONG_BIT, widen
from pypy.rpython.lltypesystem import lltype, rffi
+from pypy.rlib.rstruct.runpack import runpack
def simple_unary_op(func):
@@ -55,6 +56,7 @@
class Primitive(object):
_mixin_ = True
+
def get_element_size(self):
return rffi.sizeof(self.T)
@@ -84,6 +86,9 @@
def _coerce(self, space, w_item):
raise NotImplementedError
+ def default_fromstring(self, space):
+ raise NotImplementedError
+
def read(self, storage, width, i, offset):
return self.box(libffi.array_getitem(clibffi.cast_type_to_ffitype(self.T),
width, storage, i, offset
@@ -102,6 +107,9 @@
width, storage, i, offset, value
)
+ def runpack_str(self, s):
+ return self.box(runpack(self.format_code, s))
+
@simple_binary_op
def add(self, v1, v2):
return v1 + v2
@@ -164,6 +172,7 @@
class Bool(BaseType, Primitive):
T = lltype.Bool
BoxType = interp_boxes.W_BoolBox
+ format_code = "?"
True = BoxType(True)
False = BoxType(False)
@@ -193,6 +202,9 @@
def for_computation(self, v):
return int(v)
+ def default_fromstring(self, space):
+ return self.box(False)
+
class Integer(Primitive):
_mixin_ = True
@@ -206,6 +218,9 @@
def for_computation(self, v):
return widen(v)
+ def default_fromstring(self, space):
+ return self.box(0)
+
@simple_binary_op
def div(self, v1, v2):
if v2 == 0:
@@ -241,42 +256,52 @@
class Int8(BaseType, Integer):
T = rffi.SIGNEDCHAR
BoxType = interp_boxes.W_Int8Box
+ format_code = "b"
class UInt8(BaseType, Integer):
T = rffi.UCHAR
BoxType = interp_boxes.W_UInt8Box
+ format_code = "B"
class Int16(BaseType, Integer):
T = rffi.SHORT
BoxType = interp_boxes.W_Int16Box
+ format_code = "h"
class UInt16(BaseType, Integer):
T = rffi.USHORT
BoxType = interp_boxes.W_UInt16Box
+ format_code = "H"
class Int32(BaseType, Integer):
T = rffi.INT
BoxType = interp_boxes.W_Int32Box
+ format_code = "i"
class UInt32(BaseType, Integer):
T = rffi.UINT
BoxType = interp_boxes.W_UInt32Box
+ format_code = "I"
class Long(BaseType, Integer):
T = rffi.LONG
BoxType = interp_boxes.W_LongBox
+ format_code = "l"
class ULong(BaseType, Integer):
T = rffi.ULONG
BoxType = interp_boxes.W_ULongBox
+ format_code = "L"
class Int64(BaseType, Integer):
T = rffi.LONGLONG
BoxType = interp_boxes.W_Int64Box
+ format_code = "q"
class UInt64(BaseType, Integer):
T = rffi.ULONGLONG
BoxType = interp_boxes.W_UInt64Box
+ format_code = "Q"
def _coerce(self, space, w_item):
try:
@@ -304,6 +329,9 @@
def for_computation(self, v):
return float(v)
+ def default_fromstring(self, space):
+ return self.box(-1.0)
+
@simple_binary_op
def div(self, v1, v2):
try:
@@ -403,7 +431,9 @@
class Float32(BaseType, Float):
T = rffi.FLOAT
BoxType = interp_boxes.W_Float32Box
+ format_code = "f"
class Float64(BaseType, Float):
T = rffi.DOUBLE
- BoxType = interp_boxes.W_Float64Box
\ No newline at end of file
+ BoxType = interp_boxes.W_Float64Box
+ format_code = "d"
\ No newline at end of file
diff --git a/pypy/module/pypyjit/test_pypy_c/test_generators.py b/pypy/module/pypyjit/test_pypy_c/test_generators.py
--- a/pypy/module/pypyjit/test_pypy_c/test_generators.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_generators.py
@@ -17,17 +17,8 @@
g()
log = self.run(main, [500])
- # XXX XXX this test fails so far because of a detail that
- # changed with jit-simplify-backendintf. We should try to
- # think of a way to be more resistent against such details.
- # The issue is that we now get one Tracing, then go back
- # to the interpreter hoping to immediately run the JITted
- # code; but instead, we Trace again, just because another
- # counter was also about to reach its limit...
- loop, = log.loops_by_filename(self.filepath, is_entry_bridge='*')
+ loop, = log.loops_by_filename(self.filepath)
assert loop.match_by_id("generator", """
- ...
- label(..., descr=...)
i16 = force_token()
p45 = new_with_vtable(ConstClass(W_IntObject))
setfield_gc(p45, i29, descr=<SignedFieldDescr .*>)
@@ -36,7 +27,7 @@
jump(..., descr=...)
""")
assert loop.match_by_id("subtract", """
- setfield_gc(p7, 35, descr=<.*last_instr .*>) # XXX bad, kill me
+ setfield_gc(p7, 35, descr=<.*last_instr .*>) # XXX bad, kill me
i2 = int_sub_ovf(i1, 42)
guard_no_overflow(descr=...)
""")
diff --git a/pypy/objspace/std/stringobject.py b/pypy/objspace/std/stringobject.py
--- a/pypy/objspace/std/stringobject.py
+++ b/pypy/objspace/std/stringobject.py
@@ -514,44 +514,41 @@
if maxsplit == 0:
return space.wrap(input)
- #print "from replace, input: %s, sub: %s, by: %s" % (input, sub, by)
+ # An ok guess at the default size
+ builder = StringBuilder(len(input))
+ first = True
if not sub:
upper = len(input)
if maxsplit > 0 and maxsplit < upper + 2:
upper = maxsplit - 1
assert upper >= 0
- substrings_w = [""]
+ first = False
for i in range(upper):
- c = input[i]
- substrings_w.append(c)
- substrings_w.append(input[upper:])
+ builder.append(by)
+ builder.append(input[i])
+ builder.append(by)
+ builder.append_slice(input, upper, len(input))
else:
start = 0
sublen = len(sub)
- substrings_w = []
while maxsplit != 0:
next = input.find(sub, start)
if next < 0:
break
- substrings_w.append(input[start:next])
+ if not first:
+ builder.append(by)
+ first = False
+ builder.append_slice(input, start, next)
start = next + sublen
maxsplit -= 1 # NB. if it's already < 0, it stays < 0
- substrings_w.append(input[start:])
+ if not first:
+ builder.append(by)
+ builder.append_slice(input, start, len(input))
- try:
- # XXX conservative estimate. If your strings are that close
- # to overflowing, bad luck.
- one = ovfcheck(len(substrings_w) * len(by))
- ovfcheck(one + len(input))
- except OverflowError:
- raise OperationError(
- space.w_OverflowError,
- space.wrap("replace string is too long"))
-
- return space.wrap(by.join(substrings_w))
+ return space.wrap(builder.build())
def str_replace__String_ANY_ANY_ANY(space, w_self, w_sub, w_by, w_maxsplit):
diff --git a/pypy/rlib/longlong2float.py b/pypy/rlib/longlong2float.py
--- a/pypy/rlib/longlong2float.py
+++ b/pypy/rlib/longlong2float.py
@@ -79,19 +79,19 @@
longlong2float = rffi.llexternal(
"pypy__longlong2float", [rffi.LONGLONG], rffi.DOUBLE,
_callable=longlong2float_emulator, compilation_info=eci,
- _nowrapper=True, elidable_function=True)
+ _nowrapper=True, elidable_function=True, sandboxsafe=True)
float2longlong = rffi.llexternal(
"pypy__float2longlong", [rffi.DOUBLE], rffi.LONGLONG,
_callable=float2longlong_emulator, compilation_info=eci,
- _nowrapper=True, elidable_function=True)
+ _nowrapper=True, elidable_function=True, sandboxsafe=True)
uint2singlefloat = rffi.llexternal(
"pypy__uint2singlefloat", [rffi.UINT], rffi.FLOAT,
_callable=uint2singlefloat_emulator, compilation_info=eci,
- _nowrapper=True, elidable_function=True)
+ _nowrapper=True, elidable_function=True, sandboxsafe=True)
singlefloat2uint = rffi.llexternal(
"pypy__singlefloat2uint", [rffi.FLOAT], rffi.UINT,
_callable=singlefloat2uint_emulator, compilation_info=eci,
- _nowrapper=True, elidable_function=True)
+ _nowrapper=True, elidable_function=True, sandboxsafe=True)
diff --git a/pypy/tool/clean_old_branches.py b/pypy/tool/clean_old_branches.py
--- a/pypy/tool/clean_old_branches.py
+++ b/pypy/tool/clean_old_branches.py
@@ -11,14 +11,17 @@
sys.exit(1)
def heads(args):
- g = os.popen(r"hg heads --topo %s --template '{branches} {node|short}\n'"
+ g = os.popen(r"hg heads --topo %s --template '{node|short}:{branches}\n'"
% args, 'r')
result = g.read()
g.close()
result = result.splitlines(False)
- result = [s for s in result
- if not s.startswith(' ')
- and not s.startswith('closed-branches ')]
+ for line in result:
+ if len(line.split(':', 1)) != 2:
+ raise ValueError("'result' contains: %r" % line)
+ result = [s.split(':', 1) for s in result]
+ result = [(head, branch) for (head, branch) in result
+ if branch not in ['', 'closed-branches']]
return result
all_heads = heads("--closed")
@@ -34,8 +37,7 @@
closed_heads.reverse()
-for branch_head in closed_heads:
- branch, head = branch_head.split()
+for head, branch in closed_heads:
print '\t', branch
print
print 'The branches listed above will be merged to "closed-branches".'
@@ -54,8 +56,7 @@
print '*** error %r' % (err,)
sys.exit(1)
-for branch_head in closed_heads:
- branch, head = branch_head.split()
+for head, branch in closed_heads:
print
print '***** %s ***** %s *****' % (branch, head)
do("hg up --clean closed-branches")
diff --git a/pypy/tool/gcc_cache.py b/pypy/tool/gcc_cache.py
--- a/pypy/tool/gcc_cache.py
+++ b/pypy/tool/gcc_cache.py
@@ -11,9 +11,6 @@
# Import 'platform' every time, the compiler may have been changed
from pypy.translator.platform import platform
cache_dir = cache_dir_root.join(cachename).ensure(dir=1)
- c_files.extend([py.path.local(f) for f in eci.separate_module_files])
- eci = ExternalCompilationInfo(**eci._copy_attributes())
- eci.separate_module_files = ()
filecontents = [c_file.read() for c_file in c_files]
key = repr((filecontents, eci, platform.key()))
hash = md5(key).hexdigest()
More information about the pypy-commit
mailing list