Index: Python/ceval.c =================================================================== --- Python/ceval.c (revision 46648) +++ Python/ceval.c (working copy) @@ -1040,14 +1040,6 @@ STACKADJ(-1); break; - case UNARY_CONVERT: - v = TOP(); - x = PyObject_Repr(v); - Py_DECREF(v); - SET_TOP(x); - if (x != NULL) continue; - break; - case UNARY_INVERT: v = TOP(); x = PyNumber_Invert(v); Index: Python/graminit.c =================================================================== --- Python/graminit.c (revision 46648) +++ Python/graminit.c (working copy) @@ -1243,68 +1243,59 @@ {1, arcs_60_2}, {1, arcs_60_3}, }; -static arc arcs_61_0[7] = { +static arc arcs_61_0[6] = { {13, 1}, {145, 2}, {148, 3}, + {19, 4}, {151, 4}, - {19, 5}, - {153, 5}, - {154, 6}, + {152, 5}, }; static arc arcs_61_1[3] = { - {43, 7}, - {144, 7}, - {15, 5}, + {43, 6}, + {144, 6}, + {15, 4}, }; static arc arcs_61_2[2] = { - {146, 8}, - {147, 5}, + {146, 7}, + {147, 4}, }; static arc arcs_61_3[2] = { - {149, 9}, - {150, 5}, + {149, 8}, + {150, 4}, }; static arc arcs_61_4[1] = { - {152, 10}, + {0, 4}, }; -static arc arcs_61_5[1] = { +static arc arcs_61_5[2] = { + {152, 5}, {0, 5}, }; -static arc arcs_61_6[2] = { - {154, 6}, - {0, 6}, +static arc arcs_61_6[1] = { + {15, 4}, }; static arc arcs_61_7[1] = { - {15, 5}, + {147, 4}, }; static arc arcs_61_8[1] = { - {147, 5}, + {150, 4}, }; -static arc arcs_61_9[1] = { - {150, 5}, -}; -static arc arcs_61_10[1] = { - {151, 5}, -}; -static state states_61[11] = { - {7, arcs_61_0}, +static state states_61[9] = { + {6, arcs_61_0}, {3, arcs_61_1}, {2, arcs_61_2}, {2, arcs_61_3}, {1, arcs_61_4}, - {1, arcs_61_5}, - {2, arcs_61_6}, + {2, arcs_61_5}, + {1, arcs_61_6}, {1, arcs_61_7}, {1, arcs_61_8}, - {1, arcs_61_9}, - {1, arcs_61_10}, }; static arc arcs_62_0[1] = { {26, 1}, }; static arc arcs_62_1[3] = { - {155, 2}, + {153, 2}, {27, 3}, {0, 1}, }; @@ -1330,7 +1321,7 @@ {26, 1}, }; static arc arcs_63_1[3] = { - {156, 2}, + {154, 2}, {27, 3}, {0, 1}, }; @@ -1385,7 +1376,7 @@ {15, 5}, }; static arc arcs_65_2[1] = { - {157, 6}, + {155, 6}, }; static arc arcs_65_3[1] = { {19, 5}, @@ -1409,14 +1400,14 @@ {1, arcs_65_6}, }; static arc arcs_66_0[1] = { - {158, 1}, + {156, 1}, }; static arc arcs_66_1[2] = { {27, 2}, {0, 1}, }; static arc arcs_66_2[2] = { - {158, 1}, + {156, 1}, {0, 2}, }; static state states_66[3] = { @@ -1438,14 +1429,14 @@ }; static arc arcs_67_3[3] = { {26, 5}, - {159, 6}, + {157, 6}, {0, 3}, }; static arc arcs_67_4[1] = { {75, 6}, }; static arc arcs_67_5[2] = { - {159, 6}, + {157, 6}, {0, 5}, }; static arc arcs_67_6[1] = { @@ -1532,7 +1523,7 @@ {2, arcs_71_4}, }; static arc arcs_72_0[1] = { - {160, 1}, + {158, 1}, }; static arc arcs_72_1[1] = { {19, 2}, @@ -1568,7 +1559,7 @@ {1, arcs_72_7}, }; static arc arcs_73_0[3] = { - {161, 1}, + {159, 1}, {28, 2}, {29, 3}, }; @@ -1583,7 +1574,7 @@ {26, 6}, }; static arc arcs_73_4[4] = { - {161, 1}, + {159, 1}, {28, 2}, {29, 3}, {0, 4}, @@ -1612,7 +1603,7 @@ {26, 1}, }; static arc arcs_74_1[3] = { - {156, 2}, + {154, 2}, {25, 3}, {0, 1}, }; @@ -1629,8 +1620,8 @@ {1, arcs_74_3}, }; static arc arcs_75_0[2] = { - {155, 1}, - {163, 1}, + {153, 1}, + {161, 1}, }; static arc arcs_75_1[1] = { {0, 1}, @@ -1652,7 +1643,7 @@ {104, 4}, }; static arc arcs_76_4[2] = { - {162, 5}, + {160, 5}, {0, 4}, }; static arc arcs_76_5[1] = { @@ -1673,7 +1664,7 @@ {105, 2}, }; static arc arcs_77_2[2] = { - {162, 3}, + {160, 3}, {0, 2}, }; static arc arcs_77_3[1] = { @@ -1686,8 +1677,8 @@ {1, arcs_77_3}, }; static arc arcs_78_0[2] = { - {156, 1}, - {165, 1}, + {154, 1}, + {163, 1}, }; static arc arcs_78_1[1] = { {0, 1}, @@ -1709,7 +1700,7 @@ {106, 4}, }; static arc arcs_79_4[2] = { - {164, 5}, + {162, 5}, {0, 4}, }; static arc arcs_79_5[1] = { @@ -1730,7 +1721,7 @@ {105, 2}, }; static arc arcs_80_2[2] = { - {164, 3}, + {162, 3}, {0, 2}, }; static arc arcs_80_3[1] = { @@ -1764,7 +1755,7 @@ {1, arcs_82_1}, }; static arc arcs_83_0[1] = { - {167, 1}, + {166, 1}, }; static arc arcs_83_1[2] = { {9, 2}, @@ -1780,11 +1771,11 @@ }; static dfa dfas[84] = { {256, "single_input", 0, 3, states_0, - "\004\050\014\000\000\000\000\025\074\005\023\310\011\020\004\000\300\020\222\006\201"}, + "\004\050\014\000\000\000\000\025\074\005\023\310\011\020\004\000\300\020\222\101\100"}, {257, "file_input", 0, 2, states_1, - "\204\050\014\000\000\000\000\025\074\005\023\310\011\020\004\000\300\020\222\006\201"}, + "\204\050\014\000\000\000\000\025\074\005\023\310\011\020\004\000\300\020\222\101\100"}, {258, "eval_input", 0, 3, states_2, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\006\000"}, + "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\001\000"}, {259, "decorator", 0, 7, states_3, "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {260, "decorators", 0, 2, states_4, @@ -1800,13 +1791,13 @@ {265, "fplist", 0, 3, states_9, "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {266, "stmt", 0, 2, states_10, - "\000\050\014\000\000\000\000\025\074\005\023\310\011\020\004\000\300\020\222\006\201"}, + "\000\050\014\000\000\000\000\025\074\005\023\310\011\020\004\000\300\020\222\101\100"}, {267, "simple_stmt", 0, 4, states_11, - "\000\040\010\000\000\000\000\025\074\005\023\000\000\020\004\000\300\020\222\006\200"}, + "\000\040\010\000\000\000\000\025\074\005\023\000\000\020\004\000\300\020\222\001\100"}, {268, "small_stmt", 0, 2, states_12, - "\000\040\010\000\000\000\000\025\074\005\023\000\000\020\004\000\300\020\222\006\200"}, + "\000\040\010\000\000\000\000\025\074\005\023\000\000\020\004\000\300\020\222\001\100"}, {269, "expr_stmt", 0, 6, states_13, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\006\000"}, + "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\001\000"}, {270, "augassign", 0, 2, states_14, "\000\000\000\000\000\360\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {271, "print_stmt", 0, 9, states_15, @@ -1816,7 +1807,7 @@ {273, "pass_stmt", 0, 2, states_17, "\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {274, "flow_stmt", 0, 2, states_18, - "\000\000\000\000\000\000\000\000\074\000\000\000\000\000\000\000\000\000\000\000\200"}, + "\000\000\000\000\000\000\000\000\074\000\000\000\000\000\000\000\000\000\000\000\100"}, {275, "break_stmt", 0, 2, states_19, "\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000"}, {276, "continue_stmt", 0, 2, states_20, @@ -1824,7 +1815,7 @@ {277, "return_stmt", 0, 3, states_21, "\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000\000"}, {278, "yield_stmt", 0, 2, states_22, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\200"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\100"}, {279, "raise_stmt", 0, 7, states_23, "\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000"}, {280, "import_stmt", 0, 2, states_24, @@ -1850,7 +1841,7 @@ {290, "assert_stmt", 0, 5, states_34, "\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000"}, {291, "compound_stmt", 0, 2, states_35, - "\000\010\004\000\000\000\000\000\000\000\000\310\011\000\000\000\000\000\000\000\001"}, + "\000\010\004\000\000\000\000\000\000\000\000\310\011\000\000\000\000\000\000\100\000"}, {292, "if_stmt", 0, 8, states_36, "\000\000\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000"}, {293, "while_stmt", 0, 8, states_37, @@ -1866,69 +1857,69 @@ {298, "except_clause", 0, 5, states_42, "\000\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000"}, {299, "suite", 0, 5, states_43, - "\004\040\010\000\000\000\000\025\074\005\023\000\000\020\004\000\300\020\222\006\200"}, + "\004\040\010\000\000\000\000\025\074\005\023\000\000\020\004\000\300\020\222\001\100"}, {300, "testlist_safe", 0, 5, states_44, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\006\000"}, + "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\001\000"}, {301, "old_test", 0, 2, states_45, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\006\000"}, + "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\001\000"}, {302, "old_lambdef", 0, 5, states_46, "\000\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000"}, {303, "test", 0, 6, states_47, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\006\000"}, + "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\001\000"}, {304, "or_test", 0, 2, states_48, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\004\000\300\020\222\006\000"}, + "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\004\000\300\020\222\001\000"}, {305, "and_test", 0, 2, states_49, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\004\000\300\020\222\006\000"}, + "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\004\000\300\020\222\001\000"}, {306, "not_test", 0, 3, states_50, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\004\000\300\020\222\006\000"}, + "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\004\000\300\020\222\001\000"}, {307, "comparison", 0, 2, states_51, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\300\020\222\006\000"}, + "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\300\020\222\001\000"}, {308, "comp_op", 0, 4, states_52, "\000\000\000\000\000\000\000\000\000\000\010\000\000\000\344\037\000\000\000\000\000"}, {309, "expr", 0, 2, states_53, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\300\020\222\006\000"}, + "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\300\020\222\001\000"}, {310, "xor_expr", 0, 2, states_54, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\300\020\222\006\000"}, + "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\300\020\222\001\000"}, {311, "and_expr", 0, 2, states_55, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\300\020\222\006\000"}, + "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\300\020\222\001\000"}, {312, "shift_expr", 0, 2, states_56, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\300\020\222\006\000"}, + "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\300\020\222\001\000"}, {313, "arith_expr", 0, 2, states_57, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\300\020\222\006\000"}, + "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\300\020\222\001\000"}, {314, "term", 0, 2, states_58, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\300\020\222\006\000"}, + "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\300\020\222\001\000"}, {315, "factor", 0, 3, states_59, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\300\020\222\006\000"}, + "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\300\020\222\001\000"}, {316, "power", 0, 4, states_60, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\222\006\000"}, - {317, "atom", 0, 11, states_61, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\222\006\000"}, + "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\222\001\000"}, + {317, "atom", 0, 9, states_61, + "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\222\001\000"}, {318, "listmaker", 0, 5, states_62, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\006\000"}, + "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\001\000"}, {319, "testlist_gexp", 0, 5, states_63, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\006\000"}, + "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\001\000"}, {320, "lambdef", 0, 5, states_64, "\000\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000"}, {321, "trailer", 0, 7, states_65, "\000\040\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\002\000\000"}, {322, "subscriptlist", 0, 3, states_66, - "\000\040\050\000\000\000\000\000\000\010\000\000\000\020\004\000\300\020\222\006\000"}, + "\000\040\050\000\000\000\000\000\000\010\000\000\000\020\004\000\300\020\222\001\000"}, {323, "subscript", 0, 7, states_67, - "\000\040\050\000\000\000\000\000\000\010\000\000\000\020\004\000\300\020\222\006\000"}, + "\000\040\050\000\000\000\000\000\000\010\000\000\000\020\004\000\300\020\222\001\000"}, {324, "sliceop", 0, 3, states_68, "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {325, "exprlist", 0, 3, states_69, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\300\020\222\006\000"}, + "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\300\020\222\001\000"}, {326, "testlist", 0, 3, states_70, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\006\000"}, + "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\001\000"}, {327, "dictmaker", 0, 5, states_71, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\006\000"}, + "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\001\000"}, {328, "classdef", 0, 8, states_72, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\100\000"}, {329, "arglist", 0, 8, states_73, - "\000\040\010\060\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\006\000"}, + "\000\040\010\060\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\001\000"}, {330, "argument", 0, 4, states_74, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\006\000"}, + "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\001\000"}, {331, "list_iter", 0, 2, states_75, "\000\000\000\000\000\000\000\000\000\000\000\210\000\000\000\000\000\000\000\000\000"}, {332, "list_for", 0, 6, states_76, @@ -1942,13 +1933,13 @@ {336, "gen_if", 0, 4, states_80, "\000\000\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000"}, {337, "testlist1", 0, 2, states_81, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\006\000"}, + "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\001\000"}, {338, "encoding_decl", 0, 2, states_82, "\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {339, "yield_expr", 0, 3, states_83, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\200"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\100"}, }; -static label labels[168] = { +static label labels[167] = { {0, "EMPTY"}, {256, 0}, {4, 0}, @@ -2100,8 +2091,6 @@ {26, 0}, {327, 0}, {27, 0}, - {25, 0}, - {337, 0}, {2, 0}, {3, 0}, {332, 0}, @@ -2115,12 +2104,13 @@ {333, 0}, {334, 0}, {336, 0}, + {337, 0}, {338, 0}, {1, "yield"}, }; grammar _PyParser_Grammar = { 84, dfas, - {168, labels}, + {167, labels}, 256 }; Index: Python/ast.c =================================================================== --- Python/ast.c (revision 46648) +++ Python/ast.c (working copy) @@ -398,9 +398,6 @@ case Compare_kind: expr_name = "comparison"; break; - case Repr_kind: - expr_name = "repr"; - break; case IfExp_kind: expr_name = "conditional expression"; break; @@ -1270,13 +1267,6 @@ } return Dict(keys, values, LINENO(n), n->n_col_offset, c->c_arena); } - case BACKQUOTE: { /* repr */ - expr_ty expression = ast_for_testlist(c, CHILD(n, 1)); - if (!expression) - return NULL; - - return Repr(expression, LINENO(n), n->n_col_offset, c->c_arena); - } default: PyErr_Format(PyExc_SystemError, "unhandled atom %d", TYPE(ch)); return NULL; Index: Python/symtable.c =================================================================== --- Python/symtable.c (revision 46648) +++ Python/symtable.c (working copy) @@ -1150,9 +1150,6 @@ if (e->v.Call.kwargs) VISIT(st, expr, e->v.Call.kwargs); break; - case Repr_kind: - VISIT(st, expr, e->v.Repr.value); - break; case Num_kind: case Str_kind: /* Nothing to do here. */ Index: Python/compile.c =================================================================== --- Python/compile.c (revision 46648) +++ Python/compile.c (working copy) @@ -571,9 +571,6 @@ if (PyObject_IsTrue(v) == 1) newconst = PyNumber_Negative(v); break; - case UNARY_CONVERT: - newconst = PyObject_Repr(v); - break; case UNARY_INVERT: newconst = PyNumber_Invert(v); break; @@ -850,7 +847,6 @@ /* Fold unary ops on constants. LOAD_CONST c1 UNARY_OP --> LOAD_CONST unary_op(c) */ case UNARY_NEGATIVE: - case UNARY_CONVERT: case UNARY_INVERT: if (lastlc >= 1 && ISBASICBLOCK(blocks, i-3, 4) && @@ -1303,7 +1299,6 @@ case UNARY_POSITIVE: case UNARY_NEGATIVE: case UNARY_NOT: - case UNARY_CONVERT: case UNARY_INVERT: return 0; @@ -3543,10 +3538,6 @@ return compiler_compare(c, e); case Call_kind: return compiler_call(c, e); - case Repr_kind: - VISIT(c, expr, e->v.Repr.value); - ADDOP(c, UNARY_CONVERT); - break; case Num_kind: ADDOP_O(c, LOAD_CONST, e->v.Num.n, consts); break; Index: Python/Python-ast.c =================================================================== --- Python/Python-ast.c (revision 46648) +++ Python/Python-ast.c (working copy) @@ -206,10 +206,6 @@ "starargs", "kwargs", }; -static PyTypeObject *Repr_type; -static char *Repr_fields[]={ - "value", -}; static PyTypeObject *Num_type; static char *Num_fields[]={ "n", @@ -532,8 +528,6 @@ if (!Compare_type) return 0; Call_type = make_type("Call", expr_type, Call_fields, 5); if (!Call_type) return 0; - Repr_type = make_type("Repr", expr_type, Repr_fields, 1); - if (!Repr_type) return 0; Num_type = make_type("Num", expr_type, Num_fields, 1); if (!Num_type) return 0; Str_type = make_type("Str", expr_type, Str_fields, 1); @@ -1553,27 +1547,6 @@ } expr_ty -Repr(expr_ty value, int lineno, int col_offset, PyArena *arena) -{ - expr_ty p; - if (!value) { - PyErr_SetString(PyExc_ValueError, - "field value is required for Repr"); - return NULL; - } - p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); - if (!p) { - PyErr_NoMemory(); - return NULL; - } - p->kind = Repr_kind; - p->v.Repr.value = value; - p->lineno = lineno; - p->col_offset = col_offset; - return p; -} - -expr_ty Num(object n, int lineno, int col_offset, PyArena *arena) { expr_ty p; @@ -2544,15 +2517,6 @@ goto failed; Py_DECREF(value); break; - case Repr_kind: - result = PyType_GenericNew(Repr_type, NULL, NULL); - if (!result) goto failed; - value = ast2obj_expr(o->v.Repr.value); - if (!value) goto failed; - if (PyObject_SetAttrString(result, "value", value) == -1) - goto failed; - Py_DECREF(value); - break; case Num_kind: result = PyType_GenericNew(Num_type, NULL, NULL); if (!result) goto failed; @@ -3113,7 +3077,6 @@ if (PyDict_SetItemString(d, "Compare", (PyObject*)Compare_type) < 0) return; if (PyDict_SetItemString(d, "Call", (PyObject*)Call_type) < 0) return; - if (PyDict_SetItemString(d, "Repr", (PyObject*)Repr_type) < 0) return; if (PyDict_SetItemString(d, "Num", (PyObject*)Num_type) < 0) return; if (PyDict_SetItemString(d, "Str", (PyObject*)Str_type) < 0) return; if (PyDict_SetItemString(d, "Attribute", (PyObject*)Attribute_type) < Index: Include/opcode.h =================================================================== --- Include/opcode.h (revision 46648) +++ Include/opcode.h (working copy) @@ -18,7 +18,6 @@ #define UNARY_POSITIVE 10 #define UNARY_NEGATIVE 11 #define UNARY_NOT 12 -#define UNARY_CONVERT 13 #define UNARY_INVERT 15 Index: Include/Python-ast.h =================================================================== --- Include/Python-ast.h (revision 46648) +++ Include/Python-ast.h (working copy) @@ -186,9 +186,8 @@ enum _expr_kind {BoolOp_kind=1, BinOp_kind=2, UnaryOp_kind=3, Lambda_kind=4, IfExp_kind=5, Dict_kind=6, ListComp_kind=7, GeneratorExp_kind=8, Yield_kind=9, Compare_kind=10, - Call_kind=11, Repr_kind=12, Num_kind=13, Str_kind=14, - Attribute_kind=15, Subscript_kind=16, Name_kind=17, - List_kind=18, Tuple_kind=19}; + Call_kind=11, Num_kind=12, Str_kind=13, Attribute_kind=14, + Subscript_kind=15, Name_kind=16, List_kind=17, Tuple_kind=18}; struct _expr { enum _expr_kind kind; union { @@ -253,10 +252,6 @@ } Call; struct { - expr_ty value; - } Repr; - - struct { object n; } Num; @@ -414,7 +409,6 @@ expr_ty Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty starargs, expr_ty kwargs, int lineno, int col_offset, PyArena *arena); -expr_ty Repr(expr_ty value, int lineno, int col_offset, PyArena *arena); expr_ty Num(object n, int lineno, int col_offset, PyArena *arena); expr_ty Str(string s, int lineno, int col_offset, PyArena *arena); expr_ty Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int Index: Grammar/Grammar =================================================================== --- Grammar/Grammar (revision 46648) +++ Grammar/Grammar (working copy) @@ -102,7 +102,6 @@ atom: ('(' [yield_expr|testlist_gexp] ')' | '[' [listmaker] ']' | '{' [dictmaker] '}' | - '`' testlist1 '`' | NAME | NUMBER | STRING+) listmaker: test ( list_for | (',' test)* [','] ) testlist_gexp: test ( gen_for | (',' test)* [','] ) Index: Parser/Python.asdl =================================================================== --- Parser/Python.asdl (revision 46648) +++ Parser/Python.asdl (working copy) @@ -65,7 +65,6 @@ | Compare(expr left, cmpop* ops, expr* comparators) | Call(expr func, expr* args, keyword* keywords, expr? starargs, expr? kwargs) - | Repr(expr value) | Num(object n) -- a number as a PyObject. | Str(string s) -- need to specify raw, unicode, etc? -- other literals? bools? Index: Lib/compiler/pycodegen.py =================================================================== --- Lib/compiler/pycodegen.py (revision 46648) +++ Lib/compiler/pycodegen.py (working copy) @@ -1211,9 +1211,6 @@ def visitNot(self, node): return self.unaryOp(node, 'UNARY_NOT') - def visitBackquote(self, node): - return self.unaryOp(node, 'UNARY_CONVERT') - # bit ops def bitOp(self, nodes, op): Index: Lib/compiler/ast.py =================================================================== --- Lib/compiler/ast.py (revision 46648) +++ Lib/compiler/ast.py (working copy) @@ -203,20 +203,6 @@ def __repr__(self): return "AugAssign(%s, %s, %s)" % (repr(self.node), repr(self.op), repr(self.expr)) -class Backquote(Node): - def __init__(self, expr, lineno=None): - self.expr = expr - self.lineno = lineno - - def getChildren(self): - return self.expr, - - def getChildNodes(self): - return self.expr, - - def __repr__(self): - return "Backquote(%s)" % (repr(self.expr),) - class Bitand(Node): def __init__(self, nodes, lineno=None): self.nodes = nodes Index: Lib/opcode.py =================================================================== --- Lib/opcode.py (revision 46648) +++ Lib/opcode.py (working copy) @@ -54,7 +54,6 @@ def_op('UNARY_POSITIVE', 10) def_op('UNARY_NEGATIVE', 11) def_op('UNARY_NOT', 12) -def_op('UNARY_CONVERT', 13) def_op('UNARY_INVERT', 15) Index: Lib/test/test_site.py =================================================================== --- Lib/test/test_site.py (revision 46648) +++ Lib/test/test_site.py (working copy) @@ -164,7 +164,7 @@ site.abs__file__() for module in (sys, os, __builtin__): try: - self.failUnless(os.path.isabs(module.__file__), `module`) + self.failUnless(os.path.isabs(module.__file__), repr(module)) except AttributeError: continue # We could try everything in sys.modules; however, when regrtest.py Index: Lib/test/test_syntax.py =================================================================== --- Lib/test/test_syntax.py (revision 46648) +++ Lib/test/test_syntax.py (working copy) @@ -69,10 +69,6 @@ Traceback (most recent call last): SyntaxError: can't assign to literal (, line 1) ->>> `1` = 1 -Traceback (most recent call last): -SyntaxError: can't assign to repr (, line 1) - If the left-hand side of an assignment is a list or tuple, an illegal expression inside that contain should still cause a syntax error. This test just checks a couple of cases rather than enumerating all of @@ -80,22 +76,22 @@ >>> (a, "b", c) = (1, 2, 3) Traceback (most recent call last): -SyntaxError: can't assign to literal (, line 1) +SyntaxError: can't assign to literal (, line 1) >>> [a, b, c + 1] = [1, 2, 3] Traceback (most recent call last): -SyntaxError: can't assign to operator (, line 1) +SyntaxError: can't assign to operator (, line 1) >>> a if 1 else b = 1 Traceback (most recent call last): -SyntaxError: can't assign to conditional expression (, line 1) +SyntaxError: can't assign to conditional expression (, line 1) From compiler_complex_args(): >>> def f(None=1): ... pass Traceback (most recent call last): -SyntaxError: assignment to None (, line 1) +SyntaxError: assignment to None (, line 1) From ast_for_arguments(): @@ -103,22 +99,22 @@ >>> def f(x, y=1, z): ... pass Traceback (most recent call last): -SyntaxError: non-default argument follows default argument (, line 1) +SyntaxError: non-default argument follows default argument (, line 1) >>> def f(x, None): ... pass Traceback (most recent call last): -SyntaxError: assignment to None (, line 1) +SyntaxError: assignment to None (, line 1) >>> def f(*None): ... pass Traceback (most recent call last): -SyntaxError: assignment to None (, line 1) +SyntaxError: assignment to None (, line 1) >>> def f(**None): ... pass Traceback (most recent call last): -SyntaxError: assignment to None (, line 1) +SyntaxError: assignment to None (, line 1) From ast_for_funcdef(): @@ -126,7 +122,7 @@ >>> def None(x): ... pass Traceback (most recent call last): -SyntaxError: assignment to None (, line 1) +SyntaxError: assignment to None (, line 1) From ast_for_call(): @@ -138,7 +134,7 @@ [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> f(x for x in L, 1) Traceback (most recent call last): -SyntaxError: Generator expression must be parenthesized if not sole argument (, line 1) +SyntaxError: Generator expression must be parenthesized if not sole argument (, line 1) >>> f((x for x in L), 1) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] @@ -170,7 +166,7 @@ ... i244, i245, i246, i247, i248, i249, i250, i251, i252, ... i253, i254, i255) Traceback (most recent call last): -SyntaxError: more than 255 arguments (, line 1) +SyntaxError: more than 255 arguments (, line 1) The actual error cases counts positional arguments, keyword arguments, and generator expression arguments separately. This test combines the @@ -204,37 +200,43 @@ ... (x for x in i244), i245, i246, i247, i248, i249, i250, i251, ... i252=1, i253=1, i254=1, i255=1) Traceback (most recent call last): -SyntaxError: more than 255 arguments (, line 1) +SyntaxError: more than 255 arguments (, line 1) >>> f(lambda x: x[0] = 3) Traceback (most recent call last): -SyntaxError: lambda cannot contain assignment (, line 1) +SyntaxError: lambda cannot contain assignment (, line 1) The grammar accepts any test (basically, any expression) in the keyword slot of a call site. Test a few different options. >>> f(x()=2) Traceback (most recent call last): -SyntaxError: keyword can't be an expression (, line 1) +SyntaxError: keyword can't be an expression (, line 1) >>> f(a or b=1) Traceback (most recent call last): -SyntaxError: keyword can't be an expression (, line 1) +SyntaxError: keyword can't be an expression (, line 1) >>> f(x.y=1) Traceback (most recent call last): -SyntaxError: keyword can't be an expression (, line 1) +SyntaxError: keyword can't be an expression (, line 1) From ast_for_expr_stmt(): >>> (x for x in x) += 1 Traceback (most recent call last): -SyntaxError: augmented assignment to generator expression not possible (, line 1) +SyntaxError: augmented assignment to generator expression not possible (, line 1) >>> None += 1 Traceback (most recent call last): -SyntaxError: assignment to None (, line 1) +SyntaxError: assignment to None (, line 1) >>> f() += 1 Traceback (most recent call last): -SyntaxError: illegal expression for augmented assignment (, line 1) +SyntaxError: illegal expression for augmented assignment (, line 1) + +Make sure the backticks really are gone: + +>>> `5` +Traceback (most recent call last): +SyntaxError: invalid syntax """ import re Index: Lib/test/list_tests.py =================================================================== --- Lib/test/list_tests.py (revision 46648) +++ Lib/test/list_tests.py (working copy) @@ -37,7 +37,7 @@ self.assertEqual(str(a0), str(l0)) self.assertEqual(repr(a0), repr(l0)) - self.assertEqual(`a2`, `l2`) + self.assertEqual(repr(a2), repr(l2)) self.assertEqual(str(a2), "[0, 1, 2]") self.assertEqual(repr(a2), "[0, 1, 2]") Index: Lib/test/test_doctest.py =================================================================== --- Lib/test/test_doctest.py (revision 46648) +++ Lib/test/test_doctest.py (working copy) @@ -637,7 +637,7 @@ ... if isinstance(piece, doctest.Example): ... print 'Example:', (piece.source, piece.want, piece.lineno) ... else: - ... print ' Text:', `piece` + ... print ' Text:', repr(piece) Text: '\n' Example: ('x, y = 2, 3 # no output expected\n', '', 1) Text: '' Index: Lib/test/test_rfc822.py =================================================================== --- Lib/test/test_rfc822.py (revision 46648) +++ Lib/test/test_rfc822.py (working copy) @@ -46,9 +46,9 @@ continue i = i + 1 self.assertEqual(mn, n, - "Un-expected name: %s != %s" % (`mn`, `n`)) + "Un-expected name: %s != %s" % (repr(mn), repr(n))) self.assertEqual(ma, a, - "Un-expected address: %s != %s" % (`ma`, `a`)) + "Un-expected address: %s != %s" % (repr(ma), repr(a))) if mn == n and ma == a: pass else: Index: Lib/test/test_peepholer.py =================================================================== --- Lib/test/test_peepholer.py (revision 46648) +++ Lib/test/test_peepholer.py (working copy) @@ -135,7 +135,6 @@ def test_folding_of_unaryops_on_constants(self): for line, elem in ( - ('`1`', "('1')"), # unary convert ('-0.5', '(-0.5)'), # unary negative ('~-2', '(1)'), # unary invert ): Index: Lib/test/test_grammar.py =================================================================== --- Lib/test/test_grammar.py (revision 46648) +++ Lib/test/test_grammar.py (working copy) @@ -681,7 +681,7 @@ print 'atoms' -### atom: '(' [testlist] ')' | '[' [testlist] ']' | '{' [dictmaker] '}' | '`' testlist '`' | NAME | NUMBER | STRING +### atom: '(' [testlist] ')' | '[' [testlist] ']' | '{' [dictmaker] '}' | NAME | NUMBER | STRING ### dictmaker: test ':' test (',' test ':' test)* [','] x = (1) @@ -702,8 +702,6 @@ x = {'one': 1, 'two': 2,} x = {'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5, 'six': 6} -x = `x` -x = `1 or 2 or 3` x = x x = 'x' x = 123 Index: Lib/test/test_mutants.py =================================================================== --- Lib/test/test_mutants.py (revision 46648) +++ Lib/test/test_mutants.py (working copy) @@ -202,7 +202,7 @@ # Tim sez: "luck of the draw; crashes with or without for me." print >> f - return `"machiavelli"` + return repr("machiavelli") def __hash__(self): return 0 Index: Lib/test/test_weakref.py =================================================================== --- Lib/test/test_weakref.py (revision 46648) +++ Lib/test/test_weakref.py (working copy) @@ -51,10 +51,10 @@ # Live reference: o = C() wr = weakref.ref(o) - `wr` + repr(wr) # Dead reference: del o - `wr` + repr(wr) def test_basic_callback(self): self.check_basic_callback(C) Index: Lib/test/test_userdict.py =================================================================== --- Lib/test/test_userdict.py (revision 46648) +++ Lib/test/test_userdict.py (working copy) @@ -46,7 +46,6 @@ # Test __repr__ self.assertEqual(str(u0), str(d0)) self.assertEqual(repr(u1), repr(d1)) - self.assertEqual(`u2`, `d2`) # Test __cmp__ and __len__ all = [d0, d1, d2, u, u0, u1, u2, uu, uu0, uu1, uu2] Index: Lib/test/test_ast.py =================================================================== --- Lib/test/test_ast.py (revision 46648) +++ Lib/test/test_ast.py (working copy) @@ -94,8 +94,6 @@ "1 < 2 < 3", # Call "f(1,2,c=3,*d,**e)", - # Repr - "`v`", # Num "10L", # Str @@ -191,7 +189,6 @@ ('Expression', ('GeneratorExp', (1, 1), ('Name', (1, 1), 'a', ('Load',)), [('comprehension', ('Name', (1, 7), 'b', ('Store',)), ('Name', (1, 12), 'c', ('Load',)), [('Name', (1, 17), 'd', ('Load',))])])), ('Expression', ('Compare', (1, 0), ('Num', (1, 0), 1), [('Lt',), ('Lt',)], [('Num', (1, 4), 2), ('Num', (1, 8), 3)])), ('Expression', ('Call', (1, 0), ('Name', (1, 0), 'f', ('Load',)), [('Num', (1, 2), 1), ('Num', (1, 4), 2)], [('keyword', 'c', ('Num', (1, 8), 3))], ('Name', (1, 11), 'd', ('Load',)), ('Name', (1, 15), 'e', ('Load',)))), -('Expression', ('Repr', (1, 0), ('Name', (1, 1), 'v', ('Load',)))), ('Expression', ('Num', (1, 0), 10L)), ('Expression', ('Str', (1, 0), 'string')), ('Expression', ('Attribute', (1, 0), ('Name', (1, 0), 'a', ('Load',)), 'b', ('Load',))),