The following issues were found

Python/compile.c
4 issues
There is an unknown macro here somewhere. Configuration is required. If _Py_IDENTIFIER is a macro then please configure it.
Error

Line: 2274

              
       Return 0 on error, -1 if no annotations pushed, 1 if a annotations is pushed.
       */
    _Py_IDENTIFIER(return);
    Py_ssize_t annotations_len = 0;

    if (!compiler_visit_argannotations(c, args->args, &annotations_len))
        return 0;
    if (!compiler_visit_argannotations(c, args->posonlyargs, &annotations_len))

            

Reported by Cppcheck.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 6872 Column: 5 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                      PyErr_NoMemory();
        return NULL;
    }
    memcpy(copy, stack, sizeof(ExceptStack));
    return copy;
}

static int
label_exception_targets(basicblock *entry) {

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 7537 Column: 5 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

                  const char *jrel = (is_relative_jump(i)) ? "jrel " : "";
    const char *jabs = (is_jump(i) && !is_relative_jump(i))? "jabs " : "";

    char arg[128];

    *arg = '\0';
    if (HAS_ARG(i->i_opcode)) {
        sprintf(arg, "arg: %d ", i->i_oparg);
    }

            

Reported by FlawFinder.

sprintf - Does not check for buffer overflows
Security

Line: 7541 Column: 9 CWE codes: 120
Suggestion: Use sprintf_s, snprintf, or vsnprintf

              
    *arg = '\0';
    if (HAS_ARG(i->i_opcode)) {
        sprintf(arg, "arg: %d ", i->i_oparg);
    }
    fprintf(stderr, "line: %d, opcode: %d %s%s%s\n",
                    i->i_lineno, i->i_opcode, arg, jabs, jrel);
}


            

Reported by FlawFinder.

Modules/_blake2/impl/blake2bp.c
4 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 108 Column: 5 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                {
    uint8_t block[BLAKE2B_BLOCKBYTES];
    memset( block, 0, BLAKE2B_BLOCKBYTES );
    memcpy( block, key, keylen );

    for( size_t i = 0; i < PARALLELISM_DEGREE; ++i )
      blake2b_update( S->S[i], block, BLAKE2B_BLOCKBYTES );

    secure_zero_memory( block, BLAKE2B_BLOCKBYTES ); /* Burn the key from stack */

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 126 Column: 5 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

              
  if( left && inlen >= fill )
  {
    memcpy( S->buf + left, in, fill );

    for( size_t i = 0; i < PARALLELISM_DEGREE; ++i )
      blake2b_update( S->S[i], S->buf + i * BLAKE2B_BLOCKBYTES, BLAKE2B_BLOCKBYTES );

    in += fill;

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 162 Column: 5 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                inlen %= PARALLELISM_DEGREE * BLAKE2B_BLOCKBYTES;

  if( inlen > 0 )
    memcpy( S->buf + left, in, inlen );

  S->buflen = ( uint32_t ) left + ( uint32_t ) inlen;
  return 0;
}


            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 223 Column: 5 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                {
    uint8_t block[BLAKE2B_BLOCKBYTES];
    memset( block, 0, BLAKE2B_BLOCKBYTES );
    memcpy( block, key, keylen );

    for( size_t i = 0; i < PARALLELISM_DEGREE; ++i )
      blake2b_update( S[i], block, BLAKE2B_BLOCKBYTES );

    secure_zero_memory( block, BLAKE2B_BLOCKBYTES ); /* Burn the key from stack */

            

Reported by FlawFinder.

Lib/distutils/tests/test_bdist.py
4 issues
Missing class docstring
Error

Line: 13 Column: 1

                  from distutils.tests import support


class BuildTestCase(support.TempdirManager,
                    unittest.TestCase):

    def test_formats(self):
        # let's create a command and make sure
        # we can set the format

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 16 Column: 5

              class BuildTestCase(support.TempdirManager,
                    unittest.TestCase):

    def test_formats(self):
        # let's create a command and make sure
        # we can set the format
        dist = self.create_dist()[1]
        cmd = bdist(dist)
        cmd.formats = ['msi']

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 31 Column: 5

                      found = sorted(cmd.format_command)
        self.assertEqual(found, formats)

    def test_skip_build(self):
        # bug #10946: bdist --skip-build should trickle down to subcommands
        dist = self.create_dist()[1]
        cmd = bdist(dist)
        cmd.skip_build = 1
        cmd.ensure_finalized()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 52 Column: 1

                                          '%s should take --skip-build from bdist' % name)


def test_suite():
    return unittest.makeSuite(BuildTestCase)

if __name__ == '__main__':
    run_unittest(test_suite())

            

Reported by Pylint.

Doc/includes/sqlite3/complete_statement.py
4 issues
Missing module docstring
Error

Line: 1 Column: 1

              # A minimal SQLite shell for experiments

import sqlite3

con = sqlite3.connect(":memory:")
con.isolation_level = None
cur = con.cursor()

buffer = ""

            

Reported by Pylint.

Constant name "buffer" doesn't conform to UPPER_CASE naming style
Error

Line: 9 Column: 1

              con.isolation_level = None
cur = con.cursor()

buffer = ""

print("Enter your SQL commands to execute in sqlite3.")
print("Enter a blank line to exit.")

while True:

            

Reported by Pylint.

Variable name "e" doesn't conform to snake_case naming style
Error

Line: 26 Column: 9

              
            if buffer.lstrip().upper().startswith("SELECT"):
                print(cur.fetchall())
        except sqlite3.Error as e:
            print("An error occurred:", e.args[0])
        buffer = ""

con.close()

            

Reported by Pylint.

Constant name "buffer" doesn't conform to UPPER_CASE naming style
Error

Line: 28 Column: 9

                              print(cur.fetchall())
        except sqlite3.Error as e:
            print("An error occurred:", e.args[0])
        buffer = ""

con.close()

            

Reported by Pylint.

Lib/distutils/dep_util.py
4 issues
Else clause on loop without a break statement
Error

Line: 89 Column: 5

                      source_mtime = os.stat(source)[ST_MTIME]
        if source_mtime > target_mtime:
            return 1
    else:
        return 0

# newer_group ()

            

Reported by Pylint.

Import outside toplevel (stat.ST_MTIME)
Error

Line: 23 Column: 5

                  if not os.path.exists(target):
        return 1

    from stat import ST_MTIME
    mtime1 = os.stat(source)[ST_MTIME]
    mtime2 = os.stat(target)[ST_MTIME]

    return mtime1 > mtime2


            

Reported by Pylint.

Consider using enumerate instead of iterating with range and len
Error

Line: 44 Column: 5

                  # build a pair of lists (sources, targets) where  source is newer
    n_sources = []
    n_targets = []
    for i in range(len(sources)):
        if newer(sources[i], targets[i]):
            n_sources.append(sources[i])
            n_targets.append(targets[i])

    return (n_sources, n_targets)

            

Reported by Pylint.

Import outside toplevel (stat.ST_MTIME)
Error

Line: 75 Column: 5

                  # is more recent than 'target', then 'target' is out-of-date and
    # we can immediately return true.  If we fall through to the end
    # of the loop, then 'target' is up-to-date and we return false.
    from stat import ST_MTIME
    target_mtime = os.stat(target)[ST_MTIME]
    for source in sources:
        if not os.path.exists(source):
            if missing == 'error':      # blow up when we stat() the file
                pass

            

Reported by Pylint.

Lib/idlelib/idle_test/test_editmenu.py
4 issues
Import "import tkinter as tk" should be placed at the top of the module
Error

Line: 7 Column: 1

              '''
from test.support import requires
requires('gui')
import tkinter as tk
from tkinter import ttk
import unittest
from idlelib import pyshell

class PasteTest(unittest.TestCase):

            

Reported by Pylint.

Import "from tkinter import ttk" should be placed at the top of the module
Error

Line: 8 Column: 1

              from test.support import requires
requires('gui')
import tkinter as tk
from tkinter import ttk
import unittest
from idlelib import pyshell

class PasteTest(unittest.TestCase):
    '''Test pasting into widgets that allow pasting.

            

Reported by Pylint.

Import "import unittest" should be placed at the top of the module
Error

Line: 9 Column: 1

              requires('gui')
import tkinter as tk
from tkinter import ttk
import unittest
from idlelib import pyshell

class PasteTest(unittest.TestCase):
    '''Test pasting into widgets that allow pasting.


            

Reported by Pylint.

Import "from idlelib import pyshell" should be placed at the top of the module
Error

Line: 10 Column: 1

              import tkinter as tk
from tkinter import ttk
import unittest
from idlelib import pyshell

class PasteTest(unittest.TestCase):
    '''Test pasting into widgets that allow pasting.

    On X11, replacing selections requires tk fix.

            

Reported by Pylint.

Lib/ctypes/test/test_macholib.py
4 issues
Missing module docstring
Error

Line: 1 Column: 1

              import os
import sys
import unittest

# Bob Ippolito:
#
# Ok.. the code to find the filename for __getattr__ should look
# something like:
#

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 36 Column: 1

              
from ctypes.macholib.dyld import dyld_find

def find_lib(name):
    possible = ['lib'+name+'.dylib', name+'.dylib', name+'.framework/'+name]
    for dylib in possible:
        try:
            return os.path.realpath(dyld_find(dylib))
        except ValueError:

            

Reported by Pylint.

Missing class docstring
Error

Line: 45 Column: 1

                          pass
    raise ValueError("%s not found" % (name,))

class MachOTest(unittest.TestCase):
    @unittest.skipUnless(sys.platform == "darwin", 'OSX-specific test')
    def test_find(self):
        # On Mac OS 11, system dylibs are only present in the shared cache,
        # so symlinks like libpthread.dylib -> libSystem.B.dylib will not
        # be resolved by dyld_find

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 47 Column: 5

              
class MachOTest(unittest.TestCase):
    @unittest.skipUnless(sys.platform == "darwin", 'OSX-specific test')
    def test_find(self):
        # On Mac OS 11, system dylibs are only present in the shared cache,
        # so symlinks like libpthread.dylib -> libSystem.B.dylib will not
        # be resolved by dyld_find
        self.assertIn(find_lib('pthread'),
                              ('/usr/lib/libSystem.B.dylib', '/usr/lib/libpthread.dylib'))

            

Reported by Pylint.

Lib/distutils/tests/test_build.py
4 issues
Unused variable 'pkg_dir'
Error

Line: 16 Column: 9

                                  unittest.TestCase):

    def test_finalize_options(self):
        pkg_dir, dist = self.create_dist()
        cmd = build(dist)
        cmd.finalize_options()

        # if not specified, plat_name gets the current platform
        self.assertEqual(cmd.plat_name, get_platform())

            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

              from distutils.tests import support
from sysconfig import get_platform

class BuildTestCase(support.TempdirManager,
                    support.LoggingSilencer,
                    unittest.TestCase):

    def test_finalize_options(self):
        pkg_dir, dist = self.create_dist()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 15 Column: 5

                                  support.LoggingSilencer,
                    unittest.TestCase):

    def test_finalize_options(self):
        pkg_dir, dist = self.create_dist()
        cmd = build(dist)
        cmd.finalize_options()

        # if not specified, plat_name gets the current platform

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 52 Column: 1

                      # executable is os.path.normpath(sys.executable)
        self.assertEqual(cmd.executable, os.path.normpath(sys.executable))

def test_suite():
    return unittest.makeSuite(BuildTestCase)

if __name__ == "__main__":
    run_unittest(test_suite())

            

Reported by Pylint.

Lib/ctypes/test/test_objects.py
4 issues
Unused variable 'tests'
Error

Line: 63 Column: 19

              
class TestCase(unittest.TestCase):
    def test(self):
        failures, tests = doctest.testmod(ctypes.test.test_objects)
        self.assertFalse(failures, 'doctests failed, see output above')

if __name__ == '__main__':
    doctest.testmod(ctypes.test.test_objects)

            

Reported by Pylint.

Multiple imports on one line (unittest, doctest)
Error

Line: 57 Column: 1

              
'''

import unittest, doctest

import ctypes.test.test_objects

class TestCase(unittest.TestCase):
    def test(self):

            

Reported by Pylint.

Missing class docstring
Error

Line: 61 Column: 1

              
import ctypes.test.test_objects

class TestCase(unittest.TestCase):
    def test(self):
        failures, tests = doctest.testmod(ctypes.test.test_objects)
        self.assertFalse(failures, 'doctests failed, see output above')

if __name__ == '__main__':

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 62 Column: 5

              import ctypes.test.test_objects

class TestCase(unittest.TestCase):
    def test(self):
        failures, tests = doctest.testmod(ctypes.test.test_objects)
        self.assertFalse(failures, 'doctests failed, see output above')

if __name__ == '__main__':
    doctest.testmod(ctypes.test.test_objects)

            

Reported by Pylint.

Lib/lib2to3/fixes/fix_set_literal.py
4 issues
Instance of 'Symbols' has no 'listmaker' member
Error

Line: 31 Column: 32

                      single = results.get("single")
        if single:
            # Make a fake listmaker
            fake = pytree.Node(syms.listmaker, [single.clone()])
            single.replace(fake)
            items = fake
        else:
            items = results["items"]


            

Reported by Pylint.

Instance of 'Symbols' has no 'dictsetmaker' member
Error

Line: 43 Column: 29

                      literal.append(pytree.Leaf(token.RBRACE, "}"))
        # Set the prefix of the right brace to that of the ')' or ']'
        literal[-1].prefix = items.next_sibling.prefix
        maker = pytree.Node(syms.dictsetmaker, literal)
        maker.prefix = node.prefix

        # If the original was a one tuple, we need to remove the extra comma.
        if len(maker.children) == 4:
            n = maker.children[2]

            

Reported by Pylint.

Missing class docstring
Error

Line: 12 Column: 1

              


class FixSetLiteral(fixer_base.BaseFix):

    BM_compatible = True
    explicit = True

    PATTERN = """power< 'set' trailer< '('

            

Reported by Pylint.

Variable name "n" doesn't conform to snake_case naming style
Error

Line: 48 Column: 13

              
        # If the original was a one tuple, we need to remove the extra comma.
        if len(maker.children) == 4:
            n = maker.children[2]
            n.remove()
            maker.children[-1].prefix = n.prefix

        # Finally, replace the set call with our shiny new literal.
        return maker

            

Reported by Pylint.