]> granicus.if.org Git - python/commitdiff
Implement PEP 238 in its (almost) full glory.
authorGuido van Rossum <guido@python.org>
Wed, 8 Aug 2001 05:00:18 +0000 (05:00 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 8 Aug 2001 05:00:18 +0000 (05:00 +0000)
This introduces:

- A new operator // that means floor division (the kind of division
  where 1/2 is 0).

- The "future division" statement ("from __future__ import division)
  which changes the meaning of the / operator to implement "true
  division" (where 1/2 is 0.5).

- New overloadable operators __truediv__ and __floordiv__.

- New slots in the PyNumberMethods struct for true and floor division,
  new abstract APIs for them, new opcodes, and so on.

I emphasize that without the future division statement, the semantics
of / will remain unchanged until Python 3.0.

Not yet implemented are warnings (default off) when / is used with int
or long arguments.

This has been on display since 7/31 as SF patch #443474.

Flames to /dev/null.

19 files changed:
Grammar/Grammar
Include/abstract.h
Include/compile.h
Include/object.h
Include/opcode.h
Include/pythonrun.h
Include/token.h
Lib/__future__.py
Objects/abstract.c
Objects/classobject.c
Objects/complexobject.c
Objects/floatobject.c
Objects/intobject.c
Objects/longobject.c
Parser/tokenizer.c
Python/ceval.c
Python/compile.c
Python/future.c
Python/graminit.c

index c791892dff4f0b96a306fd2a5d5e1c311a2d09d7..d85863e9a269b103416949a892e674a5b38abfb9 100644 (file)
@@ -38,7 +38,7 @@ stmt: simple_stmt | compound_stmt
 simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE
 small_stmt: expr_stmt | print_stmt  | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | exec_stmt | assert_stmt
 expr_stmt: testlist (augassign testlist | ('=' testlist)*)
-augassign: '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | '<<=' | '>>=' | '**='
+augassign: '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | '<<=' | '>>=' | '**=' | '//='
 # For normal assignments, additional restrictions enforced by the interpreter
 print_stmt: 'print' ( [ test (',' test)* [','] ] | '>>' test [ (',' test)+ [','] ] )
 del_stmt: 'del' exprlist
@@ -77,7 +77,7 @@ xor_expr: and_expr ('^' and_expr)*
 and_expr: shift_expr ('&' shift_expr)*
 shift_expr: arith_expr (('<<'|'>>') arith_expr)*
 arith_expr: term (('+'|'-') term)*
-term: factor (('*'|'/'|'%') factor)*
+term: factor (('*'|'/'|'%'|'//') factor)*
 factor: ('+'|'-'|'~') factor | power
 power: atom trailer* ('**' factor)*
 atom: '(' [testlist] ')' | '[' [listmaker] ']' | '{' [dictmaker] '}' | '`' testlist '`' | NAME | NUMBER | STRING+
index 799438e2b1dc91ed621e54ce10594511babfa10b..f4c1b3ec65b21e28d2fb0f71123f20b50fb44e7e 100644 (file)
@@ -547,6 +547,26 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
 
        */
 
+     DL_IMPORT(PyObject *) PyNumber_FloorDivide(PyObject *o1, PyObject *o2);
+
+       /*
+        Returns the result of dividing o1 by o2 giving an integral result,
+        or null on failure.
+        This is the equivalent of the Python expression: o1//o2.
+
+
+       */
+
+     DL_IMPORT(PyObject *) PyNumber_TrueDivide(PyObject *o1, PyObject *o2);
+
+       /*
+        Returns the result of dividing o1 by o2 giving a float result,
+        or null on failure.
+        This is the equivalent of the Python expression: o1/o2.
+
+
+       */
+
      DL_IMPORT(PyObject *) PyNumber_Remainder(PyObject *o1, PyObject *o2);
 
        /*
@@ -742,6 +762,28 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
 
        */
 
+     DL_IMPORT(PyObject *) PyNumber_InPlaceFloorDivide(PyObject *o1,
+                                                      PyObject *o2);
+
+       /*
+        Returns the result of dividing o1 by o2 giving an integral result,
+        possibly in-place, or null on failure.
+        This is the equivalent of the Python expression:
+        o1 /= o2.
+
+       */
+
+     DL_IMPORT(PyObject *) PyNumber_InPlaceTrueDivide(PyObject *o1,
+                                                     PyObject *o2);
+
+       /*
+        Returns the result of dividing o1 by o2 giving a float result,
+        possibly in-place, or null on failure.
+        This is the equivalent of the Python expression:
+        o1 /= o2.
+
+       */
+
      DL_IMPORT(PyObject *) PyNumber_InPlaceRemainder(PyObject *o1, PyObject *o2);
 
        /*
index 89c5ba46e06203d0dfe1a98df4f5b56c13d1fe78..e5840af8cc486ed1b46a7971b9d75ed491d89194 100644 (file)
@@ -41,6 +41,8 @@ typedef struct {
    effect, this passes on the "from __future__ import generators" state
    in effect when the code block was compiled. */
 #define CO_GENERATOR_ALLOWED    0x1000
+/* XXX Ditto for future division */
+#define CO_FUTURE_DIVISION     0x2000
 
 extern DL_IMPORT(PyTypeObject) PyCode_Type;
 
@@ -64,6 +66,7 @@ typedef struct {
     int ff_last_lineno;
     int ff_nested_scopes;
     int ff_generators;
+    int ff_division;
 } PyFutureFeatures;
 
 DL_IMPORT(PyFutureFeatures *) PyNode_Future(struct _node *, char *);
@@ -76,6 +79,9 @@ DL_IMPORT(PyCodeObject *) PyNode_CompileFlags(struct _node *, char *,
 #define GENERATORS_DEFAULT 0
 #define FUTURE_GENERATORS "generators"
 
+#define DIVISION_DEFAULT 0
+#define FUTURE_DIVISION "division"
+
 /* for internal use only */
 #define _PyCode_GETCODEPTR(co, pp) \
        ((*(co)->co_code->ob_type->tp_as_buffer->bf_getreadbuffer) \
index 9f679b03ab672c234a44a7fc6d2012946c943409..f6c6ac699626c756a7a9d8ebda4cbac3a541b4c7 100644 (file)
@@ -161,6 +161,12 @@ typedef struct {
        binaryfunc nb_inplace_and;
        binaryfunc nb_inplace_xor;
        binaryfunc nb_inplace_or;
+
+       /* The following require the Py_TPFLAGS_HAVE_CLASS flag */
+       binaryfunc nb_floor_divide;
+       binaryfunc nb_true_divide;
+       binaryfunc nb_inplace_floor_divide;
+       binaryfunc nb_inplace_true_divide;
 } PyNumberMethods;
 
 typedef struct {
@@ -396,7 +402,7 @@ given type object has a specified feature.
 /* tp_iter is defined */
 #define Py_TPFLAGS_HAVE_ITER (1L<<7)
 
-/* Experimental stuff for healing the type/class split */
+/* New members introduced by Python 2.2 exist */
 #define Py_TPFLAGS_HAVE_CLASS (1L<<8)
 
 /* Set if the type object is dynamically allocated */
index c1e83628538c704ed98106fc8bf7af6b5f35330d..950849942670f6a6686c16aa0ed5590fa473ad25 100644 (file)
@@ -29,6 +29,10 @@ extern "C" {
 #define BINARY_ADD     23
 #define BINARY_SUBTRACT        24
 #define BINARY_SUBSCR  25
+#define BINARY_FLOOR_DIVIDE 26
+#define BINARY_TRUE_DIVIDE 27
+#define INPLACE_FLOOR_DIVIDE 28
+#define INPLACE_TRUE_DIVIDE 29
 
 #define SLICE          30
 /* Also uses 31-33 */
index 7d947dffe4b6faac8ca1ccb763c355bb02fb0147..55e1ddd4eb193cc1c4c073a01a57e43a30ddadcd 100644 (file)
@@ -12,6 +12,7 @@ extern "C" {
    accordingly then. */
 #define PyCF_NESTED_SCOPES     (0x00000001UL)
 #define PyCF_GENERATORS                (0x00000002UL)
+#define PyCF_DIVISION          (0x00000004UL)
 typedef struct {
        unsigned long cf_flags;  /* bitmask of PyCF_xxx flags */
 } PyCompilerFlags;
index 77e3de7cd2e06255e4a99da6bf7f3eb7d56e0a0b..3f581065da59b96a0127fff80c52515436c1e400 100644 (file)
@@ -55,10 +55,12 @@ extern "C" {
 #define LEFTSHIFTEQUAL 45
 #define RIGHTSHIFTEQUAL        46
 #define DOUBLESTAREQUAL        47
+#define DOUBLESLASH    48
+#define DOUBLESLASHEQUAL 49
 /* Don't forget to update the table _PyParser_TokenNames in tokenizer.c! */
-#define OP             48
-#define ERRORTOKEN     49
-#define N_TOKENS       50
+#define OP             50
+#define ERRORTOKEN     51
+#define N_TOKENS       52
 
 /* Special definitions for cooperation with parser */
 
index 65416ae39109be28f06842911e64f0857e1aaca1..4cba7ed8026924554f7f875f92613f0cdb2005dd 100644 (file)
@@ -68,3 +68,4 @@ class _Feature:
 
 nested_scopes = _Feature((2, 1, 0, "beta", 1), (2, 2, 0, "alpha", 0))
 generators = _Feature((2, 2, 0, "alpha", 1), (2, 3, 0, "final", 0))
+division = _Feature((2, 2, 0, "alpha", 2), (3, 0, 0, "alpha", 0))
index a0f075f6081b84bca51a8100ff000d9340856fde..b646c362c9d2486a9a6b08bae84196081847362d 100644 (file)
@@ -564,6 +564,20 @@ PyNumber_Add(PyObject *v, PyObject *w)
        return result;
 }
 
+PyObject *
+PyNumber_FloorDivide(PyObject *v, PyObject *w)
+{
+       /* XXX tp_flags test */
+       return binary_op(v, w, NB_SLOT(nb_floor_divide), "//");
+}
+
+PyObject *
+PyNumber_TrueDivide(PyObject *v, PyObject *w)
+{
+       /* XXX tp_flags test */
+       return binary_op(v, w, NB_SLOT(nb_true_divide), "/");
+}
+
 PyObject *
 PyNumber_Remainder(PyObject *v, PyObject *w)
 {
@@ -630,6 +644,22 @@ INPLACE_BINOP(PyNumber_InPlaceRshift, nb_inplace_rshift, nb_rshift, ">>=")
 INPLACE_BINOP(PyNumber_InPlaceSubtract, nb_inplace_subtract, nb_subtract, "-=")
 INPLACE_BINOP(PyNumber_InPlaceDivide, nb_inplace_divide, nb_divide, "/=")
 
+PyObject *
+PyNumber_InPlaceFloorDivide(PyObject *v, PyObject *w)
+{
+       /* XXX tp_flags test */
+       return binary_iop(v, w, NB_SLOT(nb_inplace_floor_divide),
+                         NB_SLOT(nb_floor_divide), "//=");
+}
+
+PyObject *
+PyNumber_InPlaceTrueDivide(PyObject *v, PyObject *w)
+{
+       /* XXX tp_flags test */
+       return binary_iop(v, w, NB_SLOT(nb_inplace_true_divide),
+                         NB_SLOT(nb_true_divide), "/=");
+}
+
 PyObject *
 PyNumber_InPlaceAdd(PyObject *v, PyObject *w)
 {
index 4bad2fdb45c527e7d0bb3d23b67634a7b9f9c0fc..9c015383ac914d9bd7839e4a70c5971f5b7068bc 100644 (file)
@@ -1435,6 +1435,8 @@ BINARY(instance_mul, "mul", PyNumber_Multiply)
 BINARY(instance_div, "div", PyNumber_Divide)
 BINARY(instance_mod, "mod", PyNumber_Remainder)
 BINARY(instance_divmod, "divmod", PyNumber_Divmod)
+BINARY(instance_floordiv, "floordiv", PyNumber_FloorDivide)
+BINARY(instance_truediv, "truediv", PyNumber_TrueDivide)
 
 BINARY_INPLACE(instance_ior, "or", PyNumber_InPlaceOr)
 BINARY_INPLACE(instance_ixor, "xor", PyNumber_InPlaceXor)
@@ -1446,6 +1448,8 @@ BINARY_INPLACE(instance_isub, "sub", PyNumber_InPlaceSubtract)
 BINARY_INPLACE(instance_imul, "mul", PyNumber_InPlaceMultiply)
 BINARY_INPLACE(instance_idiv, "div", PyNumber_InPlaceDivide)
 BINARY_INPLACE(instance_imod, "mod", PyNumber_InPlaceRemainder)
+BINARY_INPLACE(instance_ifloordiv, "floordiv", PyNumber_InPlaceFloorDivide)
+BINARY_INPLACE(instance_itruediv, "truediv", PyNumber_InPlaceTrueDivide)
 
 /* Try a 3-way comparison, returning an int; v is an instance.  Return:
    -2 for an exception;
@@ -1900,6 +1904,10 @@ static PyNumberMethods instance_as_number = {
        (binaryfunc)instance_iand,              /* nb_inplace_and */
        (binaryfunc)instance_ixor,              /* nb_inplace_xor */
        (binaryfunc)instance_ior,               /* nb_inplace_or */
+       (binaryfunc)instance_floordiv,          /* nb_floor_divide */
+       (binaryfunc)instance_truediv,           /* nb_true_divide */
+       (binaryfunc)instance_ifloordiv,         /* nb_inplace_floor_divide */
+       (binaryfunc)instance_itruediv,          /* nb_inplace_true_divide */
 };
 
 PyTypeObject PyInstance_Type = {
index 9a66c0c593eda484e3912357e9850fd253003f94..5cfb3ca5c852519181a1d6d811bcf01a485bfbb6 100644 (file)
@@ -441,6 +441,21 @@ complex_pow(PyComplexObject *v, PyObject *w, PyComplexObject *z)
        return PyComplex_FromCComplex(p);
 }
 
+static PyObject *
+complex_int_div(PyComplexObject *v, PyComplexObject *w)
+{
+       PyObject *t, *r;
+       
+       t = complex_divmod(v, w);
+       if (t != NULL) {
+               r = PyTuple_GET_ITEM(t, 0);
+               Py_INCREF(r);
+               Py_DECREF(t);
+               return r;
+       }
+       return NULL;
+}
+
 static PyObject *
 complex_neg(PyComplexObject *v)
 {
@@ -859,6 +874,21 @@ static PyNumberMethods complex_as_number = {
        (unaryfunc)complex_float,               /* nb_float */
        0,                                      /* nb_oct */
        0,                                      /* nb_hex */
+       0,                                      /* nb_inplace_add */
+       0,                                      /* nb_inplace_subtract */
+       0,                                      /* nb_inplace_multiply*/
+       0,                                      /* nb_inplace_divide */
+       0,                                      /* nb_inplace_remainder */
+       0,                                      /* nb_inplace_power */
+       0,                                      /* nb_inplace_lshift */
+       0,                                      /* nb_inplace_rshift */
+       0,                                      /* nb_inplace_and */
+       0,                                      /* nb_inplace_xor */
+       0,                                      /* nb_inplace_or */
+       (binaryfunc)complex_int_div,            /* nb_floor_divide */
+       (binaryfunc)complex_div,                /* nb_true_divide */
+       0,                                      /* nb_inplace_floor_divide */
+       0,                                      /* nb_inplace_true_divide */
 };
 
 PyTypeObject PyComplex_Type = {
index df88736abae291bbdb34f52c44b64279a747ce32..34b252bf722ce48527b51248b4c713ce8c453ea4 100644 (file)
@@ -557,6 +557,21 @@ float_pow(PyObject *v, PyObject *w, PyObject *z)
        return PyFloat_FromDouble(ix);
 }
 
+static PyObject *
+float_int_div(PyObject *v, PyObject *w)
+{
+       PyObject *t, *r;
+       
+       t = float_divmod(v, w);
+       if (t != NULL) {
+               r = PyTuple_GET_ITEM(t, 0);
+               Py_INCREF(r);
+               Py_DECREF(t);
+               return r;
+       }
+       return NULL;
+}
+
 static PyObject *
 float_neg(PyFloatObject *v)
 {
@@ -678,19 +693,23 @@ static PyNumberMethods float_as_number = {
        (unaryfunc)float_int, /*nb_int*/
        (unaryfunc)float_long, /*nb_long*/
        (unaryfunc)float_float, /*nb_float*/
-       0,              /*nb_oct*/
-       0,              /*nb_hex*/
-       0,              /*nb_inplace_add*/
-       0,              /*nb_inplace_subtract*/
-       0,              /*nb_inplace_multiply*/
-       0,              /*nb_inplace_divide*/
-       0,              /*nb_inplace_remainder*/
-       0,              /*nb_inplace_power*/
-       0,              /*nb_inplace_lshift*/
-       0,              /*nb_inplace_rshift*/
-       0,              /*nb_inplace_and*/
-       0,              /*nb_inplace_xor*/
-       0,              /*nb_inplace_or*/
+       0,              /* nb_oct */
+       0,              /* nb_hex */
+       0,              /* nb_inplace_add */
+       0,              /* nb_inplace_subtract */
+       0,              /* nb_inplace_multiply */
+       0,              /* nb_inplace_divide */
+       0,              /* nb_inplace_remainder */
+       0,              /* nb_inplace_power */
+       0,              /* nb_inplace_lshift */
+       0,              /* nb_inplace_rshift */
+       0,              /* nb_inplace_and */
+       0,              /* nb_inplace_xor */
+       0,              /* nb_inplace_or */
+       float_int_div,  /* nb_floor_divide */
+       float_div,      /* nb_true_divide */
+       0,              /* nb_inplace_floor_divide */
+       0,              /* nb_inplace_true_divide */
 };
 
 PyTypeObject PyFloat_Type = {
index e5106c566aefb39a1f7ffadb3fa9e2875e94f884..f69f81ab1844cb2badf1afd8df08aa17342d9325 100644 (file)
@@ -702,6 +702,12 @@ int_or(PyIntObject *v, PyIntObject *w)
        return PyInt_FromLong(a | b);
 }
 
+static PyObject *
+int_true_divide(PyObject *v, PyObject *w)
+{
+       return PyFloat_Type.tp_as_number->nb_divide(v, w);
+}
+
 static PyObject *
 int_int(PyIntObject *v)
 {
@@ -812,6 +818,10 @@ static PyNumberMethods int_as_number = {
        0,                      /*nb_inplace_and*/
        0,                      /*nb_inplace_xor*/
        0,                      /*nb_inplace_or*/
+       (binaryfunc)int_div,    /* nb_floor_divide */
+       int_true_divide,        /* nb_true_divide */
+       0,                      /* nb_inplace_floor_divide */
+       0,                      /* nb_inplace_true_divide */
 };
 
 PyTypeObject PyInt_Type = {
index 28c3e5779387dc0391cdf1d1521b7eaa603c2767..9f7272c60a556bc70e35a72b063cbdd918961e3d 100644 (file)
@@ -1981,6 +1981,12 @@ long_or(PyObject *v, PyObject *w)
        return c;
 }
 
+static PyObject *
+long_true_divide(PyObject *v, PyObject *w)
+{
+       return PyFloat_Type.tp_as_number->nb_divide(v, w);
+}
+
 static int
 long_coerce(PyObject **pv, PyObject **pw)
 {
@@ -2092,17 +2098,21 @@ static PyNumberMethods long_as_number = {
        (unaryfunc)     long_float,     /*nb_float*/
        (unaryfunc)     long_oct,       /*nb_oct*/
        (unaryfunc)     long_hex,       /*nb_hex*/
-       0,                              /*nb_inplace_add*/
-       0,                              /*nb_inplace_subtract*/
-       0,                              /*nb_inplace_multiply*/
-       0,                              /*nb_inplace_divide*/
-       0,                              /*nb_inplace_remainder*/
-       0,                              /*nb_inplace_power*/
-       0,                              /*nb_inplace_lshift*/
-       0,                              /*nb_inplace_rshift*/
-       0,                              /*nb_inplace_and*/
-       0,                              /*nb_inplace_xor*/
-       0,                              /*nb_inplace_or*/
+       0,                              /* nb_inplace_add */
+       0,                              /* nb_inplace_subtract */
+       0,                              /* nb_inplace_multiply */
+       0,                              /* nb_inplace_divide */
+       0,                              /* nb_inplace_remainder */
+       0,                              /* nb_inplace_power */
+       0,                              /* nb_inplace_lshift */
+       0,                              /* nb_inplace_rshift */
+       0,                              /* nb_inplace_and */
+       0,                              /* nb_inplace_xor */
+       0,                              /* nb_inplace_or */
+       (binaryfunc)long_div,           /* nb_floor_divide */
+       long_true_divide,               /* nb_true_divide */
+       0,                              /* nb_inplace_floor_divide */
+       0,                              /* nb_inplace_true_divide */
 };
 
 PyTypeObject PyLong_Type = {
index b783e807844cc495d165879208a063bfcef384c4..23979690045f85ea4730b45ea57dc4b427248da2 100644 (file)
@@ -80,6 +80,8 @@ char *_PyParser_TokenNames[] = {
        "LEFTSHIFTEQUAL",
        "RIGHTSHIFTEQUAL",
        "DOUBLESTAREQUAL",
+       "DOUBLESLASH",
+       "DOUBLESLASHEQUAL",
        /* This table must match the #defines in token.h! */
        "OP",
        "<ERRORTOKEN>",
@@ -408,6 +410,7 @@ PyToken_TwoChars(int c1, int c2)
                break;
        case '/':
                switch (c2) {
+               case '/':       return DOUBLESLASH;
                case '=':       return SLASHEQUAL;
                }
                break;
@@ -469,6 +472,16 @@ PyToken_ThreeChars(int c1, int c2, int c3)
                        break;
                }
                break;
+       case '/':
+               switch (c2) {
+               case '/':
+                       switch (c3) {
+                       case '=':
+                               return DOUBLESLASHEQUAL;
+                       }
+                       break;
+               }
+               break;
        }
        return OP;
 }
index e6da9ebe1c3c663976417b71d7272e7368a91d2b..583d7e3dacc6d0186dc2f53674e5bcd63c7fea6a 100644 (file)
@@ -884,6 +884,26 @@ eval_frame(PyFrameObject *f)
                        if (x != NULL) continue;
                        break;
 
+               case BINARY_FLOOR_DIVIDE:
+                       w = POP();
+                       v = POP();
+                       x = PyNumber_FloorDivide(v, w);
+                       Py_DECREF(v);
+                       Py_DECREF(w);
+                       PUSH(x);
+                       if (x != NULL) continue;
+                       break;
+
+               case BINARY_TRUE_DIVIDE:
+                       w = POP();
+                       v = POP();
+                       x = PyNumber_TrueDivide(v, w);
+                       Py_DECREF(v);
+                       Py_DECREF(w);
+                       PUSH(x);
+                       if (x != NULL) continue;
+                       break;
+
                case BINARY_MODULO:
                        w = POP();
                        v = POP();
@@ -1051,6 +1071,26 @@ eval_frame(PyFrameObject *f)
                        if (x != NULL) continue;
                        break;
 
+               case INPLACE_FLOOR_DIVIDE:
+                       w = POP();
+                       v = POP();
+                       x = PyNumber_InPlaceFloorDivide(v, w);
+                       Py_DECREF(v);
+                       Py_DECREF(w);
+                       PUSH(x);
+                       if (x != NULL) continue;
+                       break;
+
+               case INPLACE_TRUE_DIVIDE:
+                       w = POP();
+                       v = POP();
+                       x = PyNumber_InPlaceTrueDivide(v, w);
+                       Py_DECREF(v);
+                       Py_DECREF(w);
+                       PUSH(x);
+                       if (x != NULL) continue;
+                       break;
+
                case INPLACE_MODULO:
                        w = POP();
                        v = POP();
index 31a75bd3b1dc7f504cd0dadc142eeaa55914eadd..d310e357f5902cab0e60a025667fb5826a250616 100644 (file)
@@ -1874,14 +1874,20 @@ com_term(struct compiling *c, node *n)
                        op = BINARY_MULTIPLY;
                        break;
                case SLASH:
-                       op = BINARY_DIVIDE;
+                       if (c->c_flags & CO_FUTURE_DIVISION)
+                               op = BINARY_TRUE_DIVIDE;
+                       else
+                               op = BINARY_DIVIDE;
                        break;
                case PERCENT:
                        op = BINARY_MODULO;
                        break;
+               case DOUBLESLASH:
+                       op = BINARY_FLOOR_DIVIDE;
+                       break;
                default:
                        com_error(c, PyExc_SystemError,
-                                 "com_term: operator not *, / or %");
+                                 "com_term: operator not *, /, // or %");
                        op = 255;
                }
                com_addbyte(c, op);
@@ -2475,7 +2481,14 @@ com_augassign(struct compiling *c, node *n)
        switch (STR(CHILD(CHILD(n, 1), 0))[0]) {
        case '+': opcode = INPLACE_ADD; break;
        case '-': opcode = INPLACE_SUBTRACT; break;
-       case '/': opcode = INPLACE_DIVIDE; break;
+       case '/':
+               if (STR(CHILD(CHILD(n, 1), 0))[1] == '/')
+                       opcode = INPLACE_FLOOR_DIVIDE;
+               else if (c->c_flags & CO_FUTURE_DIVISION)
+                       opcode = INPLACE_TRUE_DIVIDE;
+               else
+                       opcode = INPLACE_DIVIDE;
+               break;
        case '%': opcode = INPLACE_MODULO; break;
        case '<': opcode = INPLACE_LSHIFT; break;
        case '>': opcode = INPLACE_RSHIFT; break;
@@ -3945,7 +3958,8 @@ jcompile(node *n, char *filename, struct compiling *base,
                if (base->c_nested 
                    || (sc.c_symtable->st_cur->ste_type == TYPE_FUNCTION))
                        sc.c_nested = 1;
-               sc.c_flags |= base->c_flags & CO_GENERATOR_ALLOWED;
+               sc.c_flags |= base->c_flags & (CO_GENERATOR_ALLOWED |
+                                              CO_FUTURE_DIVISION);
        } else {
                sc.c_private = NULL;
                sc.c_future = PyNode_Future(n, filename);
@@ -3963,6 +3977,11 @@ jcompile(node *n, char *filename, struct compiling *base,
                                sc.c_future->ff_generators = 1;
                        else if (sc.c_future->ff_generators)
                                flags->cf_flags |= PyCF_GENERATORS;
+
+                       if (flags->cf_flags & PyCF_DIVISION)
+                               sc.c_future->ff_division = 1;
+                       else if (sc.c_future->ff_division)
+                               flags->cf_flags |= PyCF_DIVISION;
                }
                if (symtable_build(&sc, n) < 0) {
                        com_free(&sc);
@@ -4437,6 +4456,8 @@ symtable_update_flags(struct compiling *c, PySymtableEntryObject *ste,
                        c->c_flags |= CO_NESTED;
                if (c->c_future->ff_generators)
                        c->c_flags |= CO_GENERATOR_ALLOWED;
+               if (c->c_future->ff_division)
+                       c->c_flags |= CO_FUTURE_DIVISION;
        }
        if (ste->ste_generator)
                c->c_flags |= CO_GENERATOR;
index fc0d7482c9938ebe5db63f290d3d684ff5aea439..db62b5b251bcbd04676b8fe5e348560a5b3c0f31 100644 (file)
@@ -33,6 +33,8 @@ future_check_features(PyFutureFeatures *ff, node *n, char *filename)
                        ff->ff_nested_scopes = 1;
                } else if (strcmp(feature, FUTURE_GENERATORS) == 0) {
                        ff->ff_generators = 1;
+               } else if (strcmp(feature, FUTURE_DIVISION) == 0) {
+                       ff->ff_division = 1;
                } else if (strcmp(feature, "braces") == 0) {
                        PyErr_SetString(PyExc_SyntaxError,
                                        "not a chance");
@@ -234,6 +236,7 @@ PyNode_Future(node *n, char *filename)
        ff->ff_last_lineno = -1;
        ff->ff_nested_scopes = 0;
        ff->ff_generators = 0;
+       ff->ff_division = 0;
 
        if (future_parse(ff, n, filename) < 0) {
                PyMem_Free((void *)ff);
index a960730e88f928cd636708400d823b5eb830a113..176f62d2aad7a7b188f1afc92af5433e181c6888 100644 (file)
@@ -252,7 +252,7 @@ static state states_11[6] = {
        {1, arcs_11_4},
        {2, arcs_11_5},
 };
-static arc arcs_12_0[11] = {
+static arc arcs_12_0[12] = {
        {38, 1},
        {39, 1},
        {40, 1},
@@ -264,20 +264,21 @@ static arc arcs_12_0[11] = {
        {46, 1},
        {47, 1},
        {48, 1},
+       {49, 1},
 };
 static arc arcs_12_1[1] = {
        {0, 1},
 };
 static state states_12[2] = {
-       {11, arcs_12_0},
+       {12, arcs_12_0},
        {1, arcs_12_1},
 };
 static arc arcs_13_0[1] = {
-       {49, 1},
+       {50, 1},
 };
 static arc arcs_13_1[3] = {
        {21, 2},
-       {50, 3},
+       {51, 3},
        {0, 1},
 };
 static arc arcs_13_2[2] = {
@@ -318,10 +319,10 @@ static state states_13[9] = {
        {2, arcs_13_8},
 };
 static arc arcs_14_0[1] = {
-       {51, 1},
+       {52, 1},
 };
 static arc arcs_14_1[1] = {
-       {52, 2},
+       {53, 2},
 };
 static arc arcs_14_2[1] = {
        {0, 2},
@@ -332,7 +333,7 @@ static state states_14[3] = {
        {1, arcs_14_2},
 };
 static arc arcs_15_0[1] = {
-       {53, 1},
+       {54, 1},
 };
 static arc arcs_15_1[1] = {
        {0, 1},
@@ -342,11 +343,11 @@ static state states_15[2] = {
        {1, arcs_15_1},
 };
 static arc arcs_16_0[5] = {
-       {54, 1},
        {55, 1},
        {56, 1},
        {57, 1},
        {58, 1},
+       {59, 1},
 };
 static arc arcs_16_1[1] = {
        {0, 1},
@@ -356,7 +357,7 @@ static state states_16[2] = {
        {1, arcs_16_1},
 };
 static arc arcs_17_0[1] = {
-       {59, 1},
+       {60, 1},
 };
 static arc arcs_17_1[1] = {
        {0, 1},
@@ -366,7 +367,7 @@ static state states_17[2] = {
        {1, arcs_17_1},
 };
 static arc arcs_18_0[1] = {
-       {60, 1},
+       {61, 1},
 };
 static arc arcs_18_1[1] = {
        {0, 1},
@@ -376,7 +377,7 @@ static state states_18[2] = {
        {1, arcs_18_1},
 };
 static arc arcs_19_0[1] = {
-       {61, 1},
+       {62, 1},
 };
 static arc arcs_19_1[2] = {
        {9, 2},
@@ -391,7 +392,7 @@ static state states_19[3] = {
        {1, arcs_19_2},
 };
 static arc arcs_20_0[1] = {
-       {62, 1},
+       {63, 1},
 };
 static arc arcs_20_1[1] = {
        {9, 2},
@@ -405,7 +406,7 @@ static state states_20[3] = {
        {1, arcs_20_2},
 };
 static arc arcs_21_0[1] = {
-       {63, 1},
+       {64, 1},
 };
 static arc arcs_21_1[2] = {
        {21, 2},
@@ -438,25 +439,25 @@ static state states_21[7] = {
        {1, arcs_21_6},
 };
 static arc arcs_22_0[2] = {
-       {64, 1},
-       {66, 2},
+       {65, 1},
+       {67, 2},
 };
 static arc arcs_22_1[1] = {
-       {65, 3},
+       {66, 3},
 };
 static arc arcs_22_2[1] = {
-       {67, 4},
+       {68, 4},
 };
 static arc arcs_22_3[2] = {
        {22, 1},
        {0, 3},
 };
 static arc arcs_22_4[1] = {
-       {64, 5},
+       {65, 5},
 };
 static arc arcs_22_5[2] = {
        {23, 6},
-       {68, 7},
+       {69, 7},
 };
 static arc arcs_22_6[1] = {
        {0, 6},
@@ -466,7 +467,7 @@ static arc arcs_22_7[2] = {
        {0, 7},
 };
 static arc arcs_22_8[1] = {
-       {68, 7},
+       {69, 7},
 };
 static state states_22[9] = {
        {2, arcs_22_0},
@@ -499,7 +500,7 @@ static state states_23[4] = {
        {1, arcs_23_3},
 };
 static arc arcs_24_0[1] = {
-       {67, 1},
+       {68, 1},
 };
 static arc arcs_24_1[2] = {
        {12, 2},
@@ -521,7 +522,7 @@ static arc arcs_25_0[1] = {
        {12, 1},
 };
 static arc arcs_25_1[2] = {
-       {69, 0},
+       {70, 0},
        {0, 1},
 };
 static state states_25[2] = {
@@ -529,7 +530,7 @@ static state states_25[2] = {
        {2, arcs_25_1},
 };
 static arc arcs_26_0[1] = {
-       {70, 1},
+       {71, 1},
 };
 static arc arcs_26_1[1] = {
        {12, 2},
@@ -544,13 +545,13 @@ static state states_26[3] = {
        {2, arcs_26_2},
 };
 static arc arcs_27_0[1] = {
-       {71, 1},
+       {72, 1},
 };
 static arc arcs_27_1[1] = {
-       {72, 2},
+       {73, 2},
 };
 static arc arcs_27_2[2] = {
-       {73, 3},
+       {74, 3},
        {0, 2},
 };
 static arc arcs_27_3[1] = {
@@ -576,7 +577,7 @@ static state states_27[7] = {
        {1, arcs_27_6},
 };
 static arc arcs_28_0[1] = {
-       {74, 1},
+       {75, 1},
 };
 static arc arcs_28_1[1] = {
        {21, 2},
@@ -599,12 +600,12 @@ static state states_28[5] = {
        {1, arcs_28_4},
 };
 static arc arcs_29_0[6] = {
-       {75, 1},
        {76, 1},
        {77, 1},
        {78, 1},
-       {10, 1},
        {79, 1},
+       {10, 1},
+       {80, 1},
 };
 static arc arcs_29_1[1] = {
        {0, 1},
@@ -614,7 +615,7 @@ static state states_29[2] = {
        {1, arcs_29_1},
 };
 static arc arcs_30_0[1] = {
-       {80, 1},
+       {81, 1},
 };
 static arc arcs_30_1[1] = {
        {21, 2},
@@ -626,8 +627,8 @@ static arc arcs_30_3[1] = {
        {15, 4},
 };
 static arc arcs_30_4[3] = {
-       {81, 1},
-       {82, 5},
+       {82, 1},
+       {83, 5},
        {0, 4},
 };
 static arc arcs_30_5[1] = {
@@ -650,7 +651,7 @@ static state states_30[8] = {
        {1, arcs_30_7},
 };
 static arc arcs_31_0[1] = {
-       {83, 1},
+       {84, 1},
 };
 static arc arcs_31_1[1] = {
        {21, 2},
@@ -662,7 +663,7 @@ static arc arcs_31_3[1] = {
        {15, 4},
 };
 static arc arcs_31_4[2] = {
-       {82, 5},
+       {83, 5},
        {0, 4},
 };
 static arc arcs_31_5[1] = {
@@ -685,13 +686,13 @@ static state states_31[8] = {
        {1, arcs_31_7},
 };
 static arc arcs_32_0[1] = {
-       {84, 1},
+       {85, 1},
 };
 static arc arcs_32_1[1] = {
-       {52, 2},
+       {53, 2},
 };
 static arc arcs_32_2[1] = {
-       {73, 3},
+       {74, 3},
 };
 static arc arcs_32_3[1] = {
        {9, 4},
@@ -703,7 +704,7 @@ static arc arcs_32_5[1] = {
        {15, 6},
 };
 static arc arcs_32_6[2] = {
-       {82, 7},
+       {83, 7},
        {0, 6},
 };
 static arc arcs_32_7[1] = {
@@ -728,7 +729,7 @@ static state states_32[10] = {
        {1, arcs_32_9},
 };
 static arc arcs_33_0[1] = {
-       {85, 1},
+       {86, 1},
 };
 static arc arcs_33_1[1] = {
        {14, 2},
@@ -737,8 +738,8 @@ static arc arcs_33_2[1] = {
        {15, 3},
 };
 static arc arcs_33_3[2] = {
-       {86, 4},
-       {87, 5},
+       {87, 4},
+       {88, 5},
 };
 static arc arcs_33_4[1] = {
        {14, 6},
@@ -753,8 +754,8 @@ static arc arcs_33_7[1] = {
        {15, 9},
 };
 static arc arcs_33_8[3] = {
-       {86, 4},
-       {82, 5},
+       {87, 4},
+       {83, 5},
        {0, 8},
 };
 static arc arcs_33_9[1] = {
@@ -773,7 +774,7 @@ static state states_33[10] = {
        {1, arcs_33_9},
 };
 static arc arcs_34_0[1] = {
-       {88, 1},
+       {89, 1},
 };
 static arc arcs_34_1[2] = {
        {21, 2},
@@ -804,14 +805,14 @@ static arc arcs_35_1[1] = {
        {0, 1},
 };
 static arc arcs_35_2[1] = {
-       {89, 3},
+       {90, 3},
 };
 static arc arcs_35_3[1] = {
        {6, 4},
 };
 static arc arcs_35_4[2] = {
        {6, 4},
-       {90, 1},
+       {91, 1},
 };
 static state states_35[5] = {
        {2, arcs_35_0},
@@ -821,18 +822,18 @@ static state states_35[5] = {
        {2, arcs_35_4},
 };
 static arc arcs_36_0[2] = {
-       {91, 1},
-       {93, 2},
+       {92, 1},
+       {94, 2},
 };
 static arc arcs_36_1[2] = {
-       {92, 3},
+       {93, 3},
        {0, 1},
 };
 static arc arcs_36_2[1] = {
        {0, 2},
 };
 static arc arcs_36_3[1] = {
-       {91, 1},
+       {92, 1},
 };
 static state states_36[4] = {
        {2, arcs_36_0},
@@ -841,10 +842,10 @@ static state states_36[4] = {
        {1, arcs_36_3},
 };
 static arc arcs_37_0[1] = {
-       {94, 1},
+       {95, 1},
 };
 static arc arcs_37_1[2] = {
-       {95, 0},
+       {96, 0},
        {0, 1},
 };
 static state states_37[2] = {
@@ -852,11 +853,11 @@ static state states_37[2] = {
        {2, arcs_37_1},
 };
 static arc arcs_38_0[2] = {
-       {96, 1},
-       {97, 2},
+       {97, 1},
+       {98, 2},
 };
 static arc arcs_38_1[1] = {
-       {94, 2},
+       {95, 2},
 };
 static arc arcs_38_2[1] = {
        {0, 2},
@@ -867,10 +868,10 @@ static state states_38[3] = {
        {1, arcs_38_2},
 };
 static arc arcs_39_0[1] = {
-       {72, 1},
+       {73, 1},
 };
 static arc arcs_39_1[2] = {
-       {98, 0},
+       {99, 0},
        {0, 1},
 };
 static state states_39[2] = {
@@ -878,25 +879,25 @@ static state states_39[2] = {
        {2, arcs_39_1},
 };
 static arc arcs_40_0[10] = {
-       {99, 1},
        {100, 1},
        {101, 1},
        {102, 1},
        {103, 1},
        {104, 1},
        {105, 1},
-       {73, 1},
-       {96, 2},
-       {106, 3},
+       {106, 1},
+       {74, 1},
+       {97, 2},
+       {107, 3},
 };
 static arc arcs_40_1[1] = {
        {0, 1},
 };
 static arc arcs_40_2[1] = {
-       {73, 1},
+       {74, 1},
 };
 static arc arcs_40_3[2] = {
-       {96, 1},
+       {97, 1},
        {0, 3},
 };
 static state states_40[4] = {
@@ -906,10 +907,10 @@ static state states_40[4] = {
        {2, arcs_40_3},
 };
 static arc arcs_41_0[1] = {
-       {107, 1},
+       {108, 1},
 };
 static arc arcs_41_1[2] = {
-       {108, 0},
+       {109, 0},
        {0, 1},
 };
 static state states_41[2] = {
@@ -917,10 +918,10 @@ static state states_41[2] = {
        {2, arcs_41_1},
 };
 static arc arcs_42_0[1] = {
-       {109, 1},
+       {110, 1},
 };
 static arc arcs_42_1[2] = {
-       {110, 0},
+       {111, 0},
        {0, 1},
 };
 static state states_42[2] = {
@@ -928,10 +929,10 @@ static state states_42[2] = {
        {2, arcs_42_1},
 };
 static arc arcs_43_0[1] = {
-       {111, 1},
+       {112, 1},
 };
 static arc arcs_43_1[2] = {
-       {112, 0},
+       {113, 0},
        {0, 1},
 };
 static state states_43[2] = {
@@ -939,11 +940,11 @@ static state states_43[2] = {
        {2, arcs_43_1},
 };
 static arc arcs_44_0[1] = {
-       {113, 1},
+       {114, 1},
 };
 static arc arcs_44_1[3] = {
-       {114, 0},
-       {50, 0},
+       {115, 0},
+       {51, 0},
        {0, 1},
 };
 static state states_44[2] = {
@@ -951,11 +952,11 @@ static state states_44[2] = {
        {3, arcs_44_1},
 };
 static arc arcs_45_0[1] = {
-       {115, 1},
+       {116, 1},
 };
 static arc arcs_45_1[3] = {
-       {116, 0},
        {117, 0},
+       {118, 0},
        {0, 1},
 };
 static state states_45[2] = {
@@ -963,26 +964,27 @@ static state states_45[2] = {
        {3, arcs_45_1},
 };
 static arc arcs_46_0[1] = {
-       {118, 1},
+       {119, 1},
 };
-static arc arcs_46_1[4] = {
+static arc arcs_46_1[5] = {
        {23, 0},
-       {119, 0},
        {120, 0},
+       {121, 0},
+       {122, 0},
        {0, 1},
 };
 static state states_46[2] = {
        {1, arcs_46_0},
-       {4, arcs_46_1},
+       {5, arcs_46_1},
 };
 static arc arcs_47_0[4] = {
-       {116, 1},
        {117, 1},
-       {121, 1},
-       {122, 2},
+       {118, 1},
+       {123, 1},
+       {124, 2},
 };
 static arc arcs_47_1[1] = {
-       {118, 2},
+       {119, 2},
 };
 static arc arcs_47_2[1] = {
        {0, 2},
@@ -993,15 +995,15 @@ static state states_47[3] = {
        {1, arcs_47_2},
 };
 static arc arcs_48_0[1] = {
-       {123, 1},
+       {125, 1},
 };
 static arc arcs_48_1[3] = {
-       {124, 1},
+       {126, 1},
        {24, 2},
        {0, 1},
 };
 static arc arcs_48_2[1] = {
-       {118, 3},
+       {119, 3},
 };
 static arc arcs_48_3[2] = {
        {24, 2},
@@ -1015,24 +1017,24 @@ static state states_48[4] = {
 };
 static arc arcs_49_0[7] = {
        {16, 1},
-       {125, 2},
-       {128, 3},
-       {131, 4},
+       {127, 2},
+       {130, 3},
+       {133, 4},
        {12, 5},
-       {132, 5},
-       {133, 6},
+       {134, 5},
+       {135, 6},
 };
 static arc arcs_49_1[2] = {
        {9, 7},
        {18, 5},
 };
 static arc arcs_49_2[2] = {
-       {126, 8},
-       {127, 5},
+       {128, 8},
+       {129, 5},
 };
 static arc arcs_49_3[2] = {
-       {129, 9},
-       {130, 5},
+       {131, 9},
+       {132, 5},
 };
 static arc arcs_49_4[1] = {
        {9, 10},
@@ -1041,20 +1043,20 @@ static arc arcs_49_5[1] = {
        {0, 5},
 };
 static arc arcs_49_6[2] = {
-       {133, 6},
+       {135, 6},
        {0, 6},
 };
 static arc arcs_49_7[1] = {
        {18, 5},
 };
 static arc arcs_49_8[1] = {
-       {127, 5},
+       {129, 5},
 };
 static arc arcs_49_9[1] = {
-       {130, 5},
+       {132, 5},
 };
 static arc arcs_49_10[1] = {
-       {131, 5},
+       {133, 5},
 };
 static state states_49[11] = {
        {7, arcs_49_0},
@@ -1073,7 +1075,7 @@ static arc arcs_50_0[1] = {
        {21, 1},
 };
 static arc arcs_50_1[3] = {
-       {134, 2},
+       {136, 2},
        {22, 3},
        {0, 1},
 };
@@ -1096,7 +1098,7 @@ static state states_50[5] = {
        {2, arcs_50_4},
 };
 static arc arcs_51_0[1] = {
-       {135, 1},
+       {137, 1},
 };
 static arc arcs_51_1[2] = {
        {17, 2},
@@ -1120,15 +1122,15 @@ static state states_51[5] = {
 };
 static arc arcs_52_0[3] = {
        {16, 1},
-       {125, 2},
-       {69, 3},
+       {127, 2},
+       {70, 3},
 };
 static arc arcs_52_1[2] = {
-       {136, 4},
+       {138, 4},
        {18, 5},
 };
 static arc arcs_52_2[1] = {
-       {137, 6},
+       {139, 6},
 };
 static arc arcs_52_3[1] = {
        {12, 5},
@@ -1140,7 +1142,7 @@ static arc arcs_52_5[1] = {
        {0, 5},
 };
 static arc arcs_52_6[1] = {
-       {127, 5},
+       {129, 5},
 };
 static state states_52[7] = {
        {3, arcs_52_0},
@@ -1152,14 +1154,14 @@ static state states_52[7] = {
        {1, arcs_52_6},
 };
 static arc arcs_53_0[1] = {
-       {138, 1},
+       {140, 1},
 };
 static arc arcs_53_1[2] = {
        {22, 2},
        {0, 1},
 };
 static arc arcs_53_2[2] = {
-       {138, 1},
+       {140, 1},
        {0, 2},
 };
 static state states_53[3] = {
@@ -1168,12 +1170,12 @@ static state states_53[3] = {
        {2, arcs_53_2},
 };
 static arc arcs_54_0[3] = {
-       {69, 1},
+       {70, 1},
        {21, 2},
        {14, 3},
 };
 static arc arcs_54_1[1] = {
-       {69, 4},
+       {70, 4},
 };
 static arc arcs_54_2[2] = {
        {14, 3},
@@ -1181,14 +1183,14 @@ static arc arcs_54_2[2] = {
 };
 static arc arcs_54_3[3] = {
        {21, 5},
-       {139, 6},
+       {141, 6},
        {0, 3},
 };
 static arc arcs_54_4[1] = {
-       {69, 6},
+       {70, 6},
 };
 static arc arcs_54_5[2] = {
-       {139, 6},
+       {141, 6},
        {0, 5},
 };
 static arc arcs_54_6[1] = {
@@ -1219,14 +1221,14 @@ static state states_55[3] = {
        {1, arcs_55_2},
 };
 static arc arcs_56_0[1] = {
-       {72, 1},
+       {73, 1},
 };
 static arc arcs_56_1[2] = {
        {22, 2},
        {0, 1},
 };
 static arc arcs_56_2[2] = {
-       {72, 1},
+       {73, 1},
        {0, 2},
 };
 static state states_56[3] = {
@@ -1275,7 +1277,7 @@ static state states_58[5] = {
        {2, arcs_58_4},
 };
 static arc arcs_59_0[1] = {
-       {140, 1},
+       {142, 1},
 };
 static arc arcs_59_1[1] = {
        {12, 2},
@@ -1310,7 +1312,7 @@ static state states_59[8] = {
        {1, arcs_59_7},
 };
 static arc arcs_60_0[3] = {
-       {141, 1},
+       {143, 1},
        {23, 2},
        {24, 3},
 };
@@ -1325,7 +1327,7 @@ static arc arcs_60_3[1] = {
        {21, 6},
 };
 static arc arcs_60_4[4] = {
-       {141, 1},
+       {143, 1},
        {23, 2},
        {24, 3},
        {0, 4},
@@ -1370,8 +1372,8 @@ static state states_61[4] = {
        {1, arcs_61_3},
 };
 static arc arcs_62_0[2] = {
-       {134, 1},
-       {143, 1},
+       {136, 1},
+       {145, 1},
 };
 static arc arcs_62_1[1] = {
        {0, 1},
@@ -1381,19 +1383,19 @@ static state states_62[2] = {
        {1, arcs_62_1},
 };
 static arc arcs_63_0[1] = {
-       {84, 1},
+       {85, 1},
 };
 static arc arcs_63_1[1] = {
-       {52, 2},
+       {53, 2},
 };
 static arc arcs_63_2[1] = {
-       {73, 3},
+       {74, 3},
 };
 static arc arcs_63_3[1] = {
        {9, 4},
 };
 static arc arcs_63_4[2] = {
-       {142, 5},
+       {144, 5},
        {0, 4},
 };
 static arc arcs_63_5[1] = {
@@ -1408,13 +1410,13 @@ static state states_63[6] = {
        {1, arcs_63_5},
 };
 static arc arcs_64_0[1] = {
-       {80, 1},
+       {81, 1},
 };
 static arc arcs_64_1[1] = {
        {21, 2},
 };
 static arc arcs_64_2[2] = {
-       {142, 3},
+       {144, 3},
        {0, 2},
 };
 static arc arcs_64_3[1] = {
@@ -1428,137 +1430,137 @@ static state states_64[4] = {
 };
 static dfa dfas[65] = {
        {256, "single_input", 0, 3, states_0,
-        "\004\030\001\000\000\000\052\370\305\004\071\000\001\000\060\042\271\020"},
+        "\004\030\001\000\000\000\124\360\213\011\162\000\002\000\140\210\344\102\000"},
        {257, "file_input", 0, 2, states_1,
-        "\204\030\001\000\000\000\052\370\305\004\071\000\001\000\060\042\271\020"},
+        "\204\030\001\000\000\000\124\360\213\011\162\000\002\000\140\210\344\102\000"},
        {258, "eval_input", 0, 3, states_2,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\001\000\060\042\271\000"},
+        "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\210\344\002\000"},
        {259, "funcdef", 0, 6, states_3,
-        "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+        "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
        {260, "parameters", 0, 4, states_4,
-        "\000\000\001\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"},
        {261, "varargslist", 0, 10, states_5,
-        "\000\020\201\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+        "\000\020\201\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
        {262, "fpdef", 0, 4, states_6,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
        {263, "fplist", 0, 3, states_7,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
        {264, "stmt", 0, 2, states_8,
-        "\000\030\001\000\000\000\052\370\305\004\071\000\001\000\060\042\271\020"},
+        "\000\030\001\000\000\000\124\360\213\011\162\000\002\000\140\210\344\102\000"},
        {265, "simple_stmt", 0, 4, states_9,
-        "\000\020\001\000\000\000\052\370\305\004\000\000\001\000\060\042\271\000"},
+        "\000\020\001\000\000\000\124\360\213\011\000\000\002\000\140\210\344\002\000"},
        {266, "small_stmt", 0, 2, states_10,
-        "\000\020\001\000\000\000\052\370\305\004\000\000\001\000\060\042\271\000"},
+        "\000\020\001\000\000\000\124\360\213\011\000\000\002\000\140\210\344\002\000"},
        {267, "expr_stmt", 0, 6, states_11,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\001\000\060\042\271\000"},
+        "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\210\344\002\000"},
        {268, "augassign", 0, 2, states_12,
-        "\000\000\000\000\300\377\001\000\000\000\000\000\000\000\000\000\000\000"},
+        "\000\000\000\000\300\377\003\000\000\000\000\000\000\000\000\000\000\000\000"},
        {269, "print_stmt", 0, 9, states_13,
-        "\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000"},
+        "\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000"},
        {270, "del_stmt", 0, 3, states_14,
-        "\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000"},
+        "\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000\000"},
        {271, "pass_stmt", 0, 2, states_15,
-        "\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000"},
+        "\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000\000\000\000"},
        {272, "flow_stmt", 0, 2, states_16,
-        "\000\000\000\000\000\000\000\370\000\000\000\000\000\000\000\000\000\000"},
+        "\000\000\000\000\000\000\000\360\001\000\000\000\000\000\000\000\000\000\000"},
        {273, "break_stmt", 0, 2, states_17,
-        "\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000"},
+        "\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000"},
        {274, "continue_stmt", 0, 2, states_18,
-        "\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000"},
+        "\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000"},
        {275, "return_stmt", 0, 3, states_19,
-        "\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000"},
+        "\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000\000\000"},
        {276, "yield_stmt", 0, 3, states_20,
-        "\000\000\000\000\000\000\000\100\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"},
        {277, "raise_stmt", 0, 7, states_21,
-        "\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\001\000\000\000\000\000\000\000\000\000\000"},
        {278, "import_stmt", 0, 9, states_22,
-        "\000\000\000\000\000\000\000\000\005\000\000\000\000\000\000\000\000\000"},
+        "\000\000\000\000\000\000\000\000\012\000\000\000\000\000\000\000\000\000\000"},
        {279, "import_as_name", 0, 4, states_23,
-        "\000\020\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+        "\000\020\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
        {280, "dotted_as_name", 0, 4, states_24,
-        "\000\020\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+        "\000\020\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
        {281, "dotted_name", 0, 2, states_25,
-        "\000\020\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+        "\000\020\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
        {282, "global_stmt", 0, 3, states_26,
-        "\000\000\000\000\000\000\000\000\100\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"},
        {283, "exec_stmt", 0, 7, states_27,
-        "\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\001\000\000\000\000\000\000\000\000\000"},
        {284, "assert_stmt", 0, 5, states_28,
-        "\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000"},
+        "\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000"},
        {285, "compound_stmt", 0, 2, states_29,
-        "\000\010\000\000\000\000\000\000\000\000\071\000\000\000\000\000\000\020"},
+        "\000\010\000\000\000\000\000\000\000\000\162\000\000\000\000\000\000\100\000"},
        {286, "if_stmt", 0, 8, states_30,
-        "\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\002\000\000\000\000\000\000\000\000"},
        {287, "while_stmt", 0, 8, states_31,
-        "\000\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000"},
+        "\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000"},
        {288, "for_stmt", 0, 10, states_32,
-        "\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000"},
+        "\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000"},
        {289, "try_stmt", 0, 10, states_33,
-        "\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000"},
+        "\000\000\000\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000"},
        {290, "except_clause", 0, 5, states_34,
-        "\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\002\000\000\000\000\000\000\000"},
        {291, "suite", 0, 5, states_35,
-        "\004\020\001\000\000\000\052\370\305\004\000\000\001\000\060\042\271\000"},
+        "\004\020\001\000\000\000\124\360\213\011\000\000\002\000\140\210\344\002\000"},
        {292, "test", 0, 4, states_36,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\001\000\060\042\271\000"},
+        "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\210\344\002\000"},
        {293, "and_test", 0, 2, states_37,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\001\000\060\042\071\000"},
+        "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\210\344\000\000"},
        {294, "not_test", 0, 3, states_38,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\001\000\060\042\071\000"},
+        "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\210\344\000\000"},
        {295, "comparison", 0, 2, states_39,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\060\042\071\000"},
+        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\140\210\344\000\000"},
        {296, "comp_op", 0, 4, states_40,
-        "\000\000\000\000\000\000\000\000\000\002\000\000\371\007\000\000\000\000"},
+        "\000\000\000\000\000\000\000\000\000\004\000\000\362\017\000\000\000\000\000"},
        {297, "expr", 0, 2, states_41,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\060\042\071\000"},
+        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\140\210\344\000\000"},
        {298, "xor_expr", 0, 2, states_42,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\060\042\071\000"},
+        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\140\210\344\000\000"},
        {299, "and_expr", 0, 2, states_43,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\060\042\071\000"},
+        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\140\210\344\000\000"},
        {300, "shift_expr", 0, 2, states_44,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\060\042\071\000"},
+        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\140\210\344\000\000"},
        {301, "arith_expr", 0, 2, states_45,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\060\042\071\000"},
+        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\140\210\344\000\000"},
        {302, "term", 0, 2, states_46,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\060\042\071\000"},
+        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\140\210\344\000\000"},
        {303, "factor", 0, 3, states_47,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\060\042\071\000"},
+        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\140\210\344\000\000"},
        {304, "power", 0, 4, states_48,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\000\040\071\000"},
+        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\000\200\344\000\000"},
        {305, "atom", 0, 11, states_49,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\000\040\071\000"},
+        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\000\200\344\000\000"},
        {306, "listmaker", 0, 5, states_50,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\001\000\060\042\271\000"},
+        "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\210\344\002\000"},
        {307, "lambdef", 0, 5, states_51,
-        "\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\002\000"},
        {308, "trailer", 0, 7, states_52,
-        "\000\000\001\000\000\000\000\000\040\000\000\000\000\000\000\040\000\000"},
+        "\000\000\001\000\000\000\000\000\100\000\000\000\000\000\000\200\000\000\000"},
        {309, "subscriptlist", 0, 3, states_53,
-        "\000\120\001\000\000\000\000\000\040\000\000\000\001\000\060\042\271\000"},
+        "\000\120\001\000\000\000\000\000\100\000\000\000\002\000\140\210\344\002\000"},
        {310, "subscript", 0, 7, states_54,
-        "\000\120\001\000\000\000\000\000\040\000\000\000\001\000\060\042\271\000"},
+        "\000\120\001\000\000\000\000\000\100\000\000\000\002\000\140\210\344\002\000"},
        {311, "sliceop", 0, 3, states_55,
-        "\000\100\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+        "\000\100\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
        {312, "exprlist", 0, 3, states_56,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\060\042\071\000"},
+        "\000\020\001\000\000\000\000\000\000\000\000\000\000\000\140\210\344\000\000"},
        {313, "testlist", 0, 3, states_57,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\001\000\060\042\271\000"},
+        "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\210\344\002\000"},
        {314, "dictmaker", 0, 5, states_58,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\001\000\060\042\271\000"},
+        "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\210\344\002\000"},
        {315, "classdef", 0, 8, states_59,
-        "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\020"},
+        "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\100\000"},
        {316, "arglist", 0, 8, states_60,
-        "\000\020\201\001\000\000\000\000\000\000\000\000\001\000\060\042\271\000"},
+        "\000\020\201\001\000\000\000\000\000\000\000\000\002\000\140\210\344\002\000"},
        {317, "argument", 0, 4, states_61,
-        "\000\020\001\000\000\000\000\000\000\000\000\000\001\000\060\042\271\000"},
+        "\000\020\001\000\000\000\000\000\000\000\000\000\002\000\140\210\344\002\000"},
        {318, "list_iter", 0, 2, states_62,
-        "\000\000\000\000\000\000\000\000\000\000\021\000\000\000\000\000\000\000"},
+        "\000\000\000\000\000\000\000\000\000\000\042\000\000\000\000\000\000\000\000"},
        {319, "list_for", 0, 6, states_63,
-        "\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000"},
+        "\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000"},
        {320, "list_if", 0, 4, states_64,
-        "\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\002\000\000\000\000\000\000\000\000"},
 };
-static label labels[144] = {
+static label labels[146] = {
        {0, "EMPTY"},
        {256, 0},
        {4, 0},
@@ -1608,6 +1610,7 @@ static label labels[144] = {
        {45, 0},
        {46, 0},
        {47, 0},
+       {49, 0},
        {1, "print"},
        {35, 0},
        {1, "del"},
@@ -1680,6 +1683,7 @@ static label labels[144] = {
        {303, 0},
        {17, 0},
        {24, 0},
+       {48, 0},
        {32, 0},
        {304, 0},
        {305, 0},
@@ -1707,6 +1711,6 @@ static label labels[144] = {
 grammar _PyParser_Grammar = {
        65,
        dfas,
-       {144, labels},
+       {146, labels},
        256
 };