]> granicus.if.org Git - python/commitdiff
Issue #26146: remove useless code
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 26 Jan 2016 23:37:59 +0000 (00:37 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 26 Jan 2016 23:37:59 +0000 (00:37 +0100)
obj2ast_constant() code is baesd on obj2ast_object() which has a special case
for Py_None. But in practice, we don't need to have a special case for
constants.

Issue noticed by Joseph Jevnik on a review.

Parser/asdl_c.py
Python/Python-ast.c

index a81644d3b2299a9408753f335b5e25bbe620d6f8..17c85173f13981b48e770a13d7c96748fa0e2e78 100644 (file)
@@ -874,13 +874,6 @@ static int obj2ast_object(PyObject* obj, PyObject** out, PyArena* arena)
 
 static int obj2ast_constant(PyObject* obj, PyObject** out, PyArena* arena)
 {
-    if (obj == Py_None || obj == Py_True || obj == Py_False) {
-        /* don't increment the reference counter, Constant uses a borrowed
-         * reference, not a strong reference */
-        *out = obj;
-        return 0;
-    }
-
     if (obj) {
         if (PyArena_AddPyObject(arena, obj) < 0) {
             *out = NULL;
index 4dde11f00c18669180f7244e49a690d50e6bffda..1193c7c66beaebb632cb3d8fc4084711f83cfa4b 100644 (file)
@@ -753,13 +753,6 @@ static int obj2ast_object(PyObject* obj, PyObject** out, PyArena* arena)
 
 static int obj2ast_constant(PyObject* obj, PyObject** out, PyArena* arena)
 {
-    if (obj == Py_None || obj == Py_True || obj == Py_False) {
-        /* don't increment the reference counter, Constant uses a borrowed
-         * reference, not a strong reference */
-        *out = obj;
-        return 0;
-    }
-
     if (obj) {
         if (PyArena_AddPyObject(arena, obj) < 0) {
             *out = NULL;