The following issues were found

Objects/memoryobject.c
35 issues
strcpy - Does not check for buffer overflows when copying to destination [MS-banned]
Security

Line: 823 Column: 31 CWE codes: 120
Suggestion: Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)

                          PyErr_NoMemory();
            return -1;
        }
        mbuf->master.format = strcpy(cp, fmt);
        mbuf->flags |= _Py_MANAGED_BUFFER_FREE_FORMAT;
    }

    return 0;
}

            

Reported by FlawFinder.

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

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

                  if (mem == NULL) { /* contiguous */
        Py_ssize_t size = shape[0] * itemsize;
        if (dptr + size < sptr || sptr + size < dptr)
            memcpy(dptr, sptr, size); /* no overlapping */
        else
            memmove(dptr, sptr, size);
    }
    else {
        char *p;

            

Reported by FlawFinder.

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

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

                      Py_ssize_t i;
        for (i=0, p=mem; i < shape[0]; p+=itemsize, sptr+=sstrides[0], i++) {
            char *xsptr = ADJUST_PTR(sptr, ssuboffsets, 0);
            memcpy(p, xsptr, itemsize);
        }
        for (i=0, p=mem; i < shape[0]; p+=itemsize, dptr+=dstrides[0], i++) {
            char *xdptr = ADJUST_PTR(dptr, dsuboffsets, 0);
            memcpy(xdptr, p, itemsize);
        }

            

Reported by FlawFinder.

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

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

                      }
        for (i=0, p=mem; i < shape[0]; p+=itemsize, dptr+=dstrides[0], i++) {
            char *xdptr = ADJUST_PTR(dptr, dsuboffsets, 0);
            memcpy(xdptr, p, itemsize);
        }
    }

}


            

Reported by FlawFinder.

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

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

                  }

    if (PyBuffer_IsContiguous(src, order)) {
        memcpy((char *)buf, src->buf, len);
        return 0;
    }

    /* buffer_to_contiguous() assumes PyBUF_FULL */
    fb = PyMem_Malloc(sizeof *fb + 3 * src->ndim * (sizeof *fb->array));

            

Reported by FlawFinder.

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

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

              #define UNPACK_SINGLE(dest, ptr, type) \
    do {                                   \
        type x;                            \
        memcpy((char *)&x, ptr, sizeof x); \
        dest = x;                          \
    } while (0)

/* Unpack a single item. 'fmt' can be any native format character in struct
   module syntax. This function is very sensitive to small changes. With this

            

Reported by FlawFinder.

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

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

                  do {                                     \
        type x;                              \
        x = (type)src;                       \
        memcpy(ptr, (char *)&x, sizeof x);   \
    } while (0)

/* Pack a single item. 'fmt' can be any native format character in
   struct module syntax. */
static int

            

Reported by FlawFinder.

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

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

              {
    PyObject *v;

    memcpy(x->item, ptr, x->itemsize);
    v = PyObject_CallOneArg(x->unpack_from, x->mview);
    if (v == NULL)
        return NULL;

    if (PyTuple_GET_SIZE(v) == 1) {

            

Reported by FlawFinder.

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

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

                  do {                                 \
        type x;                          \
        type y;                          \
        memcpy((char *)&x, p, sizeof x); \
        memcpy((char *)&y, q, sizeof y); \
        equal = (x == y);                \
    } while (0)

static inline int

            

Reported by FlawFinder.

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

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

                      type x;                          \
        type y;                          \
        memcpy((char *)&x, p, sizeof x); \
        memcpy((char *)&y, q, sizeof y); \
        equal = (x == y);                \
    } while (0)

static inline int
unpack_cmp(const char *p, const char *q, char fmt,

            

Reported by FlawFinder.

Tools/demo/life.py
35 issues
Attribute 'boring' defined outside __init__
Error

Line: 103 Column: 9

                          return

        d = {}
        self.boring = 1
        for i in range(0, M):
            L = range(max(0, i - 1), min(M, i + 2))
            for j in range(0, N):
                s = 0
                live = (i, j) in self.state

            

Reported by Pylint.

Attribute 'boring' defined outside __init__
Error

Line: 124 Column: 25

                                  self.scr.addch(j + 1, i + 1, self.char)
                    self.scr.attrset(0)
                    if not live:
                        self.boring = 0
                elif s == 2 and live:
                    # Survival
                    d[i, j] = 1
                elif live:
                    # Death

            

Reported by Pylint.

Attribute 'boring' defined outside __init__
Error

Line: 131 Column: 21

                              elif live:
                    # Death
                    self.scr.addch(j + 1, i + 1, ' ')
                    self.boring = 0
        self.state = d
        self.scr.refresh()

    def make_random(self):
        "Fill the board with a random pattern"

            

Reported by Pylint.

Unused variable 'button_state'
Error

Line: 244 Column: 50

                      elif c == curses.KEY_RIGHT and xpos + 1 < board.X:
            xpos += 1
        elif c == curses.KEY_MOUSE:
            mouse_id, mouse_x, mouse_y, mouse_z, button_state = curses.getmouse()
            if (mouse_x > 0 and mouse_x < board.X + 1 and
                mouse_y > 0 and mouse_y < board.Y + 1):
                xpos = mouse_x - 1
                ypos = mouse_y - 1
                board.toggle(ypos, xpos)

            

Reported by Pylint.

Unused variable 'mouse_z'
Error

Line: 244 Column: 41

                      elif c == curses.KEY_RIGHT and xpos + 1 < board.X:
            xpos += 1
        elif c == curses.KEY_MOUSE:
            mouse_id, mouse_x, mouse_y, mouse_z, button_state = curses.getmouse()
            if (mouse_x > 0 and mouse_x < board.X + 1 and
                mouse_y > 0 and mouse_y < board.Y + 1):
                xpos = mouse_x - 1
                ypos = mouse_y - 1
                board.toggle(ypos, xpos)

            

Reported by Pylint.

Unused variable 'mouse_id'
Error

Line: 244 Column: 13

                      elif c == curses.KEY_RIGHT and xpos + 1 < board.X:
            xpos += 1
        elif c == curses.KEY_MOUSE:
            mouse_id, mouse_x, mouse_y, mouse_z, button_state = curses.getmouse()
            if (mouse_x > 0 and mouse_x < board.X + 1 and
                mouse_y > 0 and mouse_y < board.Y + 1):
                xpos = mouse_x - 1
                ypos = mouse_y - 1
                board.toggle(ypos, xpos)

            

Reported by Pylint.

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

Line: 48 Column: 12

                      """
        self.state = {}
        self.scr = scr
        Y, X = self.scr.getmaxyx()
        self.X, self.Y = X - 2, Y - 2 - 1
        self.char = char
        self.scr.clear()

        # Draw a border around the board

            

Reported by Pylint.

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

Line: 48 Column: 9

                      """
        self.state = {}
        self.scr = scr
        Y, X = self.scr.getmaxyx()
        self.X, self.Y = X - 2, Y - 2 - 1
        self.char = char
        self.scr.clear()

        # Draw a border around the board

            

Reported by Pylint.

Attribute name "X" doesn't conform to snake_case naming style
Error

Line: 49 Column: 9

                      self.state = {}
        self.scr = scr
        Y, X = self.scr.getmaxyx()
        self.X, self.Y = X - 2, Y - 2 - 1
        self.char = char
        self.scr.clear()

        # Draw a border around the board
        border_line = '+' + (self.X * '-') + '+'

            

Reported by Pylint.

Attribute name "Y" doesn't conform to snake_case naming style
Error

Line: 49 Column: 17

                      self.state = {}
        self.scr = scr
        Y, X = self.scr.getmaxyx()
        self.X, self.Y = X - 2, Y - 2 - 1
        self.char = char
        self.scr.clear()

        # Draw a border around the board
        border_line = '+' + (self.X * '-') + '+'

            

Reported by Pylint.

Lib/test/test_winconsoleio.py
35 issues
Unable to import '_testconsole'
Error

Line: 14 Column: 1

              if sys.platform != 'win32':
    raise unittest.SkipTest("test only relevant on win32")

from _testconsole import write_input

ConIO = io._WindowsConsoleIO

class WindowsConsoleIOTests(unittest.TestCase):
    def test_abc(self):

            

Reported by Pylint.

Module 'sys' has no 'getwindowsversion' member
Error

Line: 99 Column: 22

                      self.assertIsInstance(f, ConIO)
        f.close()

    @unittest.skipIf(sys.getwindowsversion()[:2] <= (6, 1),
        "test does not work on Windows 7 and earlier")
    def test_conin_conout_names(self):
        f = open(r'\\.\conin$', 'rb', buffering=0)
        self.assertIsInstance(f, ConIO)
        f.close()

            

Reported by Pylint.

Module 'sys' has no 'getwindowsversion' member
Error

Line: 117 Column: 16

                      conout_path = os.path.join(temp_path, 'CONOUT$')

        with open(conout_path, 'wb', buffering=0) as f:
            if sys.getwindowsversion()[:2] > (6, 1):
                self.assertIsInstance(f, ConIO)
            else:
                self.assertNotIsInstance(f, ConIO)

    def test_write_empty_data(self):

            

Reported by Pylint.

Access to a protected member _WindowsConsoleIO of a client class
Error

Line: 16 Column: 9

              
from _testconsole import write_input

ConIO = io._WindowsConsoleIO

class WindowsConsoleIOTests(unittest.TestCase):
    def test_abc(self):
        self.assertTrue(issubclass(ConIO, io.RawIOBase))
        self.assertFalse(issubclass(ConIO, io.BufferedIOBase))

            

Reported by Pylint.

Import "from _testconsole import write_input" should be placed at the top of the module
Error

Line: 14 Column: 1

              if sys.platform != 'win32':
    raise unittest.SkipTest("test only relevant on win32")

from _testconsole import write_input

ConIO = io._WindowsConsoleIO

class WindowsConsoleIOTests(unittest.TestCase):
    def test_abc(self):

            

Reported by Pylint.

Missing class docstring
Error

Line: 18 Column: 1

              
ConIO = io._WindowsConsoleIO

class WindowsConsoleIOTests(unittest.TestCase):
    def test_abc(self):
        self.assertTrue(issubclass(ConIO, io.RawIOBase))
        self.assertFalse(issubclass(ConIO, io.BufferedIOBase))
        self.assertFalse(issubclass(ConIO, io.TextIOBase))


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 19 Column: 5

              ConIO = io._WindowsConsoleIO

class WindowsConsoleIOTests(unittest.TestCase):
    def test_abc(self):
        self.assertTrue(issubclass(ConIO, io.RawIOBase))
        self.assertFalse(issubclass(ConIO, io.BufferedIOBase))
        self.assertFalse(issubclass(ConIO, io.TextIOBase))

    def test_open_fd(self):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 24 Column: 5

                      self.assertFalse(issubclass(ConIO, io.BufferedIOBase))
        self.assertFalse(issubclass(ConIO, io.TextIOBase))

    def test_open_fd(self):
        self.assertRaisesRegex(ValueError,
            "negative file descriptor", ConIO, -1)

        with tempfile.TemporaryFile() as tmpfile:
            fd = tmpfile.fileno()

            

Reported by Pylint.

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

Line: 29 Column: 13

                          "negative file descriptor", ConIO, -1)

        with tempfile.TemporaryFile() as tmpfile:
            fd = tmpfile.fileno()
            # Windows 10: "Cannot open non-console file"
            # Earlier: "Cannot open console output buffer for reading"
            self.assertRaisesRegex(ValueError,
                "Cannot open (console|non-console file)", ConIO, fd)


            

Reported by Pylint.

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

Line: 36 Column: 13

                              "Cannot open (console|non-console file)", ConIO, fd)

        try:
            f = ConIO(0)
        except ValueError:
            # cannot open console because it's not a real console
            pass
        else:
            self.assertTrue(f.readable())

            

Reported by Pylint.

Lib/test/test_wave.py
35 issues
Missing module docstring
Error

Line: 1 Column: 1

              import unittest
from test import audiotests
from test import support
from audioop import byteswap
import io
import struct
import sys
import wave


            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

              import wave


class WaveTest(audiotests.AudioWriteTests,
               audiotests.AudioTestsWithSourceFile):
    module = wave


class WavePCM8Test(WaveTest, unittest.TestCase):

            

Reported by Pylint.

Missing class docstring
Error

Line: 16 Column: 1

                  module = wave


class WavePCM8Test(WaveTest, unittest.TestCase):
    sndfilename = 'pluck-pcm8.wav'
    sndfilenframes = 3307
    nchannels = 2
    sampwidth = 1
    framerate = 11025

            

Reported by Pylint.

Missing class docstring
Error

Line: 33 Column: 1

                    """)


class WavePCM16Test(WaveTest, unittest.TestCase):
    sndfilename = 'pluck-pcm16.wav'
    sndfilenframes = 3307
    nchannels = 2
    sampwidth = 2
    framerate = 11025

            

Reported by Pylint.

Missing class docstring
Error

Line: 54 Column: 1

                      frames = byteswap(frames, 2)


class WavePCM24Test(WaveTest, unittest.TestCase):
    sndfilename = 'pluck-pcm24.wav'
    sndfilenframes = 3307
    nchannels = 2
    sampwidth = 3
    framerate = 11025

            

Reported by Pylint.

Missing class docstring
Error

Line: 81 Column: 1

                      frames = byteswap(frames, 3)


class WavePCM32Test(WaveTest, unittest.TestCase):
    sndfilename = 'pluck-pcm32.wav'
    sndfilenframes = 3307
    nchannels = 2
    sampwidth = 4
    framerate = 11025

            

Reported by Pylint.

Missing class docstring
Error

Line: 108 Column: 1

                      frames = byteswap(frames, 4)


class MiscTestCase(unittest.TestCase):
    def test__all__(self):
        support.check__all__(self, wave, not_exported={'WAVE_FORMAT_PCM'})


class WaveLowLevelTest(unittest.TestCase):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 109 Column: 5

              

class MiscTestCase(unittest.TestCase):
    def test__all__(self):
        support.check__all__(self, wave, not_exported={'WAVE_FORMAT_PCM'})


class WaveLowLevelTest(unittest.TestCase):


            

Reported by Pylint.

Missing class docstring
Error

Line: 113 Column: 1

                      support.check__all__(self, wave, not_exported={'WAVE_FORMAT_PCM'})


class WaveLowLevelTest(unittest.TestCase):

    def test_read_no_chunks(self):
        b = b'SPAM'
        with self.assertRaises(EOFError):
            wave.open(io.BytesIO(b))

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 115 Column: 5

              
class WaveLowLevelTest(unittest.TestCase):

    def test_read_no_chunks(self):
        b = b'SPAM'
        with self.assertRaises(EOFError):
            wave.open(io.BytesIO(b))

    def test_read_no_riff_chunk(self):

            

Reported by Pylint.

Objects/bytesobject.c
35 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

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

                  if (str == NULL)
        return (PyObject *) op;

    memcpy(op->ob_sval, str, size);
    /* share short strings */
    if (size == 1) {
        struct _Py_bytes_state *state = get_bytes_state();
        Py_INCREF(op);
        state->characters[*str & UCHAR_MAX] = op;

            

Reported by FlawFinder.

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

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

                  }
    _PyObject_InitVar((PyVarObject*)op, &PyBytes_Type, size);
    op->ob_shash = -1;
    memcpy(op->ob_sval, str, size+1);
    /* share short strings */
    if (size == 1) {
        assert(state->characters[*str & UCHAR_MAX] == NULL);
        Py_INCREF(op);
        state->characters[*str & UCHAR_MAX] = op;

            

Reported by FlawFinder.

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

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

              
       Longest 64-bit pointer representation:
       "0xffffffffffffffff\0" (19 bytes). */
    char buffer[21];
    _PyBytesWriter writer;

    _PyBytesWriter_Init(&writer);

    s = _PyBytesWriter_Alloc(&writer, strlen(format));

            

Reported by FlawFinder.

sprintf - Does not check for buffer overflows
Security

Line: 311 Column: 17 CWE codes: 120
Suggestion: Use sprintf_s, snprintf, or vsnprintf

              
        case 'd':
            if (longflag) {
                sprintf(buffer, "%ld", va_arg(vargs, long));
            }
            else if (size_tflag) {
                sprintf(buffer, "%zd", va_arg(vargs, Py_ssize_t));
            }
            else {

            

Reported by FlawFinder.

sprintf - Does not check for buffer overflows
Security

Line: 314 Column: 17 CWE codes: 120
Suggestion: Use sprintf_s, snprintf, or vsnprintf

                              sprintf(buffer, "%ld", va_arg(vargs, long));
            }
            else if (size_tflag) {
                sprintf(buffer, "%zd", va_arg(vargs, Py_ssize_t));
            }
            else {
                sprintf(buffer, "%d", va_arg(vargs, int));
            }
            assert(strlen(buffer) < sizeof(buffer));

            

Reported by FlawFinder.

sprintf - Does not check for buffer overflows
Security

Line: 317 Column: 17 CWE codes: 120
Suggestion: Use sprintf_s, snprintf, or vsnprintf

                              sprintf(buffer, "%zd", va_arg(vargs, Py_ssize_t));
            }
            else {
                sprintf(buffer, "%d", va_arg(vargs, int));
            }
            assert(strlen(buffer) < sizeof(buffer));
            WRITE_BYTES(buffer);
            break;


            

Reported by FlawFinder.

sprintf - Does not check for buffer overflows
Security

Line: 325 Column: 17 CWE codes: 120
Suggestion: Use sprintf_s, snprintf, or vsnprintf

              
        case 'u':
            if (longflag) {
                sprintf(buffer, "%lu", va_arg(vargs, unsigned long));
            }
            else if (size_tflag) {
                sprintf(buffer, "%zu", va_arg(vargs, size_t));
            }
            else {

            

Reported by FlawFinder.

sprintf - Does not check for buffer overflows
Security

Line: 328 Column: 17 CWE codes: 120
Suggestion: Use sprintf_s, snprintf, or vsnprintf

                              sprintf(buffer, "%lu", va_arg(vargs, unsigned long));
            }
            else if (size_tflag) {
                sprintf(buffer, "%zu", va_arg(vargs, size_t));
            }
            else {
                sprintf(buffer, "%u", va_arg(vargs, unsigned int));
            }
            assert(strlen(buffer) < sizeof(buffer));

            

Reported by FlawFinder.

sprintf - Does not check for buffer overflows
Security

Line: 331 Column: 17 CWE codes: 120
Suggestion: Use sprintf_s, snprintf, or vsnprintf

                              sprintf(buffer, "%zu", va_arg(vargs, size_t));
            }
            else {
                sprintf(buffer, "%u", va_arg(vargs, unsigned int));
            }
            assert(strlen(buffer) < sizeof(buffer));
            WRITE_BYTES(buffer);
            break;


            

Reported by FlawFinder.

sprintf - Does not check for buffer overflows
Security

Line: 338 Column: 13 CWE codes: 120
Suggestion: Use sprintf_s, snprintf, or vsnprintf

                          break;

        case 'i':
            sprintf(buffer, "%i", va_arg(vargs, int));
            assert(strlen(buffer) < sizeof(buffer));
            WRITE_BYTES(buffer);
            break;

        case 'x':

            

Reported by FlawFinder.

Tools/pynche/pyColorChooser.py
35 issues
Unable to import 'Main'
Error

Line: 5 Column: 1

              """

import os
import Main
import ColorDB



class Chooser:

            

Reported by Pylint.

Unable to import 'ColorDB'
Error

Line: 6 Column: 1

              
import os
import Main
import ColorDB



class Chooser:
    """Ask for a color"""

            

Reported by Pylint.

Unable to import 'tkinter'
Error

Line: 34 Column: 13

                      if dbfile != self.__databasefile:
            colordb = ColorDB.get_colordb(dbfile)
        if not self.__master:
            from tkinter import Tk
            self.__master = Tk()
        if not self.__pw:
            self.__pw, self.__sb = \
                       Main.build(master = self.__master,
                                  initfile = self.__initfile,

            

Reported by Pylint.

Unable to import 'tkinter'
Error

Line: 95 Column: 5

              
# test stuff
if __name__ == '__main__':
    from tkinter import *

    class Tester:
        def __init__(self):
            self.__root = tk = Tk()
            b = Button(tk, text='Choose Color...', command=self.__choose)

            

Reported by Pylint.

Undefined variable 'Tk'
Error

Line: 99 Column: 32

              
    class Tester:
        def __init__(self):
            self.__root = tk = Tk()
            b = Button(tk, text='Choose Color...', command=self.__choose)
            b.pack()
            self.__l = Label(tk)
            self.__l.pack()
            q = Button(tk, text='Quit', command=self.__quit)

            

Reported by Pylint.

Undefined variable 'Button'
Error

Line: 100 Column: 17

                  class Tester:
        def __init__(self):
            self.__root = tk = Tk()
            b = Button(tk, text='Choose Color...', command=self.__choose)
            b.pack()
            self.__l = Label(tk)
            self.__l.pack()
            q = Button(tk, text='Quit', command=self.__quit)
            q.pack()

            

Reported by Pylint.

Undefined variable 'Label'
Error

Line: 102 Column: 24

                          self.__root = tk = Tk()
            b = Button(tk, text='Choose Color...', command=self.__choose)
            b.pack()
            self.__l = Label(tk)
            self.__l.pack()
            q = Button(tk, text='Quit', command=self.__quit)
            q.pack()

        def __choose(self, event=None):

            

Reported by Pylint.

Undefined variable 'Button'
Error

Line: 104 Column: 17

                          b.pack()
            self.__l = Label(tk)
            self.__l.pack()
            q = Button(tk, text='Quit', command=self.__quit)
            q.pack()

        def __choose(self, event=None):
            rgb, name = askcolor(master=self.__root)
            if rgb is None:

            

Reported by Pylint.

Attribute '__sb' defined outside __init__
Error

Line: 37 Column: 24

                          from tkinter import Tk
            self.__master = Tk()
        if not self.__pw:
            self.__pw, self.__sb = \
                       Main.build(master = self.__master,
                                  initfile = self.__initfile,
                                  ignore = self.__ignore)
        else:
            self.__pw.deiconify()

            

Reported by Pylint.

Using the global statement
Error

Line: 82 Column: 5

              
def askcolor(color = None, **options):
    """Ask for a color"""
    global _chooser
    if not _chooser:
        _chooser = Chooser(**options)
    return _chooser.show(color, options)

def save():

            

Reported by Pylint.

Tools/pynche/Main.py
35 issues
Unable to import 'ColorDB'
Error

Line: 54 Column: 1

              import sys
import os
import getopt
import ColorDB

from PyncheWidget import PyncheWidget
from Switchboard import Switchboard
from StripViewer import StripViewer
from ChipViewer import ChipViewer

            

Reported by Pylint.

Unable to import 'PyncheWidget'
Error

Line: 56 Column: 1

              import getopt
import ColorDB

from PyncheWidget import PyncheWidget
from Switchboard import Switchboard
from StripViewer import StripViewer
from ChipViewer import ChipViewer
from TypeinViewer import TypeinViewer


            

Reported by Pylint.

Unable to import 'Switchboard'
Error

Line: 57 Column: 1

              import ColorDB

from PyncheWidget import PyncheWidget
from Switchboard import Switchboard
from StripViewer import StripViewer
from ChipViewer import ChipViewer
from TypeinViewer import TypeinViewer



            

Reported by Pylint.

Unable to import 'StripViewer'
Error

Line: 58 Column: 1

              
from PyncheWidget import PyncheWidget
from Switchboard import Switchboard
from StripViewer import StripViewer
from ChipViewer import ChipViewer
from TypeinViewer import TypeinViewer




            

Reported by Pylint.

Unable to import 'ChipViewer'
Error

Line: 59 Column: 1

              from PyncheWidget import PyncheWidget
from Switchboard import Switchboard
from StripViewer import StripViewer
from ChipViewer import ChipViewer
from TypeinViewer import TypeinViewer



PROGRAM = sys.argv[0]

            

Reported by Pylint.

Unable to import 'TypeinViewer'
Error

Line: 60 Column: 1

              from Switchboard import Switchboard
from StripViewer import StripViewer
from ChipViewer import ChipViewer
from TypeinViewer import TypeinViewer



PROGRAM = sys.argv[0]
AUTHNAME = 'Barry Warsaw'

            

Reported by Pylint.

Unused argument 's'
Error

Line: 175 Column: 14

                  return app, s


def run(app, s):
    try:
        app.start()
    except KeyboardInterrupt:
        pass


            

Reported by Pylint.

Module name "Main" doesn't conform to snake_case naming style
Error

Line: 1 Column: 1

              """Pynche -- The PYthon Natural Color and Hue Editor.

Contact: %(AUTHNAME)s
Email:   %(AUTHEMAIL)s
Version: %(__version__)s

Pynche is based largely on a similar color editor I wrote years ago for the
SunView window system.  That editor was called ICE: the Interactive Color
Editor.  I'd always wanted to port the editor to X but didn't feel like

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 83 Column: 1

              
# Do this because PyncheWidget.py wants to get at the interpolated docstring
# too, for its Help menu.
def docstring():
    return __doc__ % globals()


def usage(code, msg=''):
    print(docstring())

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 87 Column: 1

                  return __doc__ % globals()


def usage(code, msg=''):
    print(docstring())
    if msg:
        print(msg)
    sys.exit(code)


            

Reported by Pylint.

Lib/test/pyclbr_input.py
35 issues
XXX: This causes test_pyclbr.py to fail, but only because the
Error

Line: 20 Column: 3

              
    d = 10

    # XXX: This causes test_pyclbr.py to fail, but only because the
    #      introspection-based is_method() code in the test can't
    #      distinguish between this and a genuine method function like m().
    #      The pyclbr.py module gets this right as it parses the text.
    #
    #f = f

            

Reported by Pylint.

Static method with 'self' as first argument
Error

Line: 30 Column: 5

                  def m(self): pass

    @staticmethod
    def sm(self): pass

    @classmethod
    def cm(self): pass

            

Reported by Pylint.

Function name "f" doesn't conform to snake_case naming style
Error

Line: 3 Column: 1

              """Test cases for test_pyclbr.py"""

def f(): pass

class Other(object):
    @classmethod
    def foo(c): pass

    def om(self): pass

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 3 Column: 1

              """Test cases for test_pyclbr.py"""

def f(): pass

class Other(object):
    @classmethod
    def foo(c): pass

    def om(self): pass

            

Reported by Pylint.

More than one statement on a single line
Error

Line: 3 Column: 10

              """Test cases for test_pyclbr.py"""

def f(): pass

class Other(object):
    @classmethod
    def foo(c): pass

    def om(self): pass

            

Reported by Pylint.

Class 'Other' inherits from object, can be safely removed from bases in python3
Error

Line: 5 Column: 1

              
def f(): pass

class Other(object):
    @classmethod
    def foo(c): pass

    def om(self): pass


            

Reported by Pylint.

Missing class docstring
Error

Line: 5 Column: 1

              
def f(): pass

class Other(object):
    @classmethod
    def foo(c): pass

    def om(self): pass


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 7 Column: 5

              
class Other(object):
    @classmethod
    def foo(c): pass

    def om(self): pass

class B (object):
    def bm(self): pass

            

Reported by Pylint.

More than one statement on a single line
Error

Line: 7 Column: 17

              
class Other(object):
    @classmethod
    def foo(c): pass

    def om(self): pass

class B (object):
    def bm(self): pass

            

Reported by Pylint.

Black listed name "foo"
Error

Line: 7 Column: 5

              
class Other(object):
    @classmethod
    def foo(c): pass

    def om(self): pass

class B (object):
    def bm(self): pass

            

Reported by Pylint.

Lib/test/test_json/test_tool.py
35 issues
Unused support imported from test
Error

Line: 8 Column: 1

              import unittest
import subprocess

from test import support
from test.support import os_helper
from test.support.script_helper import assert_python_ok


class TestTool(unittest.TestCase):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import errno
import os
import sys
import textwrap
import unittest
import subprocess

from test import support
from test.support import os_helper

            

Reported by Pylint.

Consider possible security implications associated with subprocess module.
Security blacklist

Line: 6
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess

              import sys
import textwrap
import unittest
import subprocess

from test import support
from test.support import os_helper
from test.support.script_helper import assert_python_ok


            

Reported by Bandit.

Missing class docstring
Error

Line: 13 Column: 1

              from test.support.script_helper import assert_python_ok


class TestTool(unittest.TestCase):
    data = """

        [["blorpie"],[ "whoops" ] , [
                                 ],\t"d-shtaeou",\r"d-nthiouh",
        "i-vhbjkhnth", {"nifty":87}, {"morefield" :\tfalse,"field"

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 88 Column: 5

                  }
    """)

    def test_stdin_stdout(self):
        args = sys.executable, '-m', 'json.tool'
        process = subprocess.run(args, input=self.data, capture_output=True, text=True, check=True)
        self.assertEqual(process.stdout, self.expect)
        self.assertEqual(process.stderr, '')


            

Reported by Pylint.

subprocess call - check for execution of untrusted input.
Security injection

Line: 90
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html

              
    def test_stdin_stdout(self):
        args = sys.executable, '-m', 'json.tool'
        process = subprocess.run(args, input=self.data, capture_output=True, text=True, check=True)
        self.assertEqual(process.stdout, self.expect)
        self.assertEqual(process.stderr, '')

    def _create_infile(self, data=None):
        infile = os_helper.TESTFN

            

Reported by Bandit.

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

Line: 96 Column: 53

              
    def _create_infile(self, data=None):
        infile = os_helper.TESTFN
        with open(infile, "w", encoding="utf-8") as fp:
            self.addCleanup(os.remove, infile)
            fp.write(data or self.data)
        return infile

    def test_infile_stdout(self):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 101 Column: 5

                          fp.write(data or self.data)
        return infile

    def test_infile_stdout(self):
        infile = self._create_infile()
        rc, out, err = assert_python_ok('-m', 'json.tool', infile)
        self.assertEqual(rc, 0)
        self.assertEqual(out.splitlines(), self.expect.encode().splitlines())
        self.assertEqual(err, b'')

            

Reported by Pylint.

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

Line: 103 Column: 9

              
    def test_infile_stdout(self):
        infile = self._create_infile()
        rc, out, err = assert_python_ok('-m', 'json.tool', infile)
        self.assertEqual(rc, 0)
        self.assertEqual(out.splitlines(), self.expect.encode().splitlines())
        self.assertEqual(err, b'')

    def test_non_ascii_infile(self):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 108 Column: 5

                      self.assertEqual(out.splitlines(), self.expect.encode().splitlines())
        self.assertEqual(err, b'')

    def test_non_ascii_infile(self):
        data = '{"msg": "\u3053\u3093\u306b\u3061\u306f"}'
        expect = textwrap.dedent('''\
        {
            "msg": "\\u3053\\u3093\\u306b\\u3061\\u306f"
        }

            

Reported by Pylint.

Lib/test/test_codeop.py
35 issues
Redefining built-in 'str'
Error

Line: 24 Column: 27

              
class CodeopTests(unittest.TestCase):

    def assertValid(self, str, symbol='single'):
        '''succeed iff str is a valid piece of code'''
        if support.is_jython:
            code = compile_command(str, "<input>", symbol)
            self.assertTrue(code)
            if symbol == "single":

            

Reported by Pylint.

Use of exec
Error

Line: 34 Column: 21

                              saved_stdout = sys.stdout
                sys.stdout = io.StringIO()
                try:
                    exec(code, d)
                    exec(compile(str,"<input>","single"), r)
                finally:
                    sys.stdout = saved_stdout
            elif symbol == 'eval':
                ctx = {'a': 2}

            

Reported by Pylint.

Use of exec detected.
Security

Line: 34
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html

                              saved_stdout = sys.stdout
                sys.stdout = io.StringIO()
                try:
                    exec(code, d)
                    exec(compile(str,"<input>","single"), r)
                finally:
                    sys.stdout = saved_stdout
            elif symbol == 'eval':
                ctx = {'a': 2}

            

Reported by Bandit.

Use of exec detected.
Security

Line: 35
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html

                              sys.stdout = io.StringIO()
                try:
                    exec(code, d)
                    exec(compile(str,"<input>","single"), r)
                finally:
                    sys.stdout = saved_stdout
            elif symbol == 'eval':
                ctx = {'a': 2}
                d = { 'value': eval(code,ctx) }

            

Reported by Bandit.

Use of exec
Error

Line: 35 Column: 21

                              sys.stdout = io.StringIO()
                try:
                    exec(code, d)
                    exec(compile(str,"<input>","single"), r)
                finally:
                    sys.stdout = saved_stdout
            elif symbol == 'eval':
                ctx = {'a': 2}
                d = { 'value': eval(code,ctx) }

            

Reported by Pylint.

Use of eval
Error

Line: 40 Column: 32

                                  sys.stdout = saved_stdout
            elif symbol == 'eval':
                ctx = {'a': 2}
                d = { 'value': eval(code,ctx) }
                r = { 'value': eval(str,ctx) }
            self.assertEqual(unify_callables(r),unify_callables(d))
        else:
            expected = compile(str, "<input>", symbol, PyCF_DONT_IMPLY_DEDENT)
            self.assertEqual(compile_command(str, "<input>", symbol), expected)

            

Reported by Pylint.

Use of possibly insecure function - consider using safer ast.literal_eval.
Security blacklist

Line: 40
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval

                                  sys.stdout = saved_stdout
            elif symbol == 'eval':
                ctx = {'a': 2}
                d = { 'value': eval(code,ctx) }
                r = { 'value': eval(str,ctx) }
            self.assertEqual(unify_callables(r),unify_callables(d))
        else:
            expected = compile(str, "<input>", symbol, PyCF_DONT_IMPLY_DEDENT)
            self.assertEqual(compile_command(str, "<input>", symbol), expected)

            

Reported by Bandit.

Use of eval
Error

Line: 41 Column: 32

                          elif symbol == 'eval':
                ctx = {'a': 2}
                d = { 'value': eval(code,ctx) }
                r = { 'value': eval(str,ctx) }
            self.assertEqual(unify_callables(r),unify_callables(d))
        else:
            expected = compile(str, "<input>", symbol, PyCF_DONT_IMPLY_DEDENT)
            self.assertEqual(compile_command(str, "<input>", symbol), expected)


            

Reported by Pylint.

Use of possibly insecure function - consider using safer ast.literal_eval.
Security blacklist

Line: 41
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval

                          elif symbol == 'eval':
                ctx = {'a': 2}
                d = { 'value': eval(code,ctx) }
                r = { 'value': eval(str,ctx) }
            self.assertEqual(unify_callables(r),unify_callables(d))
        else:
            expected = compile(str, "<input>", symbol, PyCF_DONT_IMPLY_DEDENT)
            self.assertEqual(compile_command(str, "<input>", symbol), expected)


            

Reported by Bandit.

Redefining built-in 'str'
Error

Line: 47 Column: 32

                          expected = compile(str, "<input>", symbol, PyCF_DONT_IMPLY_DEDENT)
            self.assertEqual(compile_command(str, "<input>", symbol), expected)

    def assertIncomplete(self, str, symbol='single'):
        '''succeed iff str is the start of a valid piece of code'''
        self.assertEqual(compile_command(str, symbol=symbol), None)

    def assertInvalid(self, str, symbol='single', is_syntax=1):
        '''succeed iff str is the start of an invalid piece of code'''

            

Reported by Pylint.