The following issues were found

Lib/test/test_tk.py
3 issues
Missing module docstring
Error

Line: 1 Column: 1

              from test import support
from test.support import import_helper
# Skip test if _tkinter wasn't built.
import_helper.import_module('_tkinter')

# Skip test if tk cannot be initialized.
support.requires('gui')

from tkinter.test import runtktests

            

Reported by Pylint.

Import "from tkinter.test import runtktests" should be placed at the top of the module
Error

Line: 9 Column: 1

              # Skip test if tk cannot be initialized.
support.requires('gui')

from tkinter.test import runtktests

def test_main():
    support.run_unittest(
            *runtktests.get_tests(text=False, packages=['test_tkinter']))


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 11 Column: 1

              
from tkinter.test import runtktests

def test_main():
    support.run_unittest(
            *runtktests.get_tests(text=False, packages=['test_tkinter']))

if __name__ == '__main__':
    test_main()

            

Reported by Pylint.

Mac/IDLE/IDLE.app/Contents/Resources/idlemain.py
3 issues
Unable to import 'idlelib.pyshell'
Error

Line: 71 Column: 1

                      break

# Now it is safe to import idlelib.
from idlelib.pyshell import main
if __name__ == '__main__':
    main()

            

Reported by Pylint.

Multiple imports on one line (sys, os)
Error

Line: 4 Column: 1

              """
Bootstrap script for IDLE as an application bundle.
"""
import sys, os

# Change the current directory the user's home directory, that way we'll get
# a more useful default location in the open/save dialogs.
os.chdir(os.path.expanduser('~/Documents'))


            

Reported by Pylint.

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

Line: 71 Column: 1

                      break

# Now it is safe to import idlelib.
from idlelib.pyshell import main
if __name__ == '__main__':
    main()

            

Reported by Pylint.

Lib/test/test_tools/test_gprof2html.py
3 issues
Missing class docstring
Error

Line: 13 Column: 1

              
skip_if_missing()

class Gprof2htmlTests(unittest.TestCase):

    def setUp(self):
        self.gprof = import_tool('gprof2html')
        oldargv = sys.argv
        def fixup():

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 23 Column: 5

                      self.addCleanup(fixup)
        sys.argv = []

    def test_gprof(self):
        # Issue #14508: this used to fail with a NameError.
        with mock.patch.object(self.gprof, 'webbrowser') as wmock, \
                tempfile.TemporaryDirectory() as tmpdir:
            fn = os.path.join(tmpdir, 'abc')
            open(fn, 'w').close()

            

Reported by Pylint.

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

Line: 27 Column: 13

                      # Issue #14508: this used to fail with a NameError.
        with mock.patch.object(self.gprof, 'webbrowser') as wmock, \
                tempfile.TemporaryDirectory() as tmpdir:
            fn = os.path.join(tmpdir, 'abc')
            open(fn, 'w').close()
            sys.argv = ['gprof2html', fn]
            self.gprof.main()
        self.assertTrue(wmock.open.called)


            

Reported by Pylint.

Modules/_blake2/blake2b_impl.c
3 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

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

                              BLAKE2B_SALTBYTES);
            goto error;
        }
        memcpy(self->param.salt, salt->buf, salt->len);
    }

    /* Set personalization parameter. */
    if ((person->obj != NULL) && person->len) {
        if (person->len > BLAKE2B_PERSONALBYTES) {

            

Reported by FlawFinder.

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

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

                              BLAKE2B_PERSONALBYTES);
            goto error;
        }
        memcpy(self->param.personal, person->buf, person->len);
    }

    /* Set tree parameters. */
    if (fanout < 0 || fanout > 255) {
        PyErr_SetString(PyExc_ValueError,

            

Reported by FlawFinder.

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

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

                  if (self->param.key_length) {
        uint8_t block[BLAKE2B_BLOCKBYTES];
        memset(block, 0, sizeof(block));
        memcpy(block, key->buf, key->len);
        blake2b_update(&self->state, block, sizeof(block));
        secure_zero_memory(block, sizeof(block));
    }

    /* Process initial data if any. */

            

Reported by FlawFinder.

Modules/_blake2/blake2s_impl.c
3 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

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

                              BLAKE2S_SALTBYTES);
            goto error;
        }
        memcpy(self->param.salt, salt->buf, salt->len);
    }

    /* Set personalization parameter. */
    if ((person->obj != NULL) && person->len) {
        if (person->len > BLAKE2S_PERSONALBYTES) {

            

Reported by FlawFinder.

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

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

                              BLAKE2S_PERSONALBYTES);
            goto error;
        }
        memcpy(self->param.personal, person->buf, person->len);
    }

    /* Set tree parameters. */
    if (fanout < 0 || fanout > 255) {
        PyErr_SetString(PyExc_ValueError,

            

Reported by FlawFinder.

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

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

                  if (self->param.key_length) {
        uint8_t block[BLAKE2S_BLOCKBYTES];
        memset(block, 0, sizeof(block));
        memcpy(block, key->buf, key->len);
        blake2s_update(&self->state, block, sizeof(block));
        secure_zero_memory(block, sizeof(block));
    }

    /* Process initial data if any. */

            

Reported by FlawFinder.

Objects/fileobject.c
3 issues
There is an unknown macro here somewhere. Configuration is required. If Py_END_ALLOW_THREADS is a macro then please configure it.
Error

Line: 427

              
    Py_BEGIN_ALLOW_THREADS
    res = isatty(self->fd);
    Py_END_ALLOW_THREADS

    return PyBool_FromLong(res);
}

static PyMethodDef stdprinter_methods[] = {

            

Reported by Cppcheck.

open - Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents?
Security

Line: 28 Column: 16 CWE codes: 362

              extern "C" {
#endif

_Py_IDENTIFIER(open);

/* External C interface */

PyObject *
PyFile_FromFd(int fd, const char *name, const char *mode, int buffering, const char *encoding,

            

Reported by FlawFinder.

getc - Check buffer boundaries if used in a loop including recursive loops
Security

Line: 13 Column: 17 CWE codes: 120 20

              #define FLOCKFILE(f) flockfile(f)
#define FUNLOCKFILE(f) funlockfile(f)
#else
#define GETC(f) getc(f)
#define FLOCKFILE(f)
#define FUNLOCKFILE(f)
#endif

/* Newline flags */

            

Reported by FlawFinder.

Objects/stringlib/find.h
3 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 94 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

                  Py_ssize_t tmp_start = 0;
    Py_ssize_t tmp_end = PY_SSIZE_T_MAX;
    PyObject *obj_start=Py_None, *obj_end=Py_None;
    char format[FORMAT_BUFFER_SIZE] = "O|OO:";
    size_t len = strlen(format);

    strncpy(format + len, function_name, FORMAT_BUFFER_SIZE - len - 1);
    format[FORMAT_BUFFER_SIZE - 1] = '\0';


            

Reported by FlawFinder.

strlen - Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected)
Security

Line: 95 Column: 18 CWE codes: 126

                  Py_ssize_t tmp_end = PY_SSIZE_T_MAX;
    PyObject *obj_start=Py_None, *obj_end=Py_None;
    char format[FORMAT_BUFFER_SIZE] = "O|OO:";
    size_t len = strlen(format);

    strncpy(format + len, function_name, FORMAT_BUFFER_SIZE - len - 1);
    format[FORMAT_BUFFER_SIZE - 1] = '\0';

    if (!PyArg_ParseTuple(args, format, &tmp_subobj, &obj_start, &obj_end))

            

Reported by FlawFinder.

strncpy - Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned]
Security

Line: 97 Column: 5 CWE codes: 120

                  char format[FORMAT_BUFFER_SIZE] = "O|OO:";
    size_t len = strlen(format);

    strncpy(format + len, function_name, FORMAT_BUFFER_SIZE - len - 1);
    format[FORMAT_BUFFER_SIZE - 1] = '\0';

    if (!PyArg_ParseTuple(args, format, &tmp_subobj, &obj_start, &obj_end))
        return 0;


            

Reported by FlawFinder.

Objects/stringlib/join.h
3 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

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

                      for (i = 0; i < nbufs; i++) {
            Py_ssize_t n = buffers[i].len;
            char *q = buffers[i].buf;
            memcpy(p, q, n);
            p += n;
        }
    }
    else {
        for (i = 0; i < nbufs; i++) {

            

Reported by FlawFinder.

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

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

                          Py_ssize_t n;
            char *q;
            if (i) {
                memcpy(p, sepstr, seplen);
                p += seplen;
            }
            n = buffers[i].len;
            q = buffers[i].buf;
            memcpy(p, q, n);

            

Reported by FlawFinder.

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

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

                          }
            n = buffers[i].len;
            q = buffers[i].buf;
            memcpy(p, q, n);
            p += n;
        }
    }
    if (drop_gil) {
        PyEval_RestoreThread(save);

            

Reported by FlawFinder.

Lib/test/test_peg_generator/__main__.py
3 issues
Attempted relative import beyond top-level package
Error

Line: 2 Column: 1

              import unittest
from . import load_tests

unittest.main()

            

Reported by Pylint.

Unused import load_tests
Error

Line: 2 Column: 1

              import unittest
from . import load_tests

unittest.main()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import unittest
from . import load_tests

unittest.main()

            

Reported by Pylint.

Lib/test/test_ttk_textonly.py
3 issues
Missing module docstring
Error

Line: 1 Column: 1

              from test import support
from test.support import import_helper


# Skip this test if _tkinter does not exist.
import_helper.import_module('_tkinter')

from tkinter.test import runtktests


            

Reported by Pylint.

Import "from tkinter.test import runtktests" should be placed at the top of the module
Error

Line: 8 Column: 1

              # Skip this test if _tkinter does not exist.
import_helper.import_module('_tkinter')

from tkinter.test import runtktests

def test_main():
    support.run_unittest(
            *runtktests.get_tests(gui=False, packages=['test_ttk']))


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 1

              
from tkinter.test import runtktests

def test_main():
    support.run_unittest(
            *runtktests.get_tests(gui=False, packages=['test_ttk']))

if __name__ == '__main__':
    test_main()

            

Reported by Pylint.