Skip to content

Commit 25219f5

Browse files
committed
Issue python#26146: remove useless code
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.
1 parent 726f690 commit 25219f5

2 files changed

Lines changed: 0 additions & 14 deletions

File tree

Parser/asdl_c.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -874,13 +874,6 @@ def visitModule(self, mod):
874874
875875
static int obj2ast_constant(PyObject* obj, PyObject** out, PyArena* arena)
876876
{
877-
if (obj == Py_None || obj == Py_True || obj == Py_False) {
878-
/* don't increment the reference counter, Constant uses a borrowed
879-
* reference, not a strong reference */
880-
*out = obj;
881-
return 0;
882-
}
883-
884877
if (obj) {
885878
if (PyArena_AddPyObject(arena, obj) < 0) {
886879
*out = NULL;

Python/Python-ast.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -753,13 +753,6 @@ static int obj2ast_object(PyObject* obj, PyObject** out, PyArena* arena)
753753

754754
static int obj2ast_constant(PyObject* obj, PyObject** out, PyArena* arena)
755755
{
756-
if (obj == Py_None || obj == Py_True || obj == Py_False) {
757-
/* don't increment the reference counter, Constant uses a borrowed
758-
* reference, not a strong reference */
759-
*out = obj;
760-
return 0;
761-
}
762-
763756
if (obj) {
764757
if (PyArena_AddPyObject(arena, obj) < 0) {
765758
*out = NULL;

0 commit comments

Comments
 (0)