The following issues were found

Lib/concurrent/futures/thread.py
27 issues
Using the global statement
Error

Line: 24 Column: 5

              _global_shutdown_lock = threading.Lock()

def _python_exit():
    global _shutdown
    with _global_shutdown_lock:
        _shutdown = True
    items = list(_threads_queues.items())
    for t, q in items:
        q.put(None)

            

Reported by Pylint.

Access to a protected member _register_atexit of a client class
Error

Line: 37 Column: 1

              # non-daemon threads. This is used instead of `atexit.register()` for
# compatibility with subinterpreters, which no longer support daemon threads.
# See bpo-39812 for context.
threading._register_atexit(_python_exit)


class _WorkItem(object):
    def __init__(self, future, fn, args, kwargs):
        self.future = future

            

Reported by Pylint.

Catching too general exception BaseException
Error

Line: 53 Column: 16

              
        try:
            result = self.fn(*self.args, **self.kwargs)
        except BaseException as exc:
            self.future.set_exception(exc)
            # Break a reference cycle with the exception 'exc'
            self = None
        else:
            self.future.set_result(result)

            

Reported by Pylint.

Invalid assignment to self in method
Error

Line: 56 Column: 13

                      except BaseException as exc:
            self.future.set_exception(exc)
            # Break a reference cycle with the exception 'exc'
            self = None
        else:
            self.future.set_result(result)

    __class_getitem__ = classmethod(types.GenericAlias)


            

Reported by Pylint.

Catching too general exception BaseException
Error

Line: 67 Column: 16

                  if initializer is not None:
        try:
            initializer(*initargs)
        except BaseException:
            _base.LOGGER.critical('Exception in initializer:', exc_info=True)
            executor = executor_reference()
            if executor is not None:
                executor._initializer_failed()
            return

            

Reported by Pylint.

Access to a protected member _initializer_failed of a client class
Error

Line: 71 Column: 17

                          _base.LOGGER.critical('Exception in initializer:', exc_info=True)
            executor = executor_reference()
            if executor is not None:
                executor._initializer_failed()
            return
    try:
        while True:
            work_item = work_queue.get(block=True)
            if work_item is not None:

            

Reported by Pylint.

Access to a protected member _idle_semaphore of a client class
Error

Line: 84 Column: 21

                              # attempt to increment idle count
                executor = executor_reference()
                if executor is not None:
                    executor._idle_semaphore.release()
                del executor
                continue

            executor = executor_reference()
            # Exit if:

            

Reported by Pylint.

Access to a protected member _shutdown of a client class
Error

Line: 93 Column: 49

                          #   - The interpreter is shutting down OR
            #   - The executor that owns the worker has been collected OR
            #   - The executor that owns the worker has been shutdown.
            if _shutdown or executor is None or executor._shutdown:
                # Flag the executor as shutting down as early as possible if it
                # is not gc-ed yet.
                if executor is not None:
                    executor._shutdown = True
                # Notice other workers

            

Reported by Pylint.

Access to a protected member _shutdown of a client class
Error

Line: 97 Column: 21

                              # Flag the executor as shutting down as early as possible if it
                # is not gc-ed yet.
                if executor is not None:
                    executor._shutdown = True
                # Notice other workers
                work_queue.put(None)
                return
            del executor
    except BaseException:

            

Reported by Pylint.

Catching too general exception BaseException
Error

Line: 102 Column: 12

                              work_queue.put(None)
                return
            del executor
    except BaseException:
        _base.LOGGER.critical('Exception in worker', exc_info=True)


class BrokenThreadPool(_base.BrokenExecutor):
    """

            

Reported by Pylint.

Lib/idlelib/idle_test/test_history.py
27 issues
Redefining name 'History' from outer scope (line 3)
Error

Line: 94 Column: 9

                      # Perform one fetch as invoked by Alt-N or Alt-P
        # Test the result. The line test is the most important.
        # The last two are diagnostic of fetch internals.
        History = self.history
        History.fetch(reverse)

        Equal = self.assertEqual
        Equal(self.text.get('iomark', 'end-1c'), line)
        Equal(self.text._bell, bell)

            

Reported by Pylint.

Access to a protected member _bell of a client class
Error

Line: 99 Column: 15

              
        Equal = self.assertEqual
        Equal(self.text.get('iomark', 'end-1c'), line)
        Equal(self.text._bell, bell)
        if bell:
            self.text._bell = False
        Equal(History.prefix, prefix)
        Equal(History.pointer, index)
        Equal(self.text.compare("insert", '==', "end-1c"), 1)

            

Reported by Pylint.

Access to a protected member _bell of a client class
Error

Line: 101 Column: 13

                      Equal(self.text.get('iomark', 'end-1c'), line)
        Equal(self.text._bell, bell)
        if bell:
            self.text._bell = False
        Equal(History.prefix, prefix)
        Equal(History.pointer, index)
        Equal(self.text.compare("insert", '==', "end-1c"), 1)

    def test_fetch_prev_cyclic(self):

            

Reported by Pylint.

standard import "import unittest" should be placed before "from idlelib.history import History"
Error

Line: 4 Column: 1

              " Test history, coverage 100%."

from idlelib.history import History
import unittest
from test.support import requires

import tkinter as tk
from tkinter import Text as tkText
from idlelib.idle_test.mock_tk import Text as mkText

            

Reported by Pylint.

standard import "from test.support import requires" should be placed before "from idlelib.history import History"
Error

Line: 5 Column: 1

              
from idlelib.history import History
import unittest
from test.support import requires

import tkinter as tk
from tkinter import Text as tkText
from idlelib.idle_test.mock_tk import Text as mkText
from idlelib.config import idleConf

            

Reported by Pylint.

standard import "import tkinter as tk" should be placed before "from idlelib.history import History"
Error

Line: 7 Column: 1

              import unittest
from test.support import requires

import tkinter as tk
from tkinter import Text as tkText
from idlelib.idle_test.mock_tk import Text as mkText
from idlelib.config import idleConf

line1 = 'a = 7'

            

Reported by Pylint.

standard import "from tkinter import Text as tkText" should be placed before "from idlelib.history import History"
Error

Line: 8 Column: 1

              from test.support import requires

import tkinter as tk
from tkinter import Text as tkText
from idlelib.idle_test.mock_tk import Text as mkText
from idlelib.config import idleConf

line1 = 'a = 7'
line2 = 'b = a'

            

Reported by Pylint.

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

Line: 12 Column: 1

              from idlelib.idle_test.mock_tk import Text as mkText
from idlelib.config import idleConf

line1 = 'a = 7'
line2 = 'b = a'


class StoreTest(unittest.TestCase):
    '''Tests History.__init__ and History.store with mock Text'''

            

Reported by Pylint.

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

Line: 13 Column: 1

              from idlelib.config import idleConf

line1 = 'a = 7'
line2 = 'b = a'


class StoreTest(unittest.TestCase):
    '''Tests History.__init__ and History.store with mock Text'''


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 28 Column: 5

                      self.text.delete('1.0', 'end')
        self.history.history = []

    def test_init(self):
        self.assertIs(self.history.text, self.text)
        self.assertEqual(self.history.history, [])
        self.assertIsNone(self.history.prefix)
        self.assertIsNone(self.history.pointer)
        self.assertEqual(self.history.cyclic,

            

Reported by Pylint.

Lib/ctypes/test/test_refcounts.py
27 issues
Access to a protected member _testfunc_callback_i_if of a client class
Error

Line: 18 Column: 13

                  def test_1(self):
        from sys import getrefcount as grc

        f = dll._testfunc_callback_i_if
        f.restype = ctypes.c_int
        f.argtypes = [ctypes.c_int, MyCallback]

        def callback(value):
            #print "called back with", value

            

Reported by Pylint.

Unused argument 'args'
Error

Line: 42 Column: 1

                  @support.refcount_test
    def test_refcount(self):
        from sys import getrefcount as grc
        def func(*args):
            pass
        # this is the standard refcount for func
        self.assertEqual(grc(func), 2)

        # the CFuncPtr instance holds at least one refcount on func:

            

Reported by Pylint.

Attribute 'a' defined outside __init__
Error

Line: 62 Column: 9

                      class X(ctypes.Structure):
            _fields_ = [("a", OtherCallback)]
        x = X()
        x.a = OtherCallback(func)

        # the CFuncPtr instance holds at least one refcount on func:
        self.assertGreater(grc(func), 2)

        # and may release it again

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import unittest
from test import support
import ctypes
import gc

MyCallback = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int)
OtherCallback = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int, ctypes.c_ulonglong)

import _ctypes_test

            

Reported by Pylint.

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

Line: 9 Column: 1

              MyCallback = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int)
OtherCallback = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int, ctypes.c_ulonglong)

import _ctypes_test
dll = ctypes.CDLL(_ctypes_test.__file__)

class RefcountTestCase(unittest.TestCase):

    @support.refcount_test

            

Reported by Pylint.

Missing class docstring
Error

Line: 12 Column: 1

              import _ctypes_test
dll = ctypes.CDLL(_ctypes_test.__file__)

class RefcountTestCase(unittest.TestCase):

    @support.refcount_test
    def test_1(self):
        from sys import getrefcount as grc


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 15 Column: 5

              class RefcountTestCase(unittest.TestCase):

    @support.refcount_test
    def test_1(self):
        from sys import getrefcount as grc

        f = dll._testfunc_callback_i_if
        f.restype = ctypes.c_int
        f.argtypes = [ctypes.c_int, MyCallback]

            

Reported by Pylint.

Import outside toplevel (sys.getrefcount)
Error

Line: 16 Column: 9

              
    @support.refcount_test
    def test_1(self):
        from sys import getrefcount as grc

        f = dll._testfunc_callback_i_if
        f.restype = ctypes.c_int
        f.argtypes = [ctypes.c_int, MyCallback]


            

Reported by Pylint.

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

Line: 18 Column: 9

                  def test_1(self):
        from sys import getrefcount as grc

        f = dll._testfunc_callback_i_if
        f.restype = ctypes.c_int
        f.argtypes = [ctypes.c_int, MyCallback]

        def callback(value):
            #print "called back with", value

            

Reported by Pylint.

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

Line: 27 Column: 9

                          return value

        self.assertEqual(grc(callback), 2)
        cb = MyCallback(callback)

        self.assertGreater(grc(callback), 2)
        result = f(-10, cb)
        self.assertEqual(result, -18)
        cb = None

            

Reported by Pylint.

Lib/idlelib/idle_test/test_pathbrowser.py
27 issues
Access to a protected member _modules of a client class
Error

Line: 38 Column: 12

                      pb = self.pb
        eq = self.assertEqual
        eq(pb.master, self.root)
        eq(pyclbr._modules, {})
        self.assertIsInstance(pb.node, TreeNode)
        self.assertIsNotNone(browser.file_open)

    def test_settitle(self):
        pb = self.pb

            

Reported by Pylint.

Redefining built-in 'dir'
Error

Line: 70 Column: 9

                      d.GetSubList()
        self.assertEqual('', d.GetText())

        dir = os.path.split(os.path.abspath(idlelib.__file__))[0]
        self.assertEqual(d.ispackagedir(dir), True)
        self.assertEqual(d.ispackagedir(dir + '/Icons'), False)


class PathBrowserTreeItemTest(unittest.TestCase):

            

Reported by Pylint.

standard import "import unittest" should be placed before "from idlelib import pathbrowser"
Error

Line: 4 Column: 1

              "Test pathbrowser, coverage 95%."

from idlelib import pathbrowser
import unittest
from test.support import requires
from tkinter import Tk

import os.path
import pyclbr  # for _modules

            

Reported by Pylint.

standard import "from test.support import requires" should be placed before "from idlelib import pathbrowser"
Error

Line: 5 Column: 1

              
from idlelib import pathbrowser
import unittest
from test.support import requires
from tkinter import Tk

import os.path
import pyclbr  # for _modules
import sys  # for sys.path

            

Reported by Pylint.

standard import "from tkinter import Tk" should be placed before "from idlelib import pathbrowser"
Error

Line: 6 Column: 1

              from idlelib import pathbrowser
import unittest
from test.support import requires
from tkinter import Tk

import os.path
import pyclbr  # for _modules
import sys  # for sys.path


            

Reported by Pylint.

standard import "import os.path" should be placed before "from idlelib import pathbrowser"
Error

Line: 8 Column: 1

              from test.support import requires
from tkinter import Tk

import os.path
import pyclbr  # for _modules
import sys  # for sys.path

from idlelib.idle_test.mock_idle import Func
import idlelib  # for __file__

            

Reported by Pylint.

standard import "import pyclbr" should be placed before "from idlelib import pathbrowser"
Error

Line: 9 Column: 1

              from tkinter import Tk

import os.path
import pyclbr  # for _modules
import sys  # for sys.path

from idlelib.idle_test.mock_idle import Func
import idlelib  # for __file__
from idlelib import browser

            

Reported by Pylint.

standard import "import sys" should be placed before "from idlelib import pathbrowser"
Error

Line: 10 Column: 1

              
import os.path
import pyclbr  # for _modules
import sys  # for sys.path

from idlelib.idle_test.mock_idle import Func
import idlelib  # for __file__
from idlelib import browser
from idlelib.tree import TreeNode

            

Reported by Pylint.

Missing class docstring
Error

Line: 18 Column: 1

              from idlelib.tree import TreeNode


class PathBrowserTest(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        requires('gui')
        cls.root = Tk()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 34 Column: 5

                      cls.root.destroy()
        del cls.root, cls.pb

    def test_init(self):
        pb = self.pb
        eq = self.assertEqual
        eq(pb.master, self.root)
        eq(pyclbr._modules, {})
        self.assertIsInstance(pb.node, TreeNode)

            

Reported by Pylint.

Lib/encodings/idna.py
27 issues
Consider explicitly re-raising using the 'from' keyword
Error

Line: 122 Column: 13

                      try:
            label = label.encode("ascii")
        except UnicodeError:
            raise UnicodeError("Invalid character in IDN label")
    # Step 3: Check for ACE prefix
    if not label.startswith(ace_prefix):
        return str(label, "ascii")

    # Step 4: Remove ACE prefix

            

Reported by Pylint.

Redefining built-in 'input'
Error

Line: 147 Column: 22

              ### Codec APIs

class Codec(codecs.Codec):
    def encode(self, input, errors='strict'):

        if errors != 'strict':
            # IDNA is quite clear that implementations must be strict
            raise UnicodeError("unsupported error handling "+errors)


            

Reported by Pylint.

Redefining built-in 'input'
Error

Line: 184 Column: 22

                          result.extend(ToASCII(label))
        return bytes(result+trailing_dot), len(input)

    def decode(self, input, errors='strict'):

        if errors != 'strict':
            raise UnicodeError("Unsupported error handling "+errors)

        if not input:

            

Reported by Pylint.

XXX obviously wrong, see #3232
Error

Line: 194 Column: 3

              
        # IDNA allows decoding to operate on Unicode strings, too.
        if not isinstance(input, bytes):
            # XXX obviously wrong, see #3232
            input = bytes(input)

        if ace_prefix not in input:
            # Fast path
            try:

            

Reported by Pylint.

Redefining built-in 'input'
Error

Line: 219 Column: 30

                      return ".".join(result)+trailing_dot, len(input)

class IncrementalEncoder(codecs.BufferedIncrementalEncoder):
    def _buffer_encode(self, input, errors, final):
        if errors != 'strict':
            # IDNA is quite clear that implementations must be strict
            raise UnicodeError("unsupported error handling "+errors)

        if not input:

            

Reported by Pylint.

Redefining built-in 'input'
Error

Line: 254 Column: 30

                      return (bytes(result), size)

class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
    def _buffer_decode(self, input, errors, final):
        if errors != 'strict':
            raise UnicodeError("Unsupported error handling "+errors)

        if not input:
            return ("", 0)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # This module implements the RFCs 3490 (IDNA) and 3491 (Nameprep)

import stringprep, re, codecs
from unicodedata import ucd_3_2_0 as unicodedata

# IDNA section 3.1
dots = re.compile("[\u002E\u3002\uFF0E\uFF61]")

# IDNA section 5

            

Reported by Pylint.

Multiple imports on one line (stringprep, re, codecs)
Error

Line: 3 Column: 1

              # This module implements the RFCs 3490 (IDNA) and 3491 (Nameprep)

import stringprep, re, codecs
from unicodedata import ucd_3_2_0 as unicodedata

# IDNA section 3.1
dots = re.compile("[\u002E\u3002\uFF0E\uFF61]")

# IDNA section 5

            

Reported by Pylint.

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

Line: 10 Column: 1

              dots = re.compile("[\u002E\u3002\uFF0E\uFF61]")

# IDNA section 5
ace_prefix = b"xn--"
sace_prefix = "xn--"

# This assumes query strings, so AllowUnassigned is true
def nameprep(label):
    # Map

            

Reported by Pylint.

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

Line: 11 Column: 1

              
# IDNA section 5
ace_prefix = b"xn--"
sace_prefix = "xn--"

# This assumes query strings, so AllowUnassigned is true
def nameprep(label):
    # Map
    newlabel = []

            

Reported by Pylint.

Lib/distutils/tests/test_archive_util.py
27 issues
Unused import zlib
Error

Line: 34 Column: 5

                  ZIP_SUPPORT = find_executable('zip')

try:
    import zlib
    ZLIB_SUPPORT = True
except ImportError:
    ZLIB_SUPPORT = False

try:

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 297 Column: 13

                      try:
            try:
                make_archive('xxx', 'xxx', root_dir=self.mkdtemp())
            except:
                pass
            self.assertEqual(os.getcwd(), current_dir)
        finally:
            del ARCHIVE_FORMATS['xxx']


            

Reported by Pylint.

Missing class docstring
Error

Line: 62 Column: 1

                  return True


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

    @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run')
    def test_make_tarball(self, name='archive'):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 67 Column: 5

                                        unittest.TestCase):

    @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run')
    def test_make_tarball(self, name='archive'):
        # creating something to tar
        tmpdir = self._create_files()
        self._make_tarball(tmpdir, name, '.tar.gz')
        # trying an uncompressed one
        self._make_tarball(tmpdir, name, '.tar', compress=None)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 75 Column: 5

                      self._make_tarball(tmpdir, name, '.tar', compress=None)

    @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run')
    def test_make_tarball_gzip(self):
        tmpdir = self._create_files()
        self._make_tarball(tmpdir, 'archive', '.tar.gz', compress='gzip')

    @unittest.skipUnless(bz2, 'Need bz2 support to run')
    def test_make_tarball_bzip2(self):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 80 Column: 5

                      self._make_tarball(tmpdir, 'archive', '.tar.gz', compress='gzip')

    @unittest.skipUnless(bz2, 'Need bz2 support to run')
    def test_make_tarball_bzip2(self):
        tmpdir = self._create_files()
        self._make_tarball(tmpdir, 'archive', '.tar.bz2', compress='bzip2')

    @unittest.skipUnless(lzma, 'Need lzma support to run')
    def test_make_tarball_xz(self):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 85 Column: 5

                      self._make_tarball(tmpdir, 'archive', '.tar.bz2', compress='bzip2')

    @unittest.skipUnless(lzma, 'Need lzma support to run')
    def test_make_tarball_xz(self):
        tmpdir = self._create_files()
        self._make_tarball(tmpdir, 'archive', '.tar.xz', compress='xz')

    @unittest.skipUnless(can_fs_encode('årchiv'),
        'File system cannot handle this filename')

            

Reported by Pylint.

Method could be a function
Error

Line: 122 Column: 5

                      self.assertTrue(os.path.exists(tarball))
        self.assertEqual(self._tarinfo(tarball), self._created_files)

    def _tarinfo(self, path):
        tar = tarfile.open(path)
        try:
            names = tar.getnames()
            names.sort()
            return names

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 150 Column: 5

                  @unittest.skipUnless(find_executable('tar') and find_executable('gzip')
                         and ZLIB_SUPPORT,
                         'Need the tar, gzip and zlib command to run')
    def test_tarfile_vs_tar(self):
        tmpdir =  self._create_files()
        tmpdir2 = self.mkdtemp()
        base_name = os.path.join(tmpdir2, 'archive')
        old_dir = os.getcwd()
        os.chdir(tmpdir)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 206 Column: 5

              
    @unittest.skipUnless(find_executable('compress'),
                         'The compress program is required')
    def test_compress_deprecated(self):
        tmpdir =  self._create_files()
        base_name = os.path.join(self.mkdtemp(), 'archive')

        # using compress and testing the PendingDeprecationWarning
        old_dir = os.getcwd()

            

Reported by Pylint.

Tools/scripts/ifdef.py
27 issues
Missing module docstring
Error

Line: 1 Column: 1

              #! /usr/bin/env python3

# Selectively preprocess #ifdef / #ifndef statements.
# Usage:
# ifdef [-Dname] ... [-Uname] ... [file] ...
#
# This scans the file(s), looking for #ifdef and #ifndef preprocessor
# commands that test for one of the names mentioned in the -D and -U
# options.  On standard output it writes a copy of the input file(s)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 35 Column: 1

              defs = []
undefs = []

def main():
    opts, args = getopt.getopt(sys.argv[1:], 'D:U:')
    for o, a in opts:
        if o == '-D':
            defs.append(a)
        if o == '-U':

            

Reported by Pylint.

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

Line: 37 Column: 12

              
def main():
    opts, args = getopt.getopt(sys.argv[1:], 'D:U:')
    for o, a in opts:
        if o == '-D':
            defs.append(a)
        if o == '-U':
            undefs.append(a)
    if not args:

            

Reported by Pylint.

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

Line: 37 Column: 9

              
def main():
    opts, args = getopt.getopt(sys.argv[1:], 'D:U:')
    for o, a in opts:
        if o == '-D':
            defs.append(a)
        if o == '-U':
            undefs.append(a)
    if not args:

            

Reported by Pylint.

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

Line: 48 Column: 36

                      if filename == '-':
            process(sys.stdin, sys.stdout)
        else:
            with open(filename) as f:
                process(f, sys.stdout)

def process(fpi, fpo):
    keywords = ('if', 'ifdef', 'ifndef', 'else', 'endif')
    ok = 1

            

Reported by Pylint.

Too many branches (29/12)
Error

Line: 51 Column: 1

                          with open(filename) as f:
                process(f, sys.stdout)

def process(fpi, fpo):
    keywords = ('if', 'ifdef', 'ifndef', 'else', 'endif')
    ok = 1
    stack = []
    while 1:
        line = fpi.readline()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 51 Column: 1

                          with open(filename) as f:
                process(f, sys.stdout)

def process(fpi, fpo):
    keywords = ('if', 'ifdef', 'ifndef', 'else', 'endif')
    ok = 1
    stack = []
    while 1:
        line = fpi.readline()

            

Reported by Pylint.

Too many statements (67/50)
Error

Line: 51 Column: 1

                          with open(filename) as f:
                process(f, sys.stdout)

def process(fpi, fpo):
    keywords = ('if', 'ifdef', 'ifndef', 'else', 'endif')
    ok = 1
    stack = []
    while 1:
        line = fpi.readline()

            

Reported by Pylint.

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

Line: 53 Column: 5

              
def process(fpi, fpo):
    keywords = ('if', 'ifdef', 'ifndef', 'else', 'endif')
    ok = 1
    stack = []
    while 1:
        line = fpi.readline()
        if not line: break
        while line[-2:] == '\\\n':

            

Reported by Pylint.

More than one statement on a single line
Error

Line: 57 Column: 22

                  stack = []
    while 1:
        line = fpi.readline()
        if not line: break
        while line[-2:] == '\\\n':
            nextline = fpi.readline()
            if not nextline: break
            line = line + nextline
        tmp = line.strip()

            

Reported by Pylint.

Tools/scripts/md5sum.py
27 issues
Redefining built-in 'sum'
Error

Line: 26 Column: 1

              import getopt
from hashlib import md5

def sum(*files):
    sts = 0
    if files and isinstance(files[-1], io.IOBase):
        out, files = files[-1], files[:-1]
    else:
        out = sys.stdout

            

Reported by Pylint.

Use of insecure MD2, MD4, MD5, or SHA1 hash function.
Security blacklist

Line: 57
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b303-md5

                  return sts

def printsumfp(fp, filename, out=sys.stdout):
    m = md5()
    try:
        while 1:
            data = fp.read(bufsize)
            if not data:
                break

            

Reported by Bandit.

Dangerous default value sys.argv[1:] (builtins.list) as argument
Error

Line: 72 Column: 1

                  out.write('%s %s\n' % (m.hexdigest(), filename))
    return 0

def main(args = sys.argv[1:], out=sys.stdout):
    global fnfilter, rmode, bufsize
    try:
        opts, args = getopt.getopt(args, 'blts:')
    except getopt.error as msg:
        sys.stderr.write('%s: %s\n%s' % (sys.argv[0], msg, usage))

            

Reported by Pylint.

Using the global statement
Error

Line: 73 Column: 5

                  return 0

def main(args = sys.argv[1:], out=sys.stdout):
    global fnfilter, rmode, bufsize
    try:
        opts, args = getopt.getopt(args, 'blts:')
    except getopt.error as msg:
        sys.stderr.write('%s: %s\n%s' % (sys.argv[0], msg, usage))
        return 2

            

Reported by Pylint.

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

Line: 7 Column: 1

              """


bufsize = 8096
fnfilter = None
rmode = 'rb'

usage = """
usage: md5sum.py [-b] [-t] [-l] [-s bufsize] [file ...]

            

Reported by Pylint.

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

Line: 8 Column: 1

              

bufsize = 8096
fnfilter = None
rmode = 'rb'

usage = """
usage: md5sum.py [-b] [-t] [-l] [-s bufsize] [file ...]
-b        : read files in binary mode (default)

            

Reported by Pylint.

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

Line: 9 Column: 1

              
bufsize = 8096
fnfilter = None
rmode = 'rb'

usage = """
usage: md5sum.py [-b] [-t] [-l] [-s bufsize] [file ...]
-b        : read files in binary mode (default)
-t        : read files in text mode (you almost certainly don't want this!)

            

Reported by Pylint.

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

Line: 11 Column: 1

              fnfilter = None
rmode = 'rb'

usage = """
usage: md5sum.py [-b] [-t] [-l] [-s bufsize] [file ...]
-b        : read files in binary mode (default)
-t        : read files in text mode (you almost certainly don't want this!)
-l        : print last pathname component only
-s bufsize: read buffer size (default %d)

            

Reported by Pylint.

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

Line: 20 Column: 1

              file ...  : files to sum; '-' or no files means stdin
""" % bufsize

import io
import sys
import os
import getopt
from hashlib import md5


            

Reported by Pylint.

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

Line: 21 Column: 1

              """ % bufsize

import io
import sys
import os
import getopt
from hashlib import md5

def sum(*files):

            

Reported by Pylint.

Lib/multiprocessing/resource_sharer.py
26 issues
Attempted relative import beyond top-level package
Error

Line: 17 Column: 1

              import sys
import threading

from . import process
from .context import reduction
from . import util

__all__ = ['stop']


            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 18 Column: 1

              import threading

from . import process
from .context import reduction
from . import util

__all__ = ['stop']



            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 19 Column: 1

              
from . import process
from .context import reduction
from . import util

__all__ = ['stop']


if sys.platform == 'win32':

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 84 Column: 9

                  @staticmethod
    def get_connection(ident):
        '''Return connection from which to receive identified resource.'''
        from .connection import Client
        address, key = ident
        c = Client(address, authkey=process.current_process().authkey)
        c.send((key, os.getpid()))
        return c


            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 92 Column: 9

              
    def stop(self, timeout=None):
        '''Stop the background thread and clear registered resources.'''
        from .connection import Client
        with self._lock:
            if self._address is not None:
                c = Client(self._address,
                           authkey=process.current_process().authkey)
                c.send(None)

            

Reported by Pylint.

Instance of 'lock' has no '_at_fork_reinit' member
Error

Line: 115 Column: 9

                      for key, (send, close) in self._cache.items():
            close()
        self._cache.clear()
        self._lock._at_fork_reinit()
        if self._listener is not None:
            self._listener.close()
        self._listener = None
        self._address = None
        self._thread = None

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 123 Column: 9

                      self._thread = None

    def _start(self):
        from .connection import Listener
        assert self._listener is None, "Already have Listener"
        util.debug('starting listener and thread for sending handles')
        self._listener = Listener(authkey=process.current_process().authkey)
        self._address = self._listener.address
        t = threading.Thread(target=self._serve)

            

Reported by Pylint.

Unused variable 'key'
Error

Line: 107 Column: 21

                              self._thread = None
                self._address = None
                self._listener = None
                for key, (send, close) in self._cache.items():
                    close()
                self._cache.clear()

    def _afterfork(self):
        for key, (send, close) in self._cache.items():

            

Reported by Pylint.

Unused variable 'send'
Error

Line: 107 Column: 27

                              self._thread = None
                self._address = None
                self._listener = None
                for key, (send, close) in self._cache.items():
                    close()
                self._cache.clear()

    def _afterfork(self):
        for key, (send, close) in self._cache.items():

            

Reported by Pylint.

Unused variable 'key'
Error

Line: 112 Column: 13

                              self._cache.clear()

    def _afterfork(self):
        for key, (send, close) in self._cache.items():
            close()
        self._cache.clear()
        self._lock._at_fork_reinit()
        if self._listener is not None:
            self._listener.close()

            

Reported by Pylint.

Lib/test/test_fnmatch.py
26 issues
Redefining built-in 'filter'
Error

Line: 7 Column: 1

              import os
import warnings

from fnmatch import fnmatch, fnmatchcase, translate, filter

class FnmatchTestCase(unittest.TestCase):

    def check_match(self, filename, pattern, should_match=True, fn=fnmatch):
        if should_match:

            

Reported by Pylint.

Missing class docstring
Error

Line: 9 Column: 1

              
from fnmatch import fnmatch, fnmatchcase, translate, filter

class FnmatchTestCase(unittest.TestCase):

    def check_match(self, filename, pattern, should_match=True, fn=fnmatch):
        if should_match:
            self.assertTrue(fn(filename, pattern),
                         "expected %r to match pattern %r"

            

Reported by Pylint.

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

Line: 11 Column: 5

              
class FnmatchTestCase(unittest.TestCase):

    def check_match(self, filename, pattern, should_match=True, fn=fnmatch):
        if should_match:
            self.assertTrue(fn(filename, pattern),
                         "expected %r to match pattern %r"
                         % (filename, pattern))
        else:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 11 Column: 5

              
class FnmatchTestCase(unittest.TestCase):

    def check_match(self, filename, pattern, should_match=True, fn=fnmatch):
        if should_match:
            self.assertTrue(fn(filename, pattern),
                         "expected %r to match pattern %r"
                         % (filename, pattern))
        else:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 21 Column: 5

                                       "expected %r not to match pattern %r"
                         % (filename, pattern))

    def test_fnmatch(self):
        check = self.check_match
        check('abc', 'abc')
        check('abc', '?*?')
        check('abc', '???*')
        check('abc', '*???')

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 48 Column: 5

                      check('\nfoo', 'foo*', False)
        check('\n', '*')

    def test_slow_fnmatch(self):
        check = self.check_match
        check('a' * 50, '*a*a*a*a*a*a*a*a*a*a')
        # The next "takes forever" if the regexp translation is
        # straightforward.  See bpo-40480.
        check('a' * 50 + 'b', '*a*a*a*a*a*a*a*a*a*a', False)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 55 Column: 5

                      # straightforward.  See bpo-40480.
        check('a' * 50 + 'b', '*a*a*a*a*a*a*a*a*a*a', False)

    def test_mix_bytes_str(self):
        self.assertRaises(TypeError, fnmatch, 'test', b'*')
        self.assertRaises(TypeError, fnmatch, b'test', '*')
        self.assertRaises(TypeError, fnmatchcase, 'test', b'*')
        self.assertRaises(TypeError, fnmatchcase, b'test', '*')


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 61 Column: 5

                      self.assertRaises(TypeError, fnmatchcase, 'test', b'*')
        self.assertRaises(TypeError, fnmatchcase, b'test', '*')

    def test_fnmatchcase(self):
        check = self.check_match
        check('abc', 'abc', True, fnmatchcase)
        check('AbC', 'abc', False, fnmatchcase)
        check('abc', 'AbC', False, fnmatchcase)
        check('AbC', 'AbC', True, fnmatchcase)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 73 Column: 5

                      check('usr/bin', 'usr\\bin', False, fnmatchcase)
        check('usr\\bin', 'usr\\bin', True, fnmatchcase)

    def test_bytes(self):
        self.check_match(b'test', b'te*')
        self.check_match(b'test\xff', b'te*\xff')
        self.check_match(b'foo\nbar', b'foo*')

    def test_case(self):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 78 Column: 5

                      self.check_match(b'test\xff', b'te*\xff')
        self.check_match(b'foo\nbar', b'foo*')

    def test_case(self):
        ignorecase = os.path.normcase('ABC') == os.path.normcase('abc')
        check = self.check_match
        check('abc', 'abc')
        check('AbC', 'abc', ignorecase)
        check('abc', 'AbC', ignorecase)

            

Reported by Pylint.