[New-bugs-announce] [issue17738] Unnecessary "if" in SHA1_copy

Jonas Wagner report at bugs.python.org
Mon Apr 15 16:10:24 CEST 2013


New submission from Jonas Wagner:

I'm puzzled by the following code in SHA1_copy (at python/Modules/sha1module.c:320

    if (Py_TYPE(self) == &SHA1type) {
        if ( (newobj = newSHA1object())==NULL)
            return NULL;
    } else {
        if ( (newobj = newSHA1object())==NULL)
            return NULL;
    }

Both branches of the if-statement are identical; it would seem that the if is unnecessary. Its condition does not have any side effect. Attached is a patch that simplifies the code.

This code happened to be at Line 316, and was thus discovered by random sampling. [1]

[1] http://www-cs-faculty.stanford.edu/~uno/316.html

----------
components: Extension Modules
files: sha1copy.patch
keywords: patch
messages: 186992
nosy: Sjlver
priority: normal
severity: normal
status: open
title: Unnecessary "if" in SHA1_copy
versions: Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5
Added file: http://bugs.python.org/file29866/sha1copy.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17738>
_______________________________________


More information about the New-bugs-announce mailing list