[Python-checkins] cpython: use a the bool type for a boolean variable

benjamin.peterson python-checkins at python.org
Wed Sep 7 14:29:19 EDT 2016


https://hg.python.org/cpython/rev/1ef9a3021da9
changeset:   103238:1ef9a3021da9
user:        Benjamin Peterson <benjamin at python.org>
date:        Wed Sep 07 11:28:35 2016 -0700
summary:
  use a the bool type for a boolean variable

files:
  Objects/codeobject.c |  6 ++++--
  1 files changed, 4 insertions(+), 2 deletions(-)


diff --git a/Objects/codeobject.c b/Objects/codeobject.c
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -1,3 +1,5 @@
+#include <stdbool.h>
+
 #include "Python.h"
 #include "code.h"
 #include "structmember.h"
@@ -96,7 +98,7 @@
         Py_ssize_t total_args = argcount + kwonlyargcount +
             ((flags & CO_VARARGS) != 0) + ((flags & CO_VARKEYWORDS) != 0);
         Py_ssize_t alloc_size = sizeof(unsigned char) * n_cellvars;
-        int used_cell2arg = 0;
+        bool used_cell2arg = false;
         cell2arg = PyMem_MALLOC(alloc_size);
         if (cell2arg == NULL)
             return NULL;
@@ -109,7 +111,7 @@
                 PyObject *arg = PyTuple_GET_ITEM(varnames, j);
                 if (!PyUnicode_Compare(cell, arg)) {
                     cell2arg[i] = j;
-                    used_cell2arg = 1;
+                    used_cell2arg = true;
                     break;
                 }
             }

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list