The following issues were found

Lib/pkgutil.py
54 issues
Module 'zipimport' has no '_zip_directory_cache' member
Error

Line: 374 Column: 26

                  from zipimport import zipimporter

    def iter_zipimport_modules(importer, prefix=''):
        dirlist = sorted(zipimport._zip_directory_cache[importer.archive])
        _prefix = importer.prefix
        plen = len(_prefix)
        yielded = {}
        import inspect
        for fn in dirlist:

            

Reported by Pylint.

Deserialization with the marshal module is possibly dangerous.
Security blacklist

Line: 50
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b302-marshal

                      return None

    stream.read(12) # Skip rest of the header
    return marshal.load(stream)


def walk_packages(path=None, prefix='', onerror=None):
    """Yields ModuleInfo for all modules recursively
    on path, or, if path is None, all accessible modules.

            

Reported by Bandit.

Dangerous default value {} as argument
Error

Line: 82 Column: 5

                  walk_packages(ctypes.__path__, ctypes.__name__+'.')
    """

    def seen(p, m={}):
        if p in m:
            return True
        m[p] = True

    for info in iter_modules(path, prefix):

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 96 Column: 20

                          except ImportError:
                if onerror is not None:
                    onerror(info.name)
            except Exception:
                if onerror is not None:
                    onerror(info.name)
                else:
                    raise
            else:

            

Reported by Pylint.

Redefining name 'fn' from outer scope (line 157)
Error

Line: 172 Column: 13

                          except OSError:
                # ignore unreadable directories like import does
                dircontents = []
            for fn in dircontents:
                subname = inspect.getmodulename(fn)
                if subname=='__init__':
                    ispkg = True
                    break
            else:

            

Reported by Pylint.

Global variable 'imp' undefined at the module level
Error

Line: 189 Column: 5

              

def _import_imp():
    global imp
    with warnings.catch_warnings():
        warnings.simplefilter('ignore', DeprecationWarning)
        imp = importlib.import_module('imp')

class ImpImporter:

            

Reported by Pylint.

Global variable 'imp' undefined at the module level
Error

Line: 206 Column: 9

                  """

    def __init__(self, path=None):
        global imp
        warnings.warn("This emulation is deprecated and slated for removal "
                      "in Python 3.12; use 'importlib' instead",
             DeprecationWarning)
        _import_imp()
        self.path = path

            

Reported by Pylint.

Redefining name 'fn' from outer scope (line 241)
Error

Line: 256 Column: 17

                              except OSError:
                    # ignore unreadable directories like import does
                    dircontents = []
                for fn in dircontents:
                    subname = inspect.getmodulename(fn)
                    if subname=='__init__':
                        ispkg = True
                        break
                else:

            

Reported by Pylint.

Access to a protected member _zip_directory_cache of a client class
Error

Line: 374 Column: 26

                  from zipimport import zipimporter

    def iter_zipimport_modules(importer, prefix=''):
        dirlist = sorted(zipimport._zip_directory_cache[importer.archive])
        _prefix = importer.prefix
        plen = len(_prefix)
        yielded = {}
        import inspect
        for fn in dirlist:

            

Reported by Pylint.

Redefining built-in 'dir'
Error

Line: 559 Column: 9

                  else:
        search_path = sys.path

    for dir in search_path:
        if not isinstance(dir, str):
            continue

        finder = get_importer(dir)
        if finder is not None:

            

Reported by Pylint.

Lib/sqlite3/test/factory.py
54 issues
Lambda may not be necessary
Error

Line: 64 Column: 39

                      self.assertIsInstance(cur, sqlite.Cursor)
        cur = self.con.cursor(MyCursor)
        self.assertIsInstance(cur, MyCursor)
        cur = self.con.cursor(factory=lambda con: MyCursor(con))
        self.assertIsInstance(cur, MyCursor)

    def test_invalid_factory(self):
        # not a callable at all
        self.assertRaises(TypeError, self.con.cursor, None)

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 115 Column: 13

                      self.assertEqual(row[-2], 1, "by index: wrong result for column -2")

        with self.assertRaises(IndexError):
            row['c']
        with self.assertRaises(IndexError):
            row['a_\x11']
        with self.assertRaises(IndexError):
            row['a\x7f1']
        with self.assertRaises(IndexError):

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 117 Column: 13

                      with self.assertRaises(IndexError):
            row['c']
        with self.assertRaises(IndexError):
            row['a_\x11']
        with self.assertRaises(IndexError):
            row['a\x7f1']
        with self.assertRaises(IndexError):
            row[2]
        with self.assertRaises(IndexError):

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 119 Column: 13

                      with self.assertRaises(IndexError):
            row['a_\x11']
        with self.assertRaises(IndexError):
            row['a\x7f1']
        with self.assertRaises(IndexError):
            row[2]
        with self.assertRaises(IndexError):
            row[-3]
        with self.assertRaises(IndexError):

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 121 Column: 13

                      with self.assertRaises(IndexError):
            row['a\x7f1']
        with self.assertRaises(IndexError):
            row[2]
        with self.assertRaises(IndexError):
            row[-3]
        with self.assertRaises(IndexError):
            row[2**1000]
        with self.assertRaises(IndexError):

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 123 Column: 13

                      with self.assertRaises(IndexError):
            row[2]
        with self.assertRaises(IndexError):
            row[-3]
        with self.assertRaises(IndexError):
            row[2**1000]
        with self.assertRaises(IndexError):
            row[complex()]  # index must be int or string


            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 125 Column: 13

                      with self.assertRaises(IndexError):
            row[-3]
        with self.assertRaises(IndexError):
            row[2**1000]
        with self.assertRaises(IndexError):
            row[complex()]  # index must be int or string

    def test_sqlite_row_index_unicode(self):
        self.con.row_factory = sqlite.Row

            

Reported by Pylint.

Expression "row[complex()]" is assigned to nothing
Error

Line: 127 Column: 13

                      with self.assertRaises(IndexError):
            row[2**1000]
        with self.assertRaises(IndexError):
            row[complex()]  # index must be int or string

    def test_sqlite_row_index_unicode(self):
        self.con.row_factory = sqlite.Row
        row = self.con.execute("select 1 as \xff").fetchone()
        self.assertEqual(row["\xff"], 1)

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 134 Column: 13

                      row = self.con.execute("select 1 as \xff").fetchone()
        self.assertEqual(row["\xff"], 1)
        with self.assertRaises(IndexError):
            row['\u0178']
        with self.assertRaises(IndexError):
            row['\xdf']

    def test_sqlite_row_slice(self):
        # A sqlite.Row can be sliced like a list.

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 136 Column: 13

                      with self.assertRaises(IndexError):
            row['\u0178']
        with self.assertRaises(IndexError):
            row['\xdf']

    def test_sqlite_row_slice(self):
        # A sqlite.Row can be sliced like a list.
        self.con.row_factory = sqlite.Row
        row = self.con.execute("select 1, 2, 3, 4").fetchone()

            

Reported by Pylint.

Lib/pydoc_data/topics.py
54 issues
Too many lines in module (14953/1000)
Error

Line: 1 Column: 1

              # -*- coding: utf-8 -*-
# Autogenerated by Sphinx on Mon Apr  5 17:39:41 2021
topics = {'assert': 'The "assert" statement\n'
           '**********************\n'
           '\n'
           'Assert statements are a convenient way to insert debugging '
           'assertions\n'
           'into a program:\n'
           '\n'

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # -*- coding: utf-8 -*-
# Autogenerated by Sphinx on Mon Apr  5 17:39:41 2021
topics = {'assert': 'The "assert" statement\n'
           '**********************\n'
           '\n'
           'Assert statements are a convenient way to insert debugging '
           'assertions\n'
           'into a program:\n'
           '\n'

            

Reported by Pylint.

Line too long (116/100)
Error

Line: 8028 Column: 1

                                   'feature as\n'
                     'described in the Comparisons section.\n'
                     '\n'
                     '+-------------------------------------------------+---------------------------------------+\n'
                     '| Operator                                        | '
                     'Description                           |\n'
                     '|=================================================|=======================================|\n'
                     '| ":="                                            | '
                     'Assignment expression                 |\n'

            

Reported by Pylint.

Line too long (116/100)
Error

Line: 8031 Column: 1

                                   '+-------------------------------------------------+---------------------------------------+\n'
                     '| Operator                                        | '
                     'Description                           |\n'
                     '|=================================================|=======================================|\n'
                     '| ":="                                            | '
                     'Assignment expression                 |\n'
                     '+-------------------------------------------------+---------------------------------------+\n'
                     '| "lambda"                                        | '
                     'Lambda expression                     |\n'

            

Reported by Pylint.

Line too long (116/100)
Error

Line: 8034 Column: 1

                                   '|=================================================|=======================================|\n'
                     '| ":="                                            | '
                     'Assignment expression                 |\n'
                     '+-------------------------------------------------+---------------------------------------+\n'
                     '| "lambda"                                        | '
                     'Lambda expression                     |\n'
                     '+-------------------------------------------------+---------------------------------------+\n'
                     '| "if" – "else"                                   | '
                     'Conditional expression                |\n'

            

Reported by Pylint.

Line too long (116/100)
Error

Line: 8037 Column: 1

                                   '+-------------------------------------------------+---------------------------------------+\n'
                     '| "lambda"                                        | '
                     'Lambda expression                     |\n'
                     '+-------------------------------------------------+---------------------------------------+\n'
                     '| "if" – "else"                                   | '
                     'Conditional expression                |\n'
                     '+-------------------------------------------------+---------------------------------------+\n'
                     '| "or"                                            | '
                     'Boolean OR                            |\n'

            

Reported by Pylint.

Line too long (116/100)
Error

Line: 8040 Column: 1

                                   '+-------------------------------------------------+---------------------------------------+\n'
                     '| "if" – "else"                                   | '
                     'Conditional expression                |\n'
                     '+-------------------------------------------------+---------------------------------------+\n'
                     '| "or"                                            | '
                     'Boolean OR                            |\n'
                     '+-------------------------------------------------+---------------------------------------+\n'
                     '| "and"                                           | '
                     'Boolean AND                           |\n'

            

Reported by Pylint.

Line too long (116/100)
Error

Line: 8043 Column: 1

                                   '+-------------------------------------------------+---------------------------------------+\n'
                     '| "or"                                            | '
                     'Boolean OR                            |\n'
                     '+-------------------------------------------------+---------------------------------------+\n'
                     '| "and"                                           | '
                     'Boolean AND                           |\n'
                     '+-------------------------------------------------+---------------------------------------+\n'
                     '| "not" "x"                                       | '
                     'Boolean NOT                           |\n'

            

Reported by Pylint.

Line too long (116/100)
Error

Line: 8046 Column: 1

                                   '+-------------------------------------------------+---------------------------------------+\n'
                     '| "and"                                           | '
                     'Boolean AND                           |\n'
                     '+-------------------------------------------------+---------------------------------------+\n'
                     '| "not" "x"                                       | '
                     'Boolean NOT                           |\n'
                     '+-------------------------------------------------+---------------------------------------+\n'
                     '| "in", "not in", "is", "is not", "<", "<=", ">", | '
                     'Comparisons, including membership     |\n'

            

Reported by Pylint.

Line too long (116/100)
Error

Line: 8049 Column: 1

                                   '+-------------------------------------------------+---------------------------------------+\n'
                     '| "not" "x"                                       | '
                     'Boolean NOT                           |\n'
                     '+-------------------------------------------------+---------------------------------------+\n'
                     '| "in", "not in", "is", "is not", "<", "<=", ">", | '
                     'Comparisons, including membership     |\n'
                     '| ">=", "!=", "=="                                | '
                     'tests and identity tests              |\n'
                     '+-------------------------------------------------+---------------------------------------+\n'

            

Reported by Pylint.

Lib/reprlib.py
54 issues
Unused argument 'level'
Error

Line: 120 Column: 27

                      s = ', '.join(pieces)
        return '{%s}' % (s,)

    def repr_str(self, x, level):
        s = builtins.repr(x[:self.maxstring])
        if len(s) > self.maxstring:
            i = max(0, (self.maxstring-3)//2)
            j = max(0, self.maxstring-3-i)
            s = builtins.repr(x[:i] + x[len(x)-j:])

            

Reported by Pylint.

Unused argument 'level'
Error

Line: 129 Column: 27

                          s = s[:i] + '...' + s[len(s)-j:]
        return s

    def repr_int(self, x, level):
        s = builtins.repr(x) # XXX Hope this isn't too slow...
        if len(s) > self.maxlong:
            i = max(0, (self.maxlong-3)//2)
            j = max(0, self.maxlong-3-i)
            s = s[:i] + '...' + s[len(s)-j:]

            

Reported by Pylint.

XXX Hope this isn't too slow...
Error

Line: 130 Column: 3

                      return s

    def repr_int(self, x, level):
        s = builtins.repr(x) # XXX Hope this isn't too slow...
        if len(s) > self.maxlong:
            i = max(0, (self.maxlong-3)//2)
            j = max(0, self.maxlong-3-i)
            s = s[:i] + '...' + s[len(s)-j:]
        return s

            

Reported by Pylint.

Unused argument 'level'
Error

Line: 137 Column: 32

                          s = s[:i] + '...' + s[len(s)-j:]
        return s

    def repr_instance(self, x, level):
        try:
            s = builtins.repr(x)
            # Bugs in x.__repr__() can cause arbitrary
            # exceptions -- then make up something
        except Exception:

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 142 Column: 16

                          s = builtins.repr(x)
            # Bugs in x.__repr__() can cause arbitrary
            # exceptions -- then make up something
        except Exception:
            return '<%s instance at %#x>' % (x.__class__.__name__, id(x))
        if len(s) > self.maxother:
            i = max(0, (self.maxother-3)//2)
            j = max(0, self.maxother-3-i)
            s = s[:i] + '...' + s[len(s)-j:]

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 157 Column: 12

                  # sequence in that case.
    try:
        return sorted(x)
    except Exception:
        return list(x)

aRepr = Repr()
repr = aRepr.repr

            

Reported by Pylint.

Redefining built-in 'repr'
Error

Line: 161 Column: 1

                      return list(x)

aRepr = Repr()
repr = aRepr.repr

            

Reported by Pylint.

Missing class docstring
Error

Line: 36 Column: 1

              
    return decorating_function

class Repr:

    def __init__(self):
        self.maxlevel = 6
        self.maxtuple = 6
        self.maxlist = 6

            

Reported by Pylint.

Too many instance attributes (11/7)
Error

Line: 36 Column: 1

              
    return decorating_function

class Repr:

    def __init__(self):
        self.maxlevel = 6
        self.maxtuple = 6
        self.maxlist = 6

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 51 Column: 5

                      self.maxlong = 40
        self.maxother = 30

    def repr(self, x):
        return self.repr1(x, self.maxlevel)

    def repr1(self, x, level):
        typename = type(x).__name__
        if ' ' in typename:

            

Reported by Pylint.

Lib/unittest/runner.py
54 issues
Attempted relative import beyond top-level package
Error

Line: 7 Column: 1

              import time
import warnings

from . import result
from .signals import registerResult

__unittest = True



            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 8 Column: 1

              import warnings

from . import result
from .signals import registerResult

__unittest = True


class _WritelnDecorator(object):

            

Reported by Pylint.

Redefining name 'warnings' from outer scope (line 5)
Error

Line: 129 Column: 66

                  resultclass = TextTestResult

    def __init__(self, stream=None, descriptions=True, verbosity=1,
                 failfast=False, buffer=False, resultclass=None, warnings=None,
                 *, tb_locals=False):
        """Construct a TextTestRunner.

        Subclasses should accept **kwargs to ensure compatibility as the
        interface changes.

            

Reported by Pylint.

Redefining name 'result' from outer scope (line 7)
Error

Line: 153 Column: 9

              
    def run(self, test):
        "Run the given test case or test suite."
        result = self._makeResult()
        registerResult(result)
        result.failfast = self.failfast
        result.buffer = self.buffer
        result.tb_locals = self.tb_locals
        with warnings.catch_warnings():

            

Reported by Pylint.

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

Line: 10 Column: 1

              from . import result
from .signals import registerResult

__unittest = True


class _WritelnDecorator(object):
    """Used to decorate file-like objects with a handy 'writeln' method"""
    def __init__(self,stream):

            

Reported by Pylint.

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

Line: 13 Column: 1

              __unittest = True


class _WritelnDecorator(object):
    """Used to decorate file-like objects with a handy 'writeln' method"""
    def __init__(self,stream):
        self.stream = stream

    def __getattr__(self, attr):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 23 Column: 5

                          raise AttributeError(attr)
        return getattr(self.stream,attr)

    def writeln(self, arg=None):
        if arg:
            self.write(arg)
        self.write('\n') # text-mode streams translate to \r\n if needed



            

Reported by Pylint.

Consider using Python 3 style super() without arguments
Error

Line: 38 Column: 9

                  separator2 = '-' * 70

    def __init__(self, stream, descriptions, verbosity):
        super(TextTestResult, self).__init__(stream, descriptions, verbosity)
        self.stream = stream
        self.showAll = verbosity > 1
        self.dots = verbosity == 1
        self.descriptions = descriptions


            

Reported by Pylint.

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

Line: 40 Column: 9

                  def __init__(self, stream, descriptions, verbosity):
        super(TextTestResult, self).__init__(stream, descriptions, verbosity)
        self.stream = stream
        self.showAll = verbosity > 1
        self.dots = verbosity == 1
        self.descriptions = descriptions

    def getDescription(self, test):
        doc_first_line = test.shortDescription()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 44 Column: 5

                      self.dots = verbosity == 1
        self.descriptions = descriptions

    def getDescription(self, test):
        doc_first_line = test.shortDescription()
        if self.descriptions and doc_first_line:
            return '\n'.join((str(test), doc_first_line))
        else:
            return str(test)

            

Reported by Pylint.

Lib/idlelib/idle_test/test_browser.py
54 issues
Redefining name 'mb' from outer scope (line 62)
Error

Line: 34 Column: 9

                      del cls.root, cls.mb

    def test_init(self):
        mb = self.mb
        eq = self.assertEqual
        eq(mb.path, __file__)
        eq(pyclbr._modules, {})
        self.assertIsInstance(mb.node, TreeNode)
        self.assertIsNotNone(browser.file_open)

            

Reported by Pylint.

Access to a protected member _modules of a client class
Error

Line: 37 Column: 12

                      mb = self.mb
        eq = self.assertEqual
        eq(mb.path, __file__)
        eq(pyclbr._modules, {})
        self.assertIsInstance(mb.node, TreeNode)
        self.assertIsNotNone(browser.file_open)

    def test_settitle(self):
        mb = self.mb

            

Reported by Pylint.

Redefining name 'mb' from outer scope (line 62)
Error

Line: 42 Column: 9

                      self.assertIsNotNone(browser.file_open)

    def test_settitle(self):
        mb = self.mb
        self.assertIn(os.path.basename(__file__), mb.top.title())
        self.assertEqual(mb.top.iconname(), 'Module Browser')

    def test_rootnode(self):
        mb = self.mb

            

Reported by Pylint.

Redefining name 'mb' from outer scope (line 62)
Error

Line: 47 Column: 9

                      self.assertEqual(mb.top.iconname(), 'Module Browser')

    def test_rootnode(self):
        mb = self.mb
        rn = mb.rootnode()
        self.assertIsInstance(rn, browser.ModuleBrowserTreeItem)

    def test_close(self):
        mb = self.mb

            

Reported by Pylint.

Redefining name 'mb' from outer scope (line 62)
Error

Line: 52 Column: 9

                      self.assertIsInstance(rn, browser.ModuleBrowserTreeItem)

    def test_close(self):
        mb = self.mb
        mb.top.destroy = Func()
        mb.node.destroy = Func()
        mb.close()
        self.assertTrue(mb.top.destroy.called)
        self.assertTrue(mb.node.destroy.called)

            

Reported by Pylint.

Access to a protected member _nest_function of a client class
Error

Line: 65 Column: 6

              mb = pyclbr
module, fname = 'test', 'test.py'
C0 = mb.Class(module, 'C0', ['base'], fname, 1, end_lineno=9)
F1 = mb._nest_function(C0, 'F1', 3, 5)
C1 = mb._nest_class(C0, 'C1', 6, 9, [''])
C2 = mb._nest_class(C1, 'C2', 7, 9)
F3 = mb._nest_function(C2, 'F3', 9, 9)
f0 = mb.Function(module, 'f0', fname, 11, end_lineno=15)
f1 = mb._nest_function(f0, 'f1', 12, 14)

            

Reported by Pylint.

Access to a protected member _nest_class of a client class
Error

Line: 66 Column: 6

              module, fname = 'test', 'test.py'
C0 = mb.Class(module, 'C0', ['base'], fname, 1, end_lineno=9)
F1 = mb._nest_function(C0, 'F1', 3, 5)
C1 = mb._nest_class(C0, 'C1', 6, 9, [''])
C2 = mb._nest_class(C1, 'C2', 7, 9)
F3 = mb._nest_function(C2, 'F3', 9, 9)
f0 = mb.Function(module, 'f0', fname, 11, end_lineno=15)
f1 = mb._nest_function(f0, 'f1', 12, 14)
f2 = mb._nest_function(f1, 'f2', 13, 13)

            

Reported by Pylint.

Access to a protected member _nest_class of a client class
Error

Line: 67 Column: 6

              C0 = mb.Class(module, 'C0', ['base'], fname, 1, end_lineno=9)
F1 = mb._nest_function(C0, 'F1', 3, 5)
C1 = mb._nest_class(C0, 'C1', 6, 9, [''])
C2 = mb._nest_class(C1, 'C2', 7, 9)
F3 = mb._nest_function(C2, 'F3', 9, 9)
f0 = mb.Function(module, 'f0', fname, 11, end_lineno=15)
f1 = mb._nest_function(f0, 'f1', 12, 14)
f2 = mb._nest_function(f1, 'f2', 13, 13)
c1 = mb._nest_class(f0, 'c1', 15, 15)

            

Reported by Pylint.

Access to a protected member _nest_function of a client class
Error

Line: 68 Column: 6

              F1 = mb._nest_function(C0, 'F1', 3, 5)
C1 = mb._nest_class(C0, 'C1', 6, 9, [''])
C2 = mb._nest_class(C1, 'C2', 7, 9)
F3 = mb._nest_function(C2, 'F3', 9, 9)
f0 = mb.Function(module, 'f0', fname, 11, end_lineno=15)
f1 = mb._nest_function(f0, 'f1', 12, 14)
f2 = mb._nest_function(f1, 'f2', 13, 13)
c1 = mb._nest_class(f0, 'c1', 15, 15)
mock_pyclbr_tree = {'C0': C0, 'f0': f0}

            

Reported by Pylint.

Access to a protected member _nest_function of a client class
Error

Line: 70 Column: 6

              C2 = mb._nest_class(C1, 'C2', 7, 9)
F3 = mb._nest_function(C2, 'F3', 9, 9)
f0 = mb.Function(module, 'f0', fname, 11, end_lineno=15)
f1 = mb._nest_function(f0, 'f1', 12, 14)
f2 = mb._nest_function(f1, 'f2', 13, 13)
c1 = mb._nest_class(f0, 'c1', 15, 15)
mock_pyclbr_tree = {'C0': C0, 'f0': f0}

# Adjust C0.name, C1.name so tests do not depend on order.

            

Reported by Pylint.

Lib/gzip.py
53 issues
Instance of 'FileIO' has no '_last_mtime' member
Error

Line: 226 Column: 16

                  @property
    def mtime(self):
        """Last modification time read from stream, or None"""
        return self._buffer.raw._last_mtime

    def __repr__(self):
        s = repr(self.fileobj)
        return '<gzip ' + s[1:-1] + ' ' + hex(id(self)) + '>'


            

Reported by Pylint.

Redefining built-in 'open'
Error

Line: 25 Column: 1

              _COMPRESS_LEVEL_BEST = 9


def open(filename, mode="rb", compresslevel=_COMPRESS_LEVEL_BEST,
         encoding=None, errors=None, newline=None):
    """Open a gzip-compressed file in binary or text mode.

    The filename argument can be an actual filename (a str or bytes object), or
    an existing file object to read from or write to.

            

Reported by Pylint.

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

Line: 134 Column: 5

                  # is passed in
    myfileobj = None

    def __init__(self, filename=None, mode=None,
                 compresslevel=_COMPRESS_LEVEL_BEST, fileobj=None, mtime=None):
        """Constructor for the GzipFile class.

        At least one of fileobj and filename must be given a
        non-trivial value.

            

Reported by Pylint.

Access to a protected member _last_mtime of a client class
Error

Line: 226 Column: 16

                  @property
    def mtime(self):
        """Last modification time read from stream, or None"""
        return self._buffer.raw._last_mtime

    def __repr__(self):
        s = repr(self.fileobj)
        return '<gzip ' + s[1:-1] + ' ' + hex(id(self)) + '>'


            

Reported by Pylint.

Attribute 'crc' defined outside __init__
Error

Line: 291 Column: 13

                      if length > 0:
            self.fileobj.write(self.compress.compress(data))
            self.size += length
            self.crc = zlib.crc32(data, self.crc)
            self.offset += length

        return length

    def read(self, size=-1):

            

Reported by Pylint.

Unused variable 'i'
Error

Line: 388 Column: 17

                              raise OSError('Negative seek in write mode')
            count = offset - self.offset
            chunk = b'\0' * 1024
            for i in range(count // 1024):
                self.write(chunk)
            self.write(b'\0' * (count % 1024))
        elif self.mode == READ:
            self._check_not_closed()
            return self._buffer.seek(offset, whence)

            

Reported by Pylint.

Attribute '_crc' defined outside __init__
Error

Line: 415 Column: 9

                      self._last_mtime = None

    def _init_read(self):
        self._crc = zlib.crc32(b"")
        self._stream_size = 0  # Decompressed size of unconcatenated stream

    def _read_exact(self, n):
        '''Read exactly *n* bytes from `self._fp`


            

Reported by Pylint.

Attribute '_stream_size' defined outside __init__
Error

Line: 416 Column: 9

              
    def _init_read(self):
        self._crc = zlib.crc32(b"")
        self._stream_size = 0  # Decompressed size of unconcatenated stream

    def _read_exact(self, n):
        '''Read exactly *n* bytes from `self._fp`

        This method is required because self._fp may be unbuffered,

            

Reported by Pylint.

Attribute '_crc' defined outside __init__
Error

Line: 519 Column: 9

                      return uncompress

    def _add_read_data(self, data):
        self._crc = zlib.crc32(data, self._crc)
        self._stream_size = self._stream_size + len(data)

    def _read_eof(self):
        # We've read to the end of the file
        # We check that the computed CRC and size of the

            

Reported by Pylint.

Attribute '_stream_size' defined outside __init__
Error

Line: 520 Column: 9

              
    def _add_read_data(self, data):
        self._crc = zlib.crc32(data, self._crc)
        self._stream_size = self._stream_size + len(data)

    def _read_eof(self):
        # We've read to the end of the file
        # We check that the computed CRC and size of the
        # uncompressed data matches the stored values.  Note that the size

            

Reported by Pylint.

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

Line: 196 Column: 1

                          except Exception:
                print("Error processing line {:d} of {}:\n".format(n+1, fullname),
                      file=sys.stderr)
                import traceback
                for record in traceback.format_exception(*sys.exc_info()):
                    for line in record.splitlines():
                        print('  '+line, file=sys.stderr)
                print("\nRemainder of file ignored", file=sys.stderr)
                break

            

Reported by Pylint.

No value for argument 'a' in function call
Error

Line: 274 Column: 35

                      return None

    def joinuser(*args):
        return os.path.expanduser(os.path.join(*args))

    if os.name == "nt":
        base = os.environ.get("APPDATA") or "~"
        return joinuser(base, "Python")


            

Reported by Pylint.

Module 'sys' has no 'winver' member
Error

Line: 292 Column: 21

                  version = sys.version_info

    if os.name == 'nt':
        ver_nodot = sys.winver.replace('.', '')
        return f'{userbase}\\Python{ver_nodot}\\site-packages'

    if sys.platform == 'darwin' and sys._framework:
        return f'{userbase}/lib/python/site-packages'


            

Reported by Pylint.

Module 'sys' has no 'platlibdir' member
Error

Line: 364 Column: 20

                          continue
        seen.add(prefix)

        libdirs = [sys.platlibdir]
        if sys.platlibdir != "lib":
            libdirs.append("lib")

        if os.sep == '/':
            for libdir in libdirs:

            

Reported by Pylint.

Module 'sys' has no 'platlibdir' member
Error

Line: 365 Column: 12

                      seen.add(prefix)

        libdirs = [sys.platlibdir]
        if sys.platlibdir != "lib":
            libdirs.append("lib")

        if os.sep == '/':
            for libdir in libdirs:
                path = os.path.join(prefix, libdir,

            

Reported by Pylint.

Redefining built-in 'dir'
Error

Line: 97 Column: 5

              

def makepath(*paths):
    dir = os.path.join(*paths)
    try:
        dir = os.path.abspath(dir)
    except OSError:
        pass
    return dir, os.path.normcase(dir)

            

Reported by Pylint.

Redefining built-in 'dir'
Error

Line: 135 Column: 9

                  # only absolute pathnames, even if we're running from the build directory.
    L = []
    known_paths = set()
    for dir in sys.path:
        # Filter out duplicate paths (on case-insensitive file systems also
        # if they only differ in case); turn relative paths into absolute
        # paths.
        dir, dircase = makepath(dir)
        if dircase not in known_paths:

            

Reported by Pylint.

Use of exec detected.
Security

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

                              continue
            try:
                if line.startswith(("import ", "import\t")):
                    exec(line)
                    continue
                line = line.rstrip()
                dir, dircase = makepath(sitedir, line)
                if not dircase in known_paths and os.path.exists(dir):
                    sys.path.append(dir)

            

Reported by Bandit.

Use of exec
Error

Line: 186 Column: 21

                              continue
            try:
                if line.startswith(("import ", "import\t")):
                    exec(line)
                    continue
                line = line.rstrip()
                dir, dircase = makepath(sitedir, line)
                if not dircase in known_paths and os.path.exists(dir):
                    sys.path.append(dir)

            

Reported by Pylint.

Redefining built-in 'dir'
Error

Line: 189 Column: 17

                                  exec(line)
                    continue
                line = line.rstrip()
                dir, dircase = makepath(sitedir, line)
                if not dircase in known_paths and os.path.exists(dir):
                    sys.path.append(dir)
                    known_paths.add(dircase)
            except Exception:
                print("Error processing line {:d} of {}:\n".format(n+1, fullname),

            

Reported by Pylint.

Modules/_decimal/tests/bench.py
53 issues
Redefining name 'n' from outer scope (line 103)
Error

Line: 27 Column: 18

              #
def pi_float():
    """native float"""
    lasts, t, s, n, na, d, da = 0, 3.0, 3, 1, 0, 0, 24
    while s != lasts:
        lasts = s
        n, na = n+na, na+8
        d, da = d+da, da+32
        t = (t * n) / d

            

Reported by Pylint.

Redefining name 'n' from outer scope (line 103)
Error

Line: 39 Column: 18

              def pi_cdecimal():
    """cdecimal"""
    D = C.Decimal
    lasts, t, s, n, na, d, da = D(0), D(3), D(3), D(1), D(0), D(0), D(24)
    while s != lasts:
        lasts = s
        n, na = n+na, na+8
        d, da = d+da, da+32
        t = (t * n) / d

            

Reported by Pylint.

Redefining name 'n' from outer scope (line 103)
Error

Line: 51 Column: 18

              def pi_decimal():
    """decimal"""
    D = P.Decimal
    lasts, t, s, n, na, d, da = D(0), D(3), D(3), D(1), D(0), D(0), D(24)
    while s != lasts:
        lasts = s
        n, na = n+na, na+8
        d, da = d+da, da+32
        t = (t * n) / d

            

Reported by Pylint.

Redefining name 'n' from outer scope (line 103)
Error

Line: 60 Column: 15

                      s += t
    return s

def factorial(n, m):
    if (n > m):
        return factorial(m, n)
    elif m == 0:
        return 1
    elif n == m:

            

Reported by Pylint.

Positional arguments appear to be out of order
Error

Line: 62 Column: 16

              
def factorial(n, m):
    if (n > m):
        return factorial(m, n)
    elif m == 0:
        return 1
    elif n == m:
        return n
    else:

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #
# Copyright (C) 2001-2012 Python Software Foundation. All Rights Reserved.
# Modified and extended by Stefan Krah.
#

# Usage: ../../../python bench.py


import time

            

Reported by Pylint.

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

Line: 27 Column: 15

              #
def pi_float():
    """native float"""
    lasts, t, s, n, na, d, da = 0, 3.0, 3, 1, 0, 0, 24
    while s != lasts:
        lasts = s
        n, na = n+na, na+8
        d, da = d+da, da+32
        t = (t * n) / d

            

Reported by Pylint.

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

Line: 27 Column: 12

              #
def pi_float():
    """native float"""
    lasts, t, s, n, na, d, da = 0, 3.0, 3, 1, 0, 0, 24
    while s != lasts:
        lasts = s
        n, na = n+na, na+8
        d, da = d+da, da+32
        t = (t * n) / d

            

Reported by Pylint.

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

Line: 27 Column: 28

              #
def pi_float():
    """native float"""
    lasts, t, s, n, na, d, da = 0, 3.0, 3, 1, 0, 0, 24
    while s != lasts:
        lasts = s
        n, na = n+na, na+8
        d, da = d+da, da+32
        t = (t * n) / d

            

Reported by Pylint.

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

Line: 27 Column: 25

              #
def pi_float():
    """native float"""
    lasts, t, s, n, na, d, da = 0, 3.0, 3, 1, 0, 0, 24
    while s != lasts:
        lasts = s
        n, na = n+na, na+8
        d, da = d+da, da+32
        t = (t * n) / d

            

Reported by Pylint.

Lib/asyncio/streams.py
53 issues
Attempted relative import beyond top-level package
Error

Line: 13 Column: 1

              if hasattr(socket, 'AF_UNIX'):
    __all__ += ('open_unix_connection', 'start_unix_server')

from . import coroutines
from . import events
from . import exceptions
from . import format_helpers
from . import protocols
from .log import logger

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 14 Column: 1

                  __all__ += ('open_unix_connection', 'start_unix_server')

from . import coroutines
from . import events
from . import exceptions
from . import format_helpers
from . import protocols
from .log import logger
from .tasks import sleep

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 15 Column: 1

              
from . import coroutines
from . import events
from . import exceptions
from . import format_helpers
from . import protocols
from .log import logger
from .tasks import sleep


            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 16 Column: 1

              from . import coroutines
from . import events
from . import exceptions
from . import format_helpers
from . import protocols
from .log import logger
from .tasks import sleep



            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 17 Column: 1

              from . import events
from . import exceptions
from . import format_helpers
from . import protocols
from .log import logger
from .tasks import sleep


_DEFAULT_LIMIT = 2 ** 16  # 64 KiB

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 18 Column: 1

              from . import exceptions
from . import format_helpers
from . import protocols
from .log import logger
from .tasks import sleep


_DEFAULT_LIMIT = 2 ** 16  # 64 KiB


            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 19 Column: 1

              from . import format_helpers
from . import protocols
from .log import logger
from .tasks import sleep


_DEFAULT_LIMIT = 2 ** 16  # 64 KiB



            

Reported by Pylint.

Unused import warnings
Error

Line: 7 Column: 1

              
import socket
import sys
import warnings
import weakref

if hasattr(socket, 'AF_UNIX'):
    __all__ += ('open_unix_connection', 'start_unix_server')


            

Reported by Pylint.

Access to a protected member _get_close_waiter of a client class
Error

Line: 344 Column: 15

                      return self._transport.is_closing()

    async def wait_closed(self):
        await self._protocol._get_close_waiter(self)

    def get_extra_info(self, name, default=None):
        return self._transport.get_extra_info(name, default)

    async def drain(self):

            

Reported by Pylint.

Access to a protected member _drain_helper of a client class
Error

Line: 372 Column: 15

                          # in a loop would never call connection_lost(), so it
            # would not see an error when the socket is closed.
            await sleep(0)
        await self._protocol._drain_helper()


class StreamReader:

    _source_traceback = None

            

Reported by Pylint.