Author: Amaury Forgeot d'Arc <[email protected]>
Branch: split-ast-classes
Changeset: r65026:0ae5aec118b1
Date: 2013-06-26 23:21 +0200
http://bitbucket.org/pypy/pypy/changeset/0ae5aec118b1/
Log: Fix last failures
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
@@ -87,12 +87,15 @@
space.wrap("_fields")))
num_fields = len(fields_w) if fields_w else 0
if args_w and len(args_w) != num_fields:
- if num_fields:
+ if num_fields == 0:
raise operationerrfmt(space.w_TypeError,
- "_ast.%T constructor takes either 0 or %d positional
arguments", w_self, num_fields)
+ "%T constructor takes 0 positional arguments", w_self)
+ elif num_fields == 1:
+ raise operationerrfmt(space.w_TypeError,
+ "%T constructor takes either 0 or %d positional argument",
w_self, num_fields)
else:
raise operationerrfmt(space.w_TypeError,
- "_ast.%T constructor takes 0 positional arguments", w_self)
+ "%T constructor takes either 0 or %d positional arguments",
w_self, num_fields)
if args_w:
for i, w_field in enumerate(fields_w):
space.setattr(w_self, w_field, args_w[i])
@@ -100,10 +103,9 @@
space.setattr(w_self, space.wrap(field), w_value)
-W_AST.typedef = typedef.TypeDef("AST",
+W_AST.typedef = typedef.TypeDef("_ast.AST",
_fields=_FieldsWrapper([]),
_attributes=_FieldsWrapper([]),
- __module__='_ast',
__reduce__=interp2app(W_AST.reduce_w),
__setstate__=interp2app(W_AST.setstate_w),
__dict__ = typedef.GetSetProperty(typedef.descr_get_dict,
@@ -397,7 +399,7 @@
w_decorator_list = get_field(space, w_node, 'decorator_list', False)
w_lineno = get_field(space, w_node, 'lineno', False)
w_col_offset = get_field(space, w_node, 'col_offset', False)
- _name = space.str_w(w_name)
+ _name = space.realstr_w(w_name)
_args = arguments.from_object(space, w_args)
body_w = space.unpackiterable(w_body)
_body = [stmt.from_object(space, w_item) for w_item in body_w]
@@ -467,7 +469,7 @@
w_decorator_list = get_field(space, w_node, 'decorator_list', False)
w_lineno = get_field(space, w_node, 'lineno', False)
w_col_offset = get_field(space, w_node, 'col_offset', False)
- _name = space.str_w(w_name)
+ _name = space.realstr_w(w_name)
bases_w = space.unpackiterable(w_bases)
_bases = [expr.from_object(space, w_item) for w_item in bases_w]
body_w = space.unpackiterable(w_body)
@@ -1340,7 +1342,7 @@
w_lineno = get_field(space, w_node, 'lineno', False)
w_col_offset = get_field(space, w_node, 'col_offset', False)
names_w = space.unpackiterable(w_names)
- _names = [space.str_w(w_item) for w_item in names_w]
+ _names = [space.realstr_w(w_item) for w_item in names_w]
_lineno = space.int_w(w_lineno)
_col_offset = space.int_w(w_col_offset)
return Global(_names, _lineno, _col_offset)
@@ -2365,7 +2367,7 @@
w_lineno = get_field(space, w_node, 'lineno', False)
w_col_offset = get_field(space, w_node, 'col_offset', False)
_value = expr.from_object(space, w_value)
- _attr = space.str_w(w_attr)
+ _attr = space.realstr_w(w_attr)
_ctx = expr_context.from_object(space, w_ctx)
_lineno = space.int_w(w_lineno)
_col_offset = space.int_w(w_col_offset)
@@ -2452,7 +2454,7 @@
w_ctx = get_field(space, w_node, 'ctx', False)
w_lineno = get_field(space, w_node, 'lineno', False)
w_col_offset = get_field(space, w_node, 'col_offset', False)
- _id = space.str_w(w_id)
+ _id = space.realstr_w(w_id)
_ctx = expr_context.from_object(space, w_ctx)
_lineno = space.int_w(w_lineno)
_col_offset = space.int_w(w_col_offset)
@@ -3285,7 +3287,7 @@
def from_object(space, w_node):
w_arg = get_field(space, w_node, 'arg', False)
w_value = get_field(space, w_node, 'value', False)
- _arg = space.str_w(w_arg)
+ _arg = space.realstr_w(w_arg)
_value = expr.from_object(space, w_value)
return keyword(_arg, _value)
@@ -3315,7 +3317,7 @@
def from_object(space, w_node):
w_name = get_field(space, w_node, 'name', False)
w_asname = get_field(space, w_node, 'asname', True)
- _name = space.str_w(w_name)
+ _name = space.realstr_w(w_name)
_asname = space.str_or_None_w(w_asname)
return alias(_name, _asname)
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
@@ -144,7 +144,7 @@
elif field.type.value in ("identifier",):
if field.opt:
return "space.str_or_None_w(%s)" % (value,)
- return "space.str_w(%s)" % (value,)
+ return "space.realstr_w(%s)" % (value,)
elif field.type.value in ("int",):
return "space.int_w(%s)" % (value,)
elif field.type.value in ("bool",):
@@ -469,12 +469,15 @@
space.wrap("_fields")))
num_fields = len(fields_w) if fields_w else 0
if args_w and len(args_w) != num_fields:
- if num_fields:
+ if num_fields == 0:
raise operationerrfmt(space.w_TypeError,
- "_ast.%T constructor takes either 0 or %d positional
arguments", w_self, num_fields)
+ "%T constructor takes 0 positional arguments", w_self)
+ elif num_fields == 1:
+ raise operationerrfmt(space.w_TypeError,
+ "%T constructor takes either 0 or %d positional argument",
w_self, num_fields)
else:
raise operationerrfmt(space.w_TypeError,
- "_ast.%T constructor takes 0 positional arguments", w_self)
+ "%T constructor takes either 0 or %d positional arguments",
w_self, num_fields)
if args_w:
for i, w_field in enumerate(fields_w):
space.setattr(w_self, w_field, args_w[i])
@@ -482,10 +485,9 @@
space.setattr(w_self, space.wrap(field), w_value)
-W_AST.typedef = typedef.TypeDef("AST",
+W_AST.typedef = typedef.TypeDef("_ast.AST",
_fields=_FieldsWrapper([]),
_attributes=_FieldsWrapper([]),
- __module__='_ast',
__reduce__=interp2app(W_AST.reduce_w),
__setstate__=interp2app(W_AST.setstate_w),
__dict__ = typedef.GetSetProperty(typedef.descr_get_dict,
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit