The following issues were found

Lib/ctypes/test/test_python_api.py
94 issues
Unused import RTLD_GLOBAL from wildcard import
Error

Line: 1 Column: 1

              from ctypes import *
import unittest, sys
from test import support

################################################################
# This section should be moved into ctypes\__init__.py, when it's ready.

from _ctypes import PyObj_FromPtr


            

Reported by Pylint.

Unused import memmove from wildcard import
Error

Line: 1 Column: 1

              from ctypes import *
import unittest, sys
from test import support

################################################################
# This section should be moved into ctypes\__init__.py, when it's ready.

from _ctypes import PyObj_FromPtr


            

Reported by Pylint.

Unused import memset from wildcard import
Error

Line: 1 Column: 1

              from ctypes import *
import unittest, sys
from test import support

################################################################
# This section should be moved into ctypes\__init__.py, when it's ready.

from _ctypes import PyObj_FromPtr


            

Reported by Pylint.

Unused import PYFUNCTYPE from wildcard import
Error

Line: 1 Column: 1

              from ctypes import *
import unittest, sys
from test import support

################################################################
# This section should be moved into ctypes\__init__.py, when it's ready.

from _ctypes import PyObj_FromPtr


            

Reported by Pylint.

Unused import cast from wildcard import
Error

Line: 1 Column: 1

              from ctypes import *
import unittest, sys
from test import support

################################################################
# This section should be moved into ctypes\__init__.py, when it's ready.

from _ctypes import PyObj_FromPtr


            

Reported by Pylint.

Unused import string_at from wildcard import
Error

Line: 1 Column: 1

              from ctypes import *
import unittest, sys
from test import support

################################################################
# This section should be moved into ctypes\__init__.py, when it's ready.

from _ctypes import PyObj_FromPtr


            

Reported by Pylint.

Unused import wstring_at from wildcard import
Error

Line: 1 Column: 1

              from ctypes import *
import unittest, sys
from test import support

################################################################
# This section should be moved into ctypes\__init__.py, when it's ready.

from _ctypes import PyObj_FromPtr


            

Reported by Pylint.

Unused import DllGetClassObject from wildcard import
Error

Line: 1 Column: 1

              from ctypes import *
import unittest, sys
from test import support

################################################################
# This section should be moved into ctypes\__init__.py, when it's ready.

from _ctypes import PyObj_FromPtr


            

Reported by Pylint.

Unused import DllCanUnloadNow from wildcard import
Error

Line: 1 Column: 1

              from ctypes import *
import unittest, sys
from test import support

################################################################
# This section should be moved into ctypes\__init__.py, when it's ready.

from _ctypes import PyObj_FromPtr


            

Reported by Pylint.

Unused import c_int8 from wildcard import
Error

Line: 1 Column: 1

              from ctypes import *
import unittest, sys
from test import support

################################################################
# This section should be moved into ctypes\__init__.py, when it's ready.

from _ctypes import PyObj_FromPtr


            

Reported by Pylint.

Lib/ctypes/test/test_checkretval.py
94 issues
Unused import c_short from wildcard import
Error

Line: 3 Column: 1

              import unittest

from ctypes import *
from ctypes.test import need_symbol

class CHECKED(c_int):
    def _check_retval_(value):
        # Receives a CHECKED instance.
        return str(value.value)

            

Reported by Pylint.

Unused import BigEndianStructure from wildcard import
Error

Line: 3 Column: 1

              import unittest

from ctypes import *
from ctypes.test import need_symbol

class CHECKED(c_int):
    def _check_retval_(value):
        # Receives a CHECKED instance.
        return str(value.value)

            

Reported by Pylint.

Unused import set_last_error from wildcard import
Error

Line: 3 Column: 1

              import unittest

from ctypes import *
from ctypes.test import need_symbol

class CHECKED(c_int):
    def _check_retval_(value):
        # Receives a CHECKED instance.
        return str(value.value)

            

Reported by Pylint.

Unused import get_last_error from wildcard import
Error

Line: 3 Column: 1

              import unittest

from ctypes import *
from ctypes.test import need_symbol

class CHECKED(c_int):
    def _check_retval_(value):
        # Receives a CHECKED instance.
        return str(value.value)

            

Reported by Pylint.

Unused import pointer from wildcard import
Error

Line: 3 Column: 1

              import unittest

from ctypes import *
from ctypes.test import need_symbol

class CHECKED(c_int):
    def _check_retval_(value):
        # Receives a CHECKED instance.
        return str(value.value)

            

Reported by Pylint.

Unused import POINTER from wildcard import
Error

Line: 3 Column: 1

              import unittest

from ctypes import *
from ctypes.test import need_symbol

class CHECKED(c_int):
    def _check_retval_(value):
        # Receives a CHECKED instance.
        return str(value.value)

            

Reported by Pylint.

Unused import set_errno from wildcard import
Error

Line: 3 Column: 1

              import unittest

from ctypes import *
from ctypes.test import need_symbol

class CHECKED(c_int):
    def _check_retval_(value):
        # Receives a CHECKED instance.
        return str(value.value)

            

Reported by Pylint.

Unused import get_errno from wildcard import
Error

Line: 3 Column: 1

              import unittest

from ctypes import *
from ctypes.test import need_symbol

class CHECKED(c_int):
    def _check_retval_(value):
        # Receives a CHECKED instance.
        return str(value.value)

            

Reported by Pylint.

Unused import resize from wildcard import
Error

Line: 3 Column: 1

              import unittest

from ctypes import *
from ctypes.test import need_symbol

class CHECKED(c_int):
    def _check_retval_(value):
        # Receives a CHECKED instance.
        return str(value.value)

            

Reported by Pylint.

Unused import alignment from wildcard import
Error

Line: 3 Column: 1

              import unittest

from ctypes import *
from ctypes.test import need_symbol

class CHECKED(c_int):
    def _check_retval_(value):
        # Receives a CHECKED instance.
        return str(value.value)

            

Reported by Pylint.

Lib/distutils/msvc9compiler.py
94 issues
Unable to import 'winreg'
Error

Line: 26 Column: 1

              from distutils import log
from distutils.util import get_platform

import winreg

RegOpenKeyEx = winreg.OpenKeyEx
RegEnumKey = winreg.EnumKey
RegEnumValue = winreg.EnumValue
RegError = winreg.error

            

Reported by Pylint.

Instance of 'MSVCCompiler' has no '__product' member
Error

Line: 381 Column: 26

                              raise DistutilsPlatformError("Python was built with %s, "
                       "and extensions need to be built with the same "
                       "version of the compiler, but it isn't installed."
                       % self.__product)

            self.cc = self.find_exe("cl.exe")
            self.linker = self.find_exe("link.exe")
            self.lib = self.find_exe("lib.exe")
            self.rc = self.find_exe("rc.exe")   # resource compiler

            

Reported by Pylint.

Unused variable 'type'
Error

Line: 102 Column: 30

                      i = 0
        while True:
            try:
                name, value, type = RegEnumValue(handle, i)
            except RegError:
                break
            name = name.lower()
            d[cls.convert_mbcs(name)] = cls.convert_mbcs(value)
            i += 1

            

Reported by Pylint.

Redefining built-in 'type'
Error

Line: 102 Column: 30

                      i = 0
        while True:
            try:
                name, value, type = RegEnumValue(handle, i)
            except RegError:
                break
            name = name.lower()
            d[cls.convert_mbcs(name)] = cls.convert_mbcs(value)
            i += 1

            

Reported by Pylint.

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

Line: 142 Column: 13

                          else:
                raise KeyError("sdkinstallrootv2.0")
        except KeyError:
            raise DistutilsPlatformError(
            """Python was built with Visual Studio 2008;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2008 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.""")


            

Reported by Pylint.

Unused variable 'rest'
Error

Line: 178 Column: 8

                  if i == -1:
        return 6
    i = i + len(prefix)
    s, rest = sys.version[i:].split(" ", 1)
    majorVersion = int(s[:-2]) - 6
    if majorVersion >= 13:
        # v13 was skipped and should be v14
        majorVersion += 1
    minorVersion = int(s[2:3]) / 10.0

            

Reported by Pylint.

XXX(nnorwitz): O(n**2), if reduced_paths gets long perhaps use a set.
Error

Line: 201 Column: 3

                  reduced_paths = []
    for p in paths:
        np = os.path.normpath(p)
        # XXX(nnorwitz): O(n**2), if reduced_paths gets long perhaps use a set.
        if np not in reduced_paths:
            reduced_paths.append(np)
    return reduced_paths

def removeDuplicates(variable):

            

Reported by Pylint.

Attribute 'cc' defined outside __init__
Error

Line: 353 Column: 13

                      if "DISTUTILS_USE_SDK" in os.environ and "MSSdk" in os.environ and self.find_exe("cl.exe"):
            # Assume that the SDK set up everything alright; don't try to be
            # smarter
            self.cc = "cl.exe"
            self.linker = "link.exe"
            self.lib = "lib.exe"
            self.rc = "rc.exe"
            self.mc = "mc.exe"
        else:

            

Reported by Pylint.

Attribute 'linker' defined outside __init__
Error

Line: 354 Column: 13

                          # Assume that the SDK set up everything alright; don't try to be
            # smarter
            self.cc = "cl.exe"
            self.linker = "link.exe"
            self.lib = "lib.exe"
            self.rc = "rc.exe"
            self.mc = "mc.exe"
        else:
            # On x86, 'vcvars32.bat amd64' creates an env that doesn't work;

            

Reported by Pylint.

Attribute 'lib' defined outside __init__
Error

Line: 355 Column: 13

                          # smarter
            self.cc = "cl.exe"
            self.linker = "link.exe"
            self.lib = "lib.exe"
            self.rc = "rc.exe"
            self.mc = "mc.exe"
        else:
            # On x86, 'vcvars32.bat amd64' creates an env that doesn't work;
            # to cross compile, you use 'x86_amd64'.

            

Reported by Pylint.

Lib/random.py
93 issues
Unused Set imported from _collections_abc as _Set
Error

Line: 53 Column: 1

              from math import sqrt as _sqrt, acos as _acos, cos as _cos, sin as _sin
from math import tau as TWOPI, floor as _floor, isfinite as _isfinite
from os import urandom as _urandom
from _collections_abc import Set as _Set, Sequence as _Sequence
from operator import index as _index
from itertools import accumulate as _accumulate, repeat as _repeat
from bisect import bisect as _bisect
import os as _os
import _random

            

Reported by Pylint.

__init__ method from base class 'Random' is not called
Error

Line: 119 Column: 5

              
    VERSION = 3     # used by getstate/setstate

    def __init__(self, x=None):
        """Initialize an instance.

        Optional argument x controls seeding, as for Random.seed().
        """


            

Reported by Pylint.

Unused argument 'kwargs'
Error

Line: 215 Column: 1

              
    ## ---- internal support method for evenly distributed integers ----

    def __init_subclass__(cls, /, **kwargs):
        """Control how subclasses generate random integers.

        The algorithm a subclass can use depends on the random() and/or
        getrandbits() implementation available to it and determines
        whether it can generate random integers from arbitrarily large

            

Reported by Pylint.

Redefining name 'getrandbits' from outer scope (line 853)
Error

Line: 240 Column: 9

              
        if not n:
            return 0
        getrandbits = self.getrandbits
        k = n.bit_length()  # don't use (n-1) here because n can be 1
        r = getrandbits(k)  # 0 <= r < 2**k
        while r >= n:
            r = getrandbits(k)
        return r

            

Reported by Pylint.

Redefining name 'random' from outer scope (line 833)
Error

Line: 253 Column: 9

                      The implementation does not use getrandbits, but only random.
        """

        random = self.random
        if n >= maxsize:
            _warn("Underlying random() generator does not supply \n"
                "enough bits to choose from a population range this large.\n"
                "To remove the range limitation, add a getrandbits() method.")
            return _floor(random() * n)

            

Reported by Pylint.

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

Line: 305 Column: 17

                          if istart != start:
                _warn('randrange() will raise TypeError in the future',
                      DeprecationWarning, 2)
                raise ValueError("non-integer arg 1 for randrange()")
            _warn('non-integer arguments to randrange() have been deprecated '
                  'since Python 3.10 and will be removed in a subsequent '
                  'version',
                  DeprecationWarning, 2)
        if stop is None:

            

Reported by Pylint.

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

Line: 327 Column: 17

                          if istop != stop:
                _warn('randrange() will raise TypeError in the future',
                      DeprecationWarning, 2)
                raise ValueError("non-integer stop for randrange()")
            _warn('non-integer arguments to randrange() have been deprecated '
                  'since Python 3.10 and will be removed in a subsequent '
                  'version',
                  DeprecationWarning, 2)
        width = istop - istart

            

Reported by Pylint.

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

Line: 340 Column: 17

                          if istep != step:
                _warn('randrange() will raise TypeError in the future',
                      DeprecationWarning, 2)
                raise ValueError("non-integer step for randrange()")
            _warn('non-integer arguments to randrange() have been deprecated '
                  'since Python 3.10 and will be removed in a subsequent '
                  'version',
                  DeprecationWarning, 2)
        # Fast path.

            

Reported by Pylint.

Redefining name 'random' from outer scope (line 833)
Error

Line: 487 Column: 9

                      the selections are made with equal probability.

        """
        random = self.random
        n = len(population)
        if cum_weights is None:
            if weights is None:
                floor = _floor
                n += 0.0    # convert to float for a small speed improvement

            

Reported by Pylint.

Redefining name 'random' from outer scope (line 833)
Error

Line: 555 Column: 9

                      # variables using the ratio of uniform deviates", ACM Trans
        # Math Software, 3, (1977), pp257-260.

        random = self.random
        while True:
            u1 = random()
            u2 = 1.0 - random()
            z = NV_MAGICCONST * (u1 - 0.5) / u2
            zz = z * z / 4.0

            

Reported by Pylint.

Lib/sunau.py
93 issues
Unused variable 'i'
Error

Line: 142 Column: 9

              
def _read_u32(file):
    x = 0
    for i in range(4):
        byte = file.read(1)
        if not byte:
            raise EOFError
        x = x*256 + ord(byte)
    return x

            

Reported by Pylint.

Unused variable 'i'
Error

Line: 151 Column: 9

              
def _write_u32(file, x):
    data = []
    for i in range(4):
        d, m = divmod(x, 256)
        data.insert(0, int(m))
        x = d
    file.write(bytes(data))


            

Reported by Pylint.

XXX--must do some arithmetic here
Error

Line: 241 Column: 3

                          return AUDIO_UNKNOWN_SIZE
        if self._encoding in _simple_encodings:
            return self._data_size // self._framesize
        return 0                # XXX--must do some arithmetic here

    def getcomptype(self):
        if self._encoding == AUDIO_FILE_ENCODING_MULAW_8:
            return 'ULAW'
        elif self._encoding == AUDIO_FILE_ENCODING_ALAW_8:

            

Reported by Pylint.

Redefining built-in 'id'
Error

Line: 267 Column: 23

                  def getmarkers(self):
        return None

    def getmark(self, id):
        raise Error('no marks')

    def readframes(self, nframes):
        if self._encoding in _simple_encodings:
            if nframes == AUDIO_UNKNOWN_SIZE:

            

Reported by Pylint.

XXX--not implemented yet
Error

Line: 281 Column: 3

                              import audioop
                data = audioop.ulaw2lin(data, self._sampwidth)
            return data
        return None             # XXX--not implemented yet

    def rewind(self):
        if self._data_pos is None:
            raise OSError('cannot seek')
        self._file.seek(self._data_pos)

            

Reported by Pylint.

Attribute '_soundpos' defined outside __init__
Error

Line: 287 Column: 9

                      if self._data_pos is None:
            raise OSError('cannot seek')
        self._file.seek(self._data_pos)
        self._soundpos = 0

    def tell(self):
        return self._soundpos

    def setpos(self, pos):

            

Reported by Pylint.

Attribute '_soundpos' defined outside __init__
Error

Line: 298 Column: 9

                      if self._data_pos is None:
            raise OSError('cannot seek')
        self._file.seek(self._data_pos + pos * self._framesize)
        self._soundpos = pos

    def close(self):
        file = self._file
        if file:
            self._file = None

            

Reported by Pylint.

Attribute '_file' defined outside __init__
Error

Line: 303 Column: 13

                  def close(self):
        file = self._file
        if file:
            self._file = None
            if self._opened:
                file.close()

class Au_write:


            

Reported by Pylint.

Attribute '_file' defined outside __init__
Error

Line: 321 Column: 9

                  def __del__(self):
        if self._file:
            self.close()
        self._file = None

    def __enter__(self):
        return self

    def __exit__(self, *args):

            

Reported by Pylint.

Attribute '_nchannels' defined outside __init__
Error

Line: 347 Column: 9

                          raise Error('cannot change parameters after starting to write')
        if nchannels not in (1, 2, 4):
            raise Error('only 1, 2, or 4 channels supported')
        self._nchannels = nchannels

    def getnchannels(self):
        if not self._nchannels:
            raise Error('number of channels not set')
        return self._nchannels

            

Reported by Pylint.

Lib/shutil.py
93 issues
Unable to import 'nt'
Error

Line: 40 Column: 5

              if os.name == 'posix':
    import posix
elif _WINDOWS:
    import nt

COPY_BUFSIZE = 1024 * 1024 if _WINDOWS else 64 * 1024
# This should never be removed, see rationale in:
# https://bugs.python.org/issue43743#msg393429
_USE_CP_SENDFILE = hasattr(os, "sendfile") and sys.platform.startswith("linux")

            

Reported by Pylint.

Module 'posix' has no '_fcopyfile' member
Error

Line: 97 Column: 9

                      raise _GiveupOnFastCopy(err)  # not a regular file

    try:
        posix._fcopyfile(infd, outfd, flags)
    except OSError as err:
        err.filename = fsrc.name
        err.filename2 = fdst.name
        if err.errno in {errno.EINVAL, errno.ENOTSUP}:
            raise _GiveupOnFastCopy(err)

            

Reported by Pylint.

Module 'posix' has no '_COPYFILE_DATA' member
Error

Line: 261 Column: 57

                              # macOS
                if _HAS_FCOPYFILE:
                    try:
                        _fastcopy_fcopyfile(fsrc, fdst, posix._COPYFILE_DATA)
                        return dst
                    except _GiveupOnFastCopy:
                        pass
                # Linux
                elif _USE_CP_SENDFILE:

            

Reported by Pylint.

Module 'os' has no 'lchmod' member; maybe 'chmod'?
Error

Line: 301 Column: 47

              
    if not follow_symlinks and _islink(src) and os.path.islink(dst):
        if hasattr(os, 'lchmod'):
            stat_func, chmod_func = os.lstat, os.lchmod
        else:
            return
    else:
        stat_func, chmod_func = _stat, os.chmod


            

Reported by Pylint.

Module 'stat' has no 'IO_REPARSE_TAG_MOUNT_POINT' member
Error

Line: 474 Column: 44

                              # Special check for directory junctions, which appear as
                # symlinks but we want to recurse.
                lstat = srcentry.stat(follow_symlinks=False)
                if lstat.st_reparse_tag == stat.IO_REPARSE_TAG_MOUNT_POINT:
                    is_symlink = False
            if is_symlink:
                linkto = os.readlink(srcname)
                if symlinks:
                    # We can't just leave it to `copy_function` because legacy

            

Reported by Pylint.

Module 'stat' has no 'IO_REPARSE_TAG_MOUNT_POINT' member
Error

Line: 571 Column: 43

                          st = entry.stat(follow_symlinks=False)
            return (stat.S_ISDIR(st.st_mode) and not
                (st.st_file_attributes & stat.FILE_ATTRIBUTE_REPARSE_POINT
                 and st.st_reparse_tag == stat.IO_REPARSE_TAG_MOUNT_POINT))
        except OSError:
            return False

    def _rmtree_islink(path):
        try:

            

Reported by Pylint.

Module 'stat' has no 'IO_REPARSE_TAG_MOUNT_POINT' member
Error

Line: 580 Column: 43

                          st = os.lstat(path)
            return (stat.S_ISLNK(st.st_mode) or
                (st.st_file_attributes & stat.FILE_ATTRIBUTE_REPARSE_POINT
                 and st.st_reparse_tag == stat.IO_REPARSE_TAG_MOUNT_POINT))
        except OSError:
            return False
else:
    def _rmtree_isdir(entry):
        try:

            

Reported by Pylint.

function already defined line 682
Error

Line: 695 Column: 9

                  """
    sys.audit("shutil.rmtree", path)
    if ignore_errors:
        def onerror(*args):
            pass
    elif onerror is None:
        def onerror(*args):
            raise
    if _use_fd_functions:

            

Reported by Pylint.

The raise statement is not inside an except clause
Error

Line: 699 Column: 13

                          pass
    elif onerror is None:
        def onerror(*args):
            raise
    if _use_fd_functions:
        # While the unsafe rmtree works fine on bytes, the fd based does not.
        if isinstance(path, bytes):
            path = os.fsdecode(path)
        # Note: To guard against symlink races, we use the standard

            

Reported by Pylint.

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

Line: 94 Column: 9

                      infd = fsrc.fileno()
        outfd = fdst.fileno()
    except Exception as err:
        raise _GiveupOnFastCopy(err)  # not a regular file

    try:
        posix._fcopyfile(infd, outfd, flags)
    except OSError as err:
        err.filename = fsrc.name

            

Reported by Pylint.

Modules/_decimal/tests/formathelper.py
93 issues
Redefining name 'loc' from outer scope (line 178)
Error

Line: 189 Column: 5

              
# Print a testcase in the format of the IBM tests (for runtest.c):
def get_preferred_encoding():
    loc = locale.setlocale(locale.LC_CTYPE)
    if loc in preferred_encoding:
        return preferred_encoding[loc]
    else:
        return locale.getpreferredencoding()


            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 208 Column: 12

                      else:
            sys.stdout.write("xfmt%d  format  %s  '%s'  ->  '%s'\n"
                             % (testno, s, fmt, result))
    except Exception as err:
        sys.stderr.write("%s  %s  %s\n" % (err, s, fmt))


# Check if an integer can be converted to a valid fill character.
def check_fillchar(i):

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 219 Column: 5

                      c.encode('utf-8').decode()
        format(P.Decimal(0), c + '<19g')
        return c
    except:
        return None

# Generate all unicode characters that are accepted as
# fill characters by decimal.py.
def all_fillchars():

            

Reported by Pylint.

Redefining built-in 'type'
Error

Line: 277 Column: 29

                                  for width in ['']+[str(y) for y in range(1, 15)]+['101']:
                        for prec in ['']+['.'+str(y) for y in range(15)]:
                            # for type in ('', 'E', 'e', 'G', 'g', 'F', 'f', '%'):
                            type = random.choice(('', 'E', 'e', 'G', 'g', 'F', 'f', '%'))
                            yield ''.join((fill, align, sign, zeropad, width, ',', prec, type))

# Partially brute force all possible format strings with an 'n' specifier.
# [[fill]align][sign][#][0][width][,][.precision][type]
def all_format_loc():

            

Reported by Pylint.

Redefining name 'loc' from outer scope (line 178)
Error

Line: 320 Column: 9

              # [[fill]align][sign][#][0][width][,][.precision][type]
def rand_locale():
    try:
        loc = random.choice(locale_list)
        locale.setlocale(locale.LC_ALL, loc)
    except locale.Error as err:
        pass
    active = sorted(random.sample(range(5), random.randrange(6)))
    s = ''

            

Reported by Pylint.

Unused variable 'err'
Error

Line: 322 Column: 5

                  try:
        loc = random.choice(locale_list)
        locale.setlocale(locale.LC_ALL, loc)
    except locale.Error as err:
        pass
    active = sorted(random.sample(range(5), random.randrange(6)))
    s = ''
    have_align = 0
    for elem in active:

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #
# Copyright (c) 2008-2012 Stefan Krah. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.

            

Reported by Pylint.

Multiple imports on one line (os, sys, locale, random)
Error

Line: 32 Column: 1

              # Generate PEP-3101 format strings.


import os, sys, locale, random
import platform, subprocess
from test.support import import_fresh_module
from distutils.spawn import find_executable

C = import_fresh_module('decimal', fresh=['_decimal'])

            

Reported by Pylint.

Consider possible security implications associated with subprocess module.
Security blacklist

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

              

import os, sys, locale, random
import platform, subprocess
from test.support import import_fresh_module
from distutils.spawn import find_executable

C = import_fresh_module('decimal', fresh=['_decimal'])
P = import_fresh_module('decimal', blocked=['_decimal'])

            

Reported by Bandit.

Multiple imports on one line (platform, subprocess)
Error

Line: 33 Column: 1

              

import os, sys, locale, random
import platform, subprocess
from test.support import import_fresh_module
from distutils.spawn import find_executable

C = import_fresh_module('decimal', fresh=['_decimal'])
P = import_fresh_module('decimal', blocked=['_decimal'])

            

Reported by Pylint.

Lib/ctypes/test/test_incomplete.py
93 issues
Unused import WINFUNCTYPE from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *

################################################################
#
# The incomplete pointer example from the tutorial
#

class MyTestCase(unittest.TestCase):

            

Reported by Pylint.

Unused import BigEndianStructure from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *

################################################################
#
# The incomplete pointer example from the tutorial
#

class MyTestCase(unittest.TestCase):

            

Reported by Pylint.

Unused import set_last_error from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *

################################################################
#
# The incomplete pointer example from the tutorial
#

class MyTestCase(unittest.TestCase):

            

Reported by Pylint.

Unused import get_last_error from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *

################################################################
#
# The incomplete pointer example from the tutorial
#

class MyTestCase(unittest.TestCase):

            

Reported by Pylint.

Unused import set_errno from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *

################################################################
#
# The incomplete pointer example from the tutorial
#

class MyTestCase(unittest.TestCase):

            

Reported by Pylint.

Unused import get_errno from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *

################################################################
#
# The incomplete pointer example from the tutorial
#

class MyTestCase(unittest.TestCase):

            

Reported by Pylint.

Unused import resize from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *

################################################################
#
# The incomplete pointer example from the tutorial
#

class MyTestCase(unittest.TestCase):

            

Reported by Pylint.

Unused import alignment from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *

################################################################
#
# The incomplete pointer example from the tutorial
#

class MyTestCase(unittest.TestCase):

            

Reported by Pylint.

Unused import CFUNCTYPE from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *

################################################################
#
# The incomplete pointer example from the tutorial
#

class MyTestCase(unittest.TestCase):

            

Reported by Pylint.

Unused import c_buffer from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *

################################################################
#
# The incomplete pointer example from the tutorial
#

class MyTestCase(unittest.TestCase):

            

Reported by Pylint.

Lib/turtledemo/sorting_animate.py
93 issues
Undefined variable 'clear'
Error

Line: 123 Column: 5

              
def randomize():
    disable_keys()
    clear()
    target = list(range(10))
    random.shuffle(target)
    for i, t in enumerate(target):
        for j in range(i, len(s)):
            if s[j].size == t + 1:

            

Reported by Pylint.

Undefined variable 'goto'
Error

Line: 136 Column: 5

              
def show_text(text, line=0):
    line = 20 * line
    goto(0,-250 - line)
    write(text, align="center", font=("Courier", 16, "bold"))

def start_ssort():
    disable_keys()
    clear()

            

Reported by Pylint.

Undefined variable 'write'
Error

Line: 137 Column: 5

              def show_text(text, line=0):
    line = 20 * line
    goto(0,-250 - line)
    write(text, align="center", font=("Courier", 16, "bold"))

def start_ssort():
    disable_keys()
    clear()
    show_text("Selection Sort")

            

Reported by Pylint.

Undefined variable 'clear'
Error

Line: 141 Column: 5

              
def start_ssort():
    disable_keys()
    clear()
    show_text("Selection Sort")
    ssort(s)
    clear()
    show_text(instructions1)
    show_text(instructions2, line=1)

            

Reported by Pylint.

Undefined variable 'clear'
Error

Line: 144 Column: 5

                  clear()
    show_text("Selection Sort")
    ssort(s)
    clear()
    show_text(instructions1)
    show_text(instructions2, line=1)
    enable_keys()

def start_isort():

            

Reported by Pylint.

Undefined variable 'clear'
Error

Line: 151 Column: 5

              
def start_isort():
    disable_keys()
    clear()
    show_text("Insertion Sort")
    isort(s)
    clear()
    show_text(instructions1)
    show_text(instructions2, line=1)

            

Reported by Pylint.

Undefined variable 'clear'
Error

Line: 154 Column: 5

                  clear()
    show_text("Insertion Sort")
    isort(s)
    clear()
    show_text(instructions1)
    show_text(instructions2, line=1)
    enable_keys()

def start_qsort():

            

Reported by Pylint.

Undefined variable 'clear'
Error

Line: 161 Column: 5

              
def start_qsort():
    disable_keys()
    clear()
    show_text("Quicksort")
    qsort(s, 0, len(s) - 1)
    clear()
    show_text(instructions1)
    show_text(instructions2, line=1)

            

Reported by Pylint.

Undefined variable 'clear'
Error

Line: 164 Column: 5

                  clear()
    show_text("Quicksort")
    qsort(s, 0, len(s) - 1)
    clear()
    show_text(instructions1)
    show_text(instructions2, line=1)
    enable_keys()

def init_shelf():

            

Reported by Pylint.

Undefined variable 'onkey'
Error

Line: 177 Column: 5

                      s.push(Block(i))

def disable_keys():
    onkey(None, "s")
    onkey(None, "i")
    onkey(None, "q")
    onkey(None, "r")

def enable_keys():

            

Reported by Pylint.

Lib/test/pythoninfo.py
93 issues
Cannot import 'traceback' due to syntax error 'invalid syntax (<unknown>, line 576)'
Error

Line: 8 Column: 1

              import errno
import re
import sys
import traceback
import warnings


def normalize_text(text):
    if text is None:

            

Reported by Pylint.

Using a conditional statement with a constant value
Error

Line: 123 Column: 9

                      if not encoding:
            continue
        errors = getattr(stream, 'errors', None)
        if errors:
            encoding = '%s/%s' % (encoding, errors)
        info_add('sys.%s.encoding' % name, encoding)

    # Were we compiled --with-pydebug or with #define Py_DEBUG?
    Py_DEBUG = hasattr(sys, 'gettotalrefcount')

            

Reported by Pylint.

Unused argument 'attr'
Error

Line: 347 Column: 21

                  except ImportError:
        return

    def format_attr(attr, value):
        if isinstance(value, int):
            return "%#x" % value
        else:
            return value


            

Reported by Pylint.

Access to a protected member _create_default_https_context of a client class
Error

Line: 508 Column: 35

              
    for name, ctx in (
        ('SSLContext', ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)),
        ('default_https_context', ssl._create_default_https_context()),
        ('stdlib_context', ssl._create_stdlib_context()),
    ):
        attributes = (
            'minimum_version',
            'maximum_version',

            

Reported by Pylint.

Access to a protected member _create_stdlib_context of a client class
Error

Line: 509 Column: 28

                  for name, ctx in (
        ('SSLContext', ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)),
        ('default_https_context', ssl._create_default_https_context()),
        ('stdlib_context', ssl._create_stdlib_context()),
    ):
        attributes = (
            'minimum_version',
            'maximum_version',
            'protocol',

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 785 Column: 16

                  ):
        try:
            collect_func(info_add)
        except Exception:
            error = True
            print("ERROR: %s() failed" % (collect_func.__name__),
                  file=sys.stderr)
            traceback.print_exc(file=sys.stderr)
            print(file=sys.stderr)

            

Reported by Pylint.

Unused argument 'file'
Error

Line: 796 Column: 21

                  return error


def dump_info(info, file=None):
    title = "Python debug information"
    print(title)
    print("=" * len(title))
    print()


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 12 Column: 1

              import warnings


def normalize_text(text):
    if text is None:
        return None
    text = str(text)
    text = re.sub(r'\s+', ' ', text)
    return text.strip()

            

Reported by Pylint.

Missing class docstring
Error

Line: 20 Column: 1

                  return text.strip()


class PythonInfo:
    def __init__(self):
        self.info = {}

    def add(self, key, value):
        if key in self.info:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 24 Column: 5

                  def __init__(self):
        self.info = {}

    def add(self, key, value):
        if key in self.info:
            raise ValueError("duplicate key: %r" % key)

        if value is None:
            return

            

Reported by Pylint.