The following issues were found

Lib/_osx_support.py
39 issues
Starting a process with a shell, possible injection detected, security issue.
Security injection

Line: 74
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b605_start_process_with_a_shell.html

                          cmd = "%s >'%s' 2>&1" % (commandstring, fp.name)
        else:
            cmd = "%s 2>/dev/null >'%s'" % (commandstring, fp.name)
        return fp.read().decode('utf-8').strip() if not os.system(cmd) else None


def _find_build_tool(toolname):
    """Find a build tool on current path or using xcrun"""
    return (_find_executable(toolname)

            

Reported by Bandit.

Starting a process with a shell, possible injection detected, security issue.
Security injection

Line: 292
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b605_start_process_with_a_shell.html

                  if re.search(r'-arch\s+ppc', _config_vars['CFLAGS']) is not None:
        # NOTE: Cannot use subprocess here because of bootstrap
        # issues when building Python itself
        status = os.system(
            """echo 'int main{};' | """
            """'%s' -c -arch ppc -x c -o /dev/null /dev/null 2>/dev/null"""
            %(_config_vars['CC'].replace("'", "'\"'\"'"),))
        if status:
            # The compile failed for some reason.  Because of differences

            

Reported by Bandit.

Unused variable 'base'
Error

Line: 39 Column: 5

                      path = os.environ['PATH']

    paths = path.split(os.pathsep)
    base, ext = os.path.splitext(executable)

    if (sys.platform == 'win32') and (ext != '.exe'):
        executable = executable + '.exe'

    if not os.path.isfile(executable):

            

Reported by Pylint.

Probable insecure usage of temp file/directory.
Security

Line: 66
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b108_hardcoded_tmp_directory.html

                      import tempfile
        fp = tempfile.NamedTemporaryFile()
    except ImportError:
        fp = open("/tmp/_osx_support.%s"%(
            os.getpid(),), "w+b")

    with contextlib.closing(fp) as fp:
        if capture_stderr:
            cmd = "%s >'%s' 2>&1" % (commandstring, fp.name)

            

Reported by Bandit.

Using the global statement
Error

Line: 94 Column: 5

                  # the build of Python itself (distutils is used to build standard library
    # extensions).

    global _SYSTEM_VERSION

    if _SYSTEM_VERSION is None:
        _SYSTEM_VERSION = ''
        try:
            f = open('/System/Library/CoreServices/SystemVersion.plist', encoding="utf-8")

            

Reported by Pylint.

Using the global statement
Error

Line: 124 Column: 5

                  The return value is safe to use to compare
    two version numbers.
    """
    global _SYSTEM_VERSION_TUPLE
    if _SYSTEM_VERSION_TUPLE is None:
        osx_version = _get_system_version()
        if osx_version:
            try:
                _SYSTEM_VERSION_TUPLE = tuple(int(i) for i in osx_version.split('.'))

            

Reported by Pylint.

Using the global statement
Error

Line: 155 Column: 5

              _cache_default_sysroot = None
def _default_sysroot(cc):
    """ Returns the root of the default SDK for this system, or '/' """
    global _cache_default_sysroot

    if _cache_default_sysroot is not None:
        return _cache_default_sysroot

    contents = _read_output('%s -c -E -v - </dev/null' % (cc,), True)

            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 44 Column: 5

                  if (sys.platform == 'win32') and (ext != '.exe'):
        executable = executable + '.exe'

    if not os.path.isfile(executable):
        for p in paths:
            f = os.path.join(p, executable)
            if os.path.isfile(f):
                # the file exists, we have a shot at spawn working
                return f

            

Reported by Pylint.

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

Line: 45 Column: 13

                      executable = executable + '.exe'

    if not os.path.isfile(executable):
        for p in paths:
            f = os.path.join(p, executable)
            if os.path.isfile(f):
                # the file exists, we have a shot at spawn working
                return f
        return None

            

Reported by Pylint.

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

Line: 46 Column: 13

              
    if not os.path.isfile(executable):
        for p in paths:
            f = os.path.join(p, executable)
            if os.path.isfile(f):
                # the file exists, we have a shot at spawn working
                return f
        return None
    else:

            

Reported by Pylint.

Lib/distutils/command/build_clib.py
39 issues
Non-iterable value self.define is used in an iterating context
Error

Line: 109 Column: 33

                          self.compiler.set_include_dirs(self.include_dirs)
        if self.define is not None:
            # 'define' option is a list of (name,value) tuples
            for (name,value) in self.define:
                self.compiler.define_macro(name, value)
        if self.undef is not None:
            for macro in self.undef:
                self.compiler.undefine_macro(macro)


            

Reported by Pylint.

Non-iterable value self.undef is used in an iterating context
Error

Line: 112 Column: 26

                          for (name,value) in self.define:
                self.compiler.define_macro(name, value)
        if self.undef is not None:
            for macro in self.undef:
                self.compiler.undefine_macro(macro)

        self.build_libraries(self.libraries)



            

Reported by Pylint.

XXX this module has *lots* of code ripped-off quite transparently from
Error

Line: 8 Column: 3

              module."""


# XXX this module has *lots* of code ripped-off quite transparently from
# build_ext.py -- not surprisingly really, as the work required to build
# a static library from a collection of C source files is not really all
# that different from what's required to build a shared object file from
# a collection of C source files.  Nevertheless, I haven't done the
# necessary refactoring to account for the overlap in code between the

            

Reported by Pylint.

Unused import CompileError from wildcard import
Error

Line: 19 Column: 1

              
import os
from distutils.core import Command
from distutils.errors import *
from distutils.sysconfig import customize_compiler
from distutils import log

def show_compilers():
    from distutils.ccompiler import show_compilers

            

Reported by Pylint.

Unused import UnknownFileError from wildcard import
Error

Line: 19 Column: 1

              
import os
from distutils.core import Command
from distutils.errors import *
from distutils.sysconfig import customize_compiler
from distutils import log

def show_compilers():
    from distutils.ccompiler import show_compilers

            

Reported by Pylint.

Unused import PreprocessError from wildcard import
Error

Line: 19 Column: 1

              
import os
from distutils.core import Command
from distutils.errors import *
from distutils.sysconfig import customize_compiler
from distutils import log

def show_compilers():
    from distutils.ccompiler import show_compilers

            

Reported by Pylint.

Unused import CCompilerError from wildcard import
Error

Line: 19 Column: 1

              
import os
from distutils.core import Command
from distutils.errors import *
from distutils.sysconfig import customize_compiler
from distutils import log

def show_compilers():
    from distutils.ccompiler import show_compilers

            

Reported by Pylint.

Unused import DistutilsByteCompileError from wildcard import
Error

Line: 19 Column: 1

              
import os
from distutils.core import Command
from distutils.errors import *
from distutils.sysconfig import customize_compiler
from distutils import log

def show_compilers():
    from distutils.ccompiler import show_compilers

            

Reported by Pylint.

Unused import DistutilsTemplateError from wildcard import
Error

Line: 19 Column: 1

              
import os
from distutils.core import Command
from distutils.errors import *
from distutils.sysconfig import customize_compiler
from distutils import log

def show_compilers():
    from distutils.ccompiler import show_compilers

            

Reported by Pylint.

Unused import DistutilsInternalError from wildcard import
Error

Line: 19 Column: 1

              
import os
from distutils.core import Command
from distutils.errors import *
from distutils.sysconfig import customize_compiler
from distutils import log

def show_compilers():
    from distutils.ccompiler import show_compilers

            

Reported by Pylint.

Lib/distutils/tests/support.py
39 issues
Super of 'LoggingSilencer' has no 'setUp' member
Error

Line: 19 Column: 9

              class LoggingSilencer(object):

    def setUp(self):
        super().setUp()
        self.threshold = log.set_threshold(log.FATAL)
        # catching warnings
        # when log will be replaced by logging
        # we won't need such monkey-patch anymore
        self._old_log = log.Log._log

            

Reported by Pylint.

Super of 'LoggingSilencer' has no 'tearDown' member
Error

Line: 31 Column: 9

                  def tearDown(self):
        log.set_threshold(self.threshold)
        log.Log._log = self._old_log
        super().tearDown()

    def _log(self, level, msg, args):
        if level not in (DEBUG, INFO, WARN, ERROR, FATAL):
            raise ValueError('%s wrong log level' % str(level))
        if not isinstance(msg, str):

            

Reported by Pylint.

Super of 'TempdirManager' has no 'setUp' member
Error

Line: 56 Column: 9

                  """

    def setUp(self):
        super().setUp()
        self.old_cwd = os.getcwd()
        self.tempdirs = []

    def tearDown(self):
        # Restore working dir, for Solaris and derivatives, where rmdir()

            

Reported by Pylint.

Super of 'TempdirManager' has no 'tearDown' member
Error

Line: 64 Column: 9

                      # Restore working dir, for Solaris and derivatives, where rmdir()
        # on the current directory fails.
        os.chdir(self.old_cwd)
        super().tearDown()
        while self.tempdirs:
            tmpdir = self.tempdirs.pop()
            os_helper.rmtree(tmpdir)

    def mkdtemp(self):

            

Reported by Pylint.

Super of 'EnvironGuard' has no 'setUp' member
Error

Line: 124 Column: 9

              class EnvironGuard(object):

    def setUp(self):
        super(EnvironGuard, self).setUp()
        self.old_environ = deepcopy(os.environ)

    def tearDown(self):
        for key, value in self.old_environ.items():
            if os.environ.get(key) != value:

            

Reported by Pylint.

Super of 'EnvironGuard' has no 'tearDown' member
Error

Line: 136 Column: 9

                          if key not in self.old_environ:
                del os.environ[key]

        super(EnvironGuard, self).tearDown()


def copy_xxmodule_c(directory):
    """Helper for tests that need the xxmodule.c source file.


            

Reported by Pylint.

Access to a protected member _log of a client class
Error

Line: 24 Column: 25

                      # catching warnings
        # when log will be replaced by logging
        # we won't need such monkey-patch anymore
        self._old_log = log.Log._log
        log.Log._log = self._log
        self.logs = []

    def tearDown(self):
        log.set_threshold(self.threshold)

            

Reported by Pylint.

Access to a protected member _log of a client class
Error

Line: 25 Column: 9

                      # when log will be replaced by logging
        # we won't need such monkey-patch anymore
        self._old_log = log.Log._log
        log.Log._log = self._log
        self.logs = []

    def tearDown(self):
        log.set_threshold(self.threshold)
        log.Log._log = self._old_log

            

Reported by Pylint.

Access to a protected member _log of a client class
Error

Line: 30 Column: 9

              
    def tearDown(self):
        log.set_threshold(self.threshold)
        log.Log._log = self._old_log
        super().tearDown()

    def _log(self, level, msg, args):
        if level not in (DEBUG, INFO, WARN, ERROR, FATAL):
            raise ValueError('%s wrong log level' % str(level))

            

Reported by Pylint.

Unused variable 'equals'
Error

Line: 208 Column: 23

                          if sys.platform == 'darwin':
                cmd.library_dirs = []
            else:
                name, equals, value = runshared.partition('=')
                cmd.library_dirs = [d for d in value.split(os.pathsep) if d]

            

Reported by Pylint.

Lib/xml/etree/cElementTree.py
38 issues
Unused import XMLParser from wildcard import
Error

Line: 3 Column: 1

              # Deprecated alias for xml.etree.ElementTree

from xml.etree.ElementTree import *

            

Reported by Pylint.

Unused import canonicalize from wildcard import
Error

Line: 3 Column: 1

              # Deprecated alias for xml.etree.ElementTree

from xml.etree.ElementTree import *

            

Reported by Pylint.

Unused import C14NWriterTarget from wildcard import
Error

Line: 3 Column: 1

              # Deprecated alias for xml.etree.ElementTree

from xml.etree.ElementTree import *

            

Reported by Pylint.

Unused import XMLPullParser from wildcard import
Error

Line: 3 Column: 1

              # Deprecated alias for xml.etree.ElementTree

from xml.etree.ElementTree import *

            

Reported by Pylint.

Unused import fromstringlist from wildcard import
Error

Line: 3 Column: 1

              # Deprecated alias for xml.etree.ElementTree

from xml.etree.ElementTree import *

            

Reported by Pylint.

Unused import fromstring from wildcard import
Error

Line: 3 Column: 1

              # Deprecated alias for xml.etree.ElementTree

from xml.etree.ElementTree import *

            

Reported by Pylint.

Unused import ElementPath from wildcard import
Error

Line: 3 Column: 1

              # Deprecated alias for xml.etree.ElementTree

from xml.etree.ElementTree import *

            

Reported by Pylint.

Wildcard import xml.etree.ElementTree
Error

Line: 3 Column: 1

              # Deprecated alias for xml.etree.ElementTree

from xml.etree.ElementTree import *

            

Reported by Pylint.

Unused import VERSION from wildcard import
Error

Line: 3 Column: 1

              # Deprecated alias for xml.etree.ElementTree

from xml.etree.ElementTree import *

            

Reported by Pylint.

Unused import sys from wildcard import
Error

Line: 3 Column: 1

              # Deprecated alias for xml.etree.ElementTree

from xml.etree.ElementTree import *

            

Reported by Pylint.

Tools/unicode/genmap_support.py
38 issues
Unused argument 'wide'
Error

Line: 53 Column: 64

                      self.decode_map = decode_map
        self.filler = self.filler_class()

    def update_decode_map(self, c1range, c2range, onlymask=(), wide=0):
        c2values = range(c2range[0], c2range[1] + 1)

        for c1 in range(c1range[0], c1range[1] + 1):
            if c1 not in self.decode_map or (onlymask and c1 not in onlymask):
                continue

            

Reported by Pylint.

Unused argument 'point'
Error

Line: 146 Column: 28

                  def write_nochar(self):
        self.filler.write('N,')

    def write_multic(self, point):
        self.filler.write('M,')

    def write_char(self, point):
        self.filler.write(str(point) + ',')


            

Reported by Pylint.

Consider explicitly re-raising using the 'from' keyword
Error

Line: 175 Column: 9

                  try:
        f = open(path)
    except IOError:
        raise SystemExit(f'{source} is needed')
    return f


def print_autogen(fo, source):
    fo.write(f'// AUTO-GENERATED FILE FROM {source}: DO NOT EDIT\n')

            

Reported by Pylint.

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

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

                      if not line or len(line.split()) < 2:
            continue

        row = [eval(e) for e in line.split()]
        loc, uni = row[natcol], row[unicol]
        if loc >= 0x100 or sbcs:
            decmap.setdefault((loc >> 8), {})
            decmap[(loc >> 8)][(loc & 0xff)] = uni


            

Reported by Bandit.

Use of eval
Error

Line: 192 Column: 16

                      if not line or len(line.split()) < 2:
            continue

        row = [eval(e) for e in line.split()]
        loc, uni = row[natcol], row[unicol]
        if loc >= 0x100 or sbcs:
            decmap.setdefault((loc >> 8), {})
            decmap[(loc >> 8)][(loc & 0xff)] = uni


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #
# genmap_support.py: Multibyte Codec Map Generator
#
# Original Author:  Hye-Shik Chang <perky@FreeBSD.org>
# Modified Author:  Dong-hee Na <donghee.na92@gmail.com>
#


class BufferedFiller:

            

Reported by Pylint.

Missing class docstring
Error

Line: 9 Column: 1

              #


class BufferedFiller:
    def __init__(self, column=78):
        self.column = column
        self.buffered = []
        self.cline = []
        self.clen = 0

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 5

                      self.clen = 0
        self.count = 0

    def write(self, *data):
        for s in data:
            if len(s) > self.column:
                raise ValueError("token is too long")
            if len(s) + self.clen > self.column:
                self.flush()

            

Reported by Pylint.

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

Line: 18 Column: 13

                      self.count = 0

    def write(self, *data):
        for s in data:
            if len(s) > self.column:
                raise ValueError("token is too long")
            if len(s) + self.clen > self.column:
                self.flush()
            self.clen += len(s)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 27 Column: 5

                          self.cline.append(s)
            self.count += 1

    def flush(self):
        if not self.cline:
            return
        self.buffered.append(''.join(self.cline))
        self.clen = 0
        del self.cline[:]

            

Reported by Pylint.

Lib/test/test_compare.py
38 issues
Method has no argument
Error

Line: 54 Column: 13

                      calls = []
        class Left:
            # Inherits object.__ne__()
            def __eq__(*args):
                calls.append('Left.__eq__')
                return NotImplemented
        class Right:
            def __eq__(*args):
                calls.append('Right.__eq__')

            

Reported by Pylint.

Method has no argument
Error

Line: 58 Column: 13

                              calls.append('Left.__eq__')
                return NotImplemented
        class Right:
            def __eq__(*args):
                calls.append('Right.__eq__')
                return NotImplemented
            def __ne__(*args):
                calls.append('Right.__ne__')
                return NotImplemented

            

Reported by Pylint.

Method has no argument
Error

Line: 61 Column: 13

                          def __eq__(*args):
                calls.append('Right.__eq__')
                return NotImplemented
            def __ne__(*args):
                calls.append('Right.__ne__')
                return NotImplemented
        Left() != Right()
        self.assertSequenceEqual(calls, ['Left.__eq__', 'Right.__ne__'])


            

Reported by Pylint.

Method has no argument
Error

Line: 72 Column: 13

                      calls = []
        class Base:
            # Inherits object.__ne__()
            def __eq__(*args):
                calls.append('Base.__eq__')
                return NotImplemented
        class Derived(Base):  # Subclassing forces higher priority
            def __eq__(*args):
                calls.append('Derived.__eq__')

            

Reported by Pylint.

Method has no argument
Error

Line: 76 Column: 13

                              calls.append('Base.__eq__')
                return NotImplemented
        class Derived(Base):  # Subclassing forces higher priority
            def __eq__(*args):
                calls.append('Derived.__eq__')
                return NotImplemented
            def __ne__(*args):
                calls.append('Derived.__ne__')
                return NotImplemented

            

Reported by Pylint.

Method has no argument
Error

Line: 79 Column: 13

                          def __eq__(*args):
                calls.append('Derived.__eq__')
                return NotImplemented
            def __ne__(*args):
                calls.append('Derived.__ne__')
                return NotImplemented
        Base() != Derived()
        self.assertSequenceEqual(calls, ['Derived.__ne__', 'Base.__eq__'])


            

Reported by Pylint.

Unused variable 'i'
Error

Line: 34 Column: 13

                  def test_id_comparisons(self):
        # Ensure default comparison compares id() of args
        L = []
        for i in range(10):
            L.insert(len(L)//2, Empty())
        for a in L:
            for b in L:
                self.assertEqual(a == b, id(a) == id(b),
                                 'a=%r, b=%r' % (a, b))

            

Reported by Pylint.

Expression "Left() != Right()" is assigned to nothing
Error

Line: 64 Column: 9

                          def __ne__(*args):
                calls.append('Right.__ne__')
                return NotImplemented
        Left() != Right()
        self.assertSequenceEqual(calls, ['Left.__eq__', 'Right.__ne__'])

    def test_ne_low_priority(self):
        """object.__ne__() should not invoke reflected __eq__()"""
        calls = []

            

Reported by Pylint.

Expression "Base() != Derived()" is assigned to nothing
Error

Line: 82 Column: 9

                          def __ne__(*args):
                calls.append('Derived.__ne__')
                return NotImplemented
        Base() != Derived()
        self.assertSequenceEqual(calls, ['Derived.__ne__', 'Base.__eq__'])

    def test_other_delegation(self):
        """No default delegation between operations except __ne__()"""
        ops = (

            

Reported by Pylint.

Unused argument 'args'
Error

Line: 96 Column: 1

                      )
        for name, func in ops:
            with self.subTest(name):
                def unexpected(*args):
                    self.fail('Unexpected operator method called')
                class C:
                    __ne__ = unexpected
                for other, _ in ops:
                    if other != name:

            

Reported by Pylint.

Lib/test/libregrtest/refleak.py
38 issues
Module 'zipimport' has no '_zip_directory_cache' member
Error

Line: 50 Column: 15

                  except ImportError:
        zdc = None # Run unmodified on platforms without zipimport support
    else:
        zdc = zipimport._zip_directory_cache.copy()
    abcs = {}
    for abc in [getattr(collections.abc, a) for a in collections.abc.__all__]:
        if not isabstract(abc):
            continue
        for obj in abc.__subclasses__() + [abc]:

            

Reported by Pylint.

Module 'sys' has no 'gettotalrefcount' member
Error

Line: 76 Column: 24

                  alloc_deltas = [0] * repcount
    fd_deltas = [0] * repcount
    getallocatedblocks = sys.getallocatedblocks
    gettotalrefcount = sys.gettotalrefcount
    _getquickenedcount = sys._getquickenedcount
    fd_count = os_helper.fd_count
    # initialize variables to make pyflakes quiet
    rc_before = alloc_before = fd_before = 0


            

Reported by Pylint.

Module 'sys' has no '_getquickenedcount' member
Error

Line: 77 Column: 26

                  fd_deltas = [0] * repcount
    getallocatedblocks = sys.getallocatedblocks
    gettotalrefcount = sys.gettotalrefcount
    _getquickenedcount = sys._getquickenedcount
    fd_count = os_helper.fd_count
    # initialize variables to make pyflakes quiet
    rc_before = alloc_before = fd_before = 0

    if not ns.quiet:

            

Reported by Pylint.

Module 'zipimport' has no '_zip_directory_cache' member
Error

Line: 166 Column: 9

                  except ImportError:
        pass # Run unmodified on platforms without zipimport support
    else:
        zipimport._zip_directory_cache.clear()
        zipimport._zip_directory_cache.update(zdc)

    # clear type cache
    sys._clear_type_cache()


            

Reported by Pylint.

Module 'zipimport' has no '_zip_directory_cache' member
Error

Line: 167 Column: 9

                      pass # Run unmodified on platforms without zipimport support
    else:
        zipimport._zip_directory_cache.clear()
        zipimport._zip_directory_cache.update(zdc)

    # clear type cache
    sys._clear_type_cache()

    # Clear ABC registries, restoring previously saved ABC registries.

            

Reported by Pylint.

Unused import re
Error

Line: 2 Column: 1

              import os
import re
import sys
import warnings
from inspect import isabstract
from test import support
from test.support import os_helper
from test.libregrtest.utils import clear_caches


            

Reported by Pylint.

Unused support imported from test
Error

Line: 6 Column: 1

              import sys
import warnings
from inspect import isabstract
from test import support
from test.support import os_helper
from test.libregrtest.utils import clear_caches

try:
    from _abc import _get_dump

            

Reported by Pylint.

Access to a protected member _abc_registry of a client class
Error

Line: 18 Column: 61

                  def _get_dump(cls):
        # Reimplement _get_dump() for pure-Python implementation of
        # the abc module (Lib/_py_abc.py)
        registry_weakrefs = set(weakref.ref(obj) for obj in cls._abc_registry)
        return (registry_weakrefs, cls._abc_cache,
                cls._abc_negative_cache, cls._abc_negative_cache_version)


def dash_R(ns, test_name, test_func):

            

Reported by Pylint.

Access to a protected member _abc_cache of a client class
Error

Line: 19 Column: 36

                      # Reimplement _get_dump() for pure-Python implementation of
        # the abc module (Lib/_py_abc.py)
        registry_weakrefs = set(weakref.ref(obj) for obj in cls._abc_registry)
        return (registry_weakrefs, cls._abc_cache,
                cls._abc_negative_cache, cls._abc_negative_cache_version)


def dash_R(ns, test_name, test_func):
    """Run a test multiple times, looking for reference leaks.

            

Reported by Pylint.

Access to a protected member _abc_negative_cache_version of a client class
Error

Line: 20 Column: 42

                      # the abc module (Lib/_py_abc.py)
        registry_weakrefs = set(weakref.ref(obj) for obj in cls._abc_registry)
        return (registry_weakrefs, cls._abc_cache,
                cls._abc_negative_cache, cls._abc_negative_cache_version)


def dash_R(ns, test_name, test_func):
    """Run a test multiple times, looking for reference leaks.


            

Reported by Pylint.

Lib/test/test_descrtut.py
38 issues
Unused sortdict imported from test.support
Error

Line: 11 Column: 1

              # of much interest anymore), and a few were fiddled to make the output
# deterministic.

from test.support import sortdict
import pprint

class defaultdict(dict):
    def __init__(self, default=None):
        dict.__init__(self)

            

Reported by Pylint.

Unused import pprint
Error

Line: 12 Column: 1

              # deterministic.

from test.support import sortdict
import pprint

class defaultdict(dict):
    def __init__(self, default=None):
        dict.__init__(self)
        self.default = default

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # This contains most of the executable examples from Guido's descr
# tutorial, once at
#
#     http://www.python.org/2.2/descrintro.html
#
# A few examples left implicit in the writeup were fleshed out, a few were
# skipped due to lack of interest (e.g., faking super() by hand isn't
# of much interest anymore), and a few were fiddled to make the output
# deterministic.

            

Reported by Pylint.

Class name "defaultdict" doesn't conform to PascalCase naming style
Error

Line: 14 Column: 1

              from test.support import sortdict
import pprint

class defaultdict(dict):
    def __init__(self, default=None):
        dict.__init__(self)
        self.default = default

    def __getitem__(self, key):

            

Reported by Pylint.

Missing class docstring
Error

Line: 14 Column: 1

              from test.support import sortdict
import pprint

class defaultdict(dict):
    def __init__(self, default=None):
        dict.__init__(self)
        self.default = default

    def __getitem__(self, key):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 30 Column: 5

                          args = (self.default,)
        return dict.get(self, key, *args)

    def merge(self, other):
        for key in other:
            if key not in self:
                self[key] = other[key]

test_1 = """

            

Reported by Pylint.

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

Line: 35 Column: 1

                          if key not in self:
                self[key] = other[key]

test_1 = """

Here's the new type at work:

    >>> print(defaultdict)              # show our type
    <class 'test.test_descrtut.defaultdict'>

            

Reported by Pylint.

Class name "defaultdict2" doesn't conform to PascalCase naming style
Error

Line: 102 Column: 1

                  >>>
"""

class defaultdict2(dict):
    __slots__ = ['default']

    def __init__(self, default=None):
        dict.__init__(self)
        self.default = default

            

Reported by Pylint.

Missing class docstring
Error

Line: 102 Column: 1

                  >>>
"""

class defaultdict2(dict):
    __slots__ = ['default']

    def __init__(self, default=None):
        dict.__init__(self)
        self.default = default

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 120 Column: 5

                          args = (self.default,)
        return dict.get(self, key, *args)

    def merge(self, other):
        for key in other:
            if key not in self:
                self[key] = other[key]

test_2 = """

            

Reported by Pylint.

Lib/test/libregrtest/utils.py
38 issues
Using the global statement
Error

Line: 79 Column: 5

              

def regrtest_unraisable_hook(unraisable):
    global orig_unraisablehook
    support.environment_altered = True
    print_warning("Unraisable exception")
    old_stderr = sys.stderr
    try:
        flush_std_streams()

            

Reported by Pylint.

Using the global statement
Error

Line: 93 Column: 5

              

def setup_unraisable_hook():
    global orig_unraisablehook
    orig_unraisablehook = sys.unraisablehook
    sys.unraisablehook = regrtest_unraisable_hook


orig_threading_excepthook = None

            

Reported by Pylint.

Using the global statement
Error

Line: 102 Column: 5

              

def regrtest_threading_excepthook(args):
    global orig_threading_excepthook
    support.environment_altered = True
    print_warning(f"Uncaught thread exception: {args.exc_type.__name__}")
    old_stderr = sys.stderr
    try:
        flush_std_streams()

            

Reported by Pylint.

Using the global statement
Error

Line: 116 Column: 5

              

def setup_threading_excepthook():
    global orig_threading_excepthook
    import threading
    orig_threading_excepthook = threading.excepthook
    threading.excepthook = regrtest_threading_excepthook



            

Reported by Pylint.

Access to a protected member _path_created of a client class
Error

Line: 141 Column: 9

                  except KeyError:
        pass
    else:
        distutils_dir_util._path_created.clear()

    try:
        re = sys.modules['re']
    except KeyError:
        pass

            

Reported by Pylint.

Access to a protected member _regex_cache of a client class
Error

Line: 155 Column: 9

                  except KeyError:
        pass
    else:
        _strptime._regex_cache.clear()

    try:
        urllib_parse = sys.modules['urllib.parse']
    except KeyError:
        pass

            

Reported by Pylint.

Access to a protected member _default_mime_types of a client class
Error

Line: 183 Column: 9

                  except KeyError:
        pass
    else:
        mimetypes._default_mime_types()

    try:
        filecmp = sys.modules['filecmp']
    except KeyError:
        pass

            

Reported by Pylint.

Access to a protected member _cache of a client class
Error

Line: 190 Column: 9

                  except KeyError:
        pass
    else:
        filecmp._cache.clear()

    try:
        struct = sys.modules['struct']
    except KeyError:
        pass

            

Reported by Pylint.

Access to a protected member _clearcache of a client class
Error

Line: 197 Column: 9

                  except KeyError:
        pass
    else:
        struct._clearcache()

    try:
        doctest = sys.modules['doctest']
    except KeyError:
        pass

            

Reported by Pylint.

Access to a protected member _reset_cache of a client class
Error

Line: 211 Column: 9

                  except KeyError:
        pass
    else:
        ctypes._reset_cache()

    try:
        typing = sys.modules['typing']
    except KeyError:
        pass

            

Reported by Pylint.

Lib/test/test_json/test_indent.py
38 issues
Instance of 'TestIndent' has no 'dumps' member
Error

Line: 32 Column: 14

                      \t}
        ]""")

        d1 = self.dumps(h)
        d2 = self.dumps(h, indent=2, sort_keys=True, separators=(',', ': '))
        d3 = self.dumps(h, indent='\t', sort_keys=True, separators=(',', ': '))
        d4 = self.dumps(h, indent=2, sort_keys=True)
        d5 = self.dumps(h, indent='\t', sort_keys=True)


            

Reported by Pylint.

Instance of 'TestIndent' has no 'dumps' member
Error

Line: 33 Column: 14

                      ]""")

        d1 = self.dumps(h)
        d2 = self.dumps(h, indent=2, sort_keys=True, separators=(',', ': '))
        d3 = self.dumps(h, indent='\t', sort_keys=True, separators=(',', ': '))
        d4 = self.dumps(h, indent=2, sort_keys=True)
        d5 = self.dumps(h, indent='\t', sort_keys=True)

        h1 = self.loads(d1)

            

Reported by Pylint.

Instance of 'TestIndent' has no 'dumps' member
Error

Line: 34 Column: 14

              
        d1 = self.dumps(h)
        d2 = self.dumps(h, indent=2, sort_keys=True, separators=(',', ': '))
        d3 = self.dumps(h, indent='\t', sort_keys=True, separators=(',', ': '))
        d4 = self.dumps(h, indent=2, sort_keys=True)
        d5 = self.dumps(h, indent='\t', sort_keys=True)

        h1 = self.loads(d1)
        h2 = self.loads(d2)

            

Reported by Pylint.

Instance of 'TestIndent' has no 'dumps' member
Error

Line: 35 Column: 14

                      d1 = self.dumps(h)
        d2 = self.dumps(h, indent=2, sort_keys=True, separators=(',', ': '))
        d3 = self.dumps(h, indent='\t', sort_keys=True, separators=(',', ': '))
        d4 = self.dumps(h, indent=2, sort_keys=True)
        d5 = self.dumps(h, indent='\t', sort_keys=True)

        h1 = self.loads(d1)
        h2 = self.loads(d2)
        h3 = self.loads(d3)

            

Reported by Pylint.

Instance of 'TestIndent' has no 'dumps' member
Error

Line: 36 Column: 14

                      d2 = self.dumps(h, indent=2, sort_keys=True, separators=(',', ': '))
        d3 = self.dumps(h, indent='\t', sort_keys=True, separators=(',', ': '))
        d4 = self.dumps(h, indent=2, sort_keys=True)
        d5 = self.dumps(h, indent='\t', sort_keys=True)

        h1 = self.loads(d1)
        h2 = self.loads(d2)
        h3 = self.loads(d3)


            

Reported by Pylint.

Instance of 'TestIndent' has no 'loads' member
Error

Line: 38 Column: 14

                      d4 = self.dumps(h, indent=2, sort_keys=True)
        d5 = self.dumps(h, indent='\t', sort_keys=True)

        h1 = self.loads(d1)
        h2 = self.loads(d2)
        h3 = self.loads(d3)

        self.assertEqual(h1, h)
        self.assertEqual(h2, h)

            

Reported by Pylint.

Instance of 'TestIndent' has no 'loads' member
Error

Line: 39 Column: 14

                      d5 = self.dumps(h, indent='\t', sort_keys=True)

        h1 = self.loads(d1)
        h2 = self.loads(d2)
        h3 = self.loads(d3)

        self.assertEqual(h1, h)
        self.assertEqual(h2, h)
        self.assertEqual(h3, h)

            

Reported by Pylint.

Instance of 'TestIndent' has no 'loads' member
Error

Line: 40 Column: 14

              
        h1 = self.loads(d1)
        h2 = self.loads(d2)
        h3 = self.loads(d3)

        self.assertEqual(h1, h)
        self.assertEqual(h2, h)
        self.assertEqual(h3, h)
        self.assertEqual(d2, expect.expandtabs(2))

            

Reported by Pylint.

Instance of 'TestIndent' has no 'assertEqual' member
Error

Line: 42 Column: 9

                      h2 = self.loads(d2)
        h3 = self.loads(d3)

        self.assertEqual(h1, h)
        self.assertEqual(h2, h)
        self.assertEqual(h3, h)
        self.assertEqual(d2, expect.expandtabs(2))
        self.assertEqual(d3, expect)
        self.assertEqual(d4, d2)

            

Reported by Pylint.

Instance of 'TestIndent' has no 'assertEqual' member
Error

Line: 43 Column: 9

                      h3 = self.loads(d3)

        self.assertEqual(h1, h)
        self.assertEqual(h2, h)
        self.assertEqual(h3, h)
        self.assertEqual(d2, expect.expandtabs(2))
        self.assertEqual(d3, expect)
        self.assertEqual(d4, d2)
        self.assertEqual(d5, d3)

            

Reported by Pylint.