[Python-checkins] cpython: Remove useless assignments

victor.stinner python-checkins at python.org
Thu May 26 14:07:52 CEST 2011


http://hg.python.org/cpython/rev/1e73b90e4d52
changeset:   70396:1e73b90e4d52
parent:      70393:12d6460fe77a
user:        Victor Stinner <victor.stinner at haypocalc.com>
date:        Thu May 26 13:47:08 2011 +0200
summary:
  Remove useless assignments

Warnings found by the the Clang Static Analyzer.

files:
  Modules/faulthandler.c |  9 ++++-----
  Python/import.c        |  4 ----
  2 files changed, 4 insertions(+), 9 deletions(-)


diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c
--- a/Modules/faulthandler.c
+++ b/Modules/faulthandler.c
@@ -1005,9 +1005,10 @@
 faulthandler_env_options(void)
 {
     PyObject *xoptions, *key, *module, *res;
-    int enable;
 
     if (!Py_GETENV("PYTHONFAULTHANDLER")) {
+        int has_key;
+
         xoptions = PySys_GetXOptions();
         if (xoptions == NULL)
             return -1;
@@ -1016,13 +1017,11 @@
         if (key == NULL)
             return -1;
 
-        enable = PyDict_Contains(xoptions, key);
+        has_key = PyDict_Contains(xoptions, key);
         Py_DECREF(key);
-        if (!enable)
+        if (!has_key)
             return 0;
     }
-    else
-        enable = 1;
 
     module = PyImport_ImportModule("faulthandler");
     if (module == NULL) {
diff --git a/Python/import.c b/Python/import.c
--- a/Python/import.c
+++ b/Python/import.c
@@ -1733,7 +1733,6 @@
     Py_UNICODE buf[MAXPATHLEN+1];
     Py_ssize_t buflen = MAXPATHLEN+1;
     PyObject *path_unicode, *filename;
-    const Py_UNICODE *base;
     Py_ssize_t len;
     struct stat statbuf;
     static struct filedescr fd_package = {"", "", PKG_DIRECTORY};
@@ -1751,7 +1750,6 @@
     else
         return 0;
 
-    base = PyUnicode_AS_UNICODE(path_unicode);
     len = PyUnicode_GET_SIZE(path_unicode);
     if (len + 2 + PyUnicode_GET_SIZE(name) + MAXSUFFIXSIZE >= buflen) {
         Py_DECREF(path_unicode);
@@ -2275,12 +2273,10 @@
 static int
 find_init_module(PyObject *directory)
 {
-    size_t len;
     struct stat statbuf;
     PyObject *filename;
     int match;
 
-    len = PyUnicode_GET_SIZE(directory);
     filename = PyUnicode_FromFormat("%U%c__init__.py", directory, SEP);
     if (filename == NULL)
         return -1;

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


More information about the Python-checkins mailing list