The following issues were found

Lib/test/test_importlib/test_locks.py
62 issues
Attempted relative import beyond top-level package
Error

Line: 1 Column: 1

              from . import util as test_util

init = test_util.import_importlib('importlib')

import sys
import threading
import weakref

from test import support

            

Reported by Pylint.

Instance of 'DeadlockAvoidanceTests' has no 'LockType' member
Error

Line: 56 Column: 18

              
    def run_deadlock_avoidance_test(self, create_deadlock):
        NLOCKS = 10
        locks = [self.LockType(str(i)) for i in range(NLOCKS)]
        pairs = [(locks[i], locks[(i+1)%NLOCKS]) for i in range(NLOCKS)]
        if create_deadlock:
            NTHREADS = NLOCKS
        else:
            NTHREADS = NLOCKS - 1

            

Reported by Pylint.

Instance of 'DeadlockAvoidanceTests' has no 'DeadlockError' member
Error

Line: 70 Column: 20

                          False on deadlock."""
            try:
                lock.acquire()
            except self.DeadlockError:
                return False
            else:
                return True

        def f():

            

Reported by Pylint.

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

Line: 86 Column: 9

                          if ra:
                a.release()
        lock_tests.Bunch(f, NTHREADS).wait_for_finished()
        self.assertEqual(len(results), NTHREADS)
        return results

    def test_deadlock(self):
        results = self.run_deadlock_avoidance_test(True)
        # At least one of the threads detected a potential deadlock on its

            

Reported by Pylint.

Instance of 'DeadlockAvoidanceTests' has no 'assertGreaterEqual' member
Error

Line: 95 Column: 9

                      # second acquire() call.  It may be several of them, because the
        # deadlock avoidance mechanism is conservative.
        nb_deadlocks = results.count((True, False))
        self.assertGreaterEqual(nb_deadlocks, 1)
        self.assertEqual(results.count((True, True)), len(results) - nb_deadlocks)

    def test_no_deadlock(self):
        results = self.run_deadlock_avoidance_test(False)
        self.assertEqual(results.count((True, False)), 0)

            

Reported by Pylint.

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

Line: 96 Column: 9

                      # deadlock avoidance mechanism is conservative.
        nb_deadlocks = results.count((True, False))
        self.assertGreaterEqual(nb_deadlocks, 1)
        self.assertEqual(results.count((True, True)), len(results) - nb_deadlocks)

    def test_no_deadlock(self):
        results = self.run_deadlock_avoidance_test(False)
        self.assertEqual(results.count((True, False)), 0)
        self.assertEqual(results.count((True, True)), len(results))

            

Reported by Pylint.

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

Line: 100 Column: 9

              
    def test_no_deadlock(self):
        results = self.run_deadlock_avoidance_test(False)
        self.assertEqual(results.count((True, False)), 0)
        self.assertEqual(results.count((True, True)), len(results))


DEADLOCK_ERRORS = {kind: splitinit._bootstrap._DeadlockError
                   for kind, splitinit in init.items()}

            

Reported by Pylint.

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

Line: 101 Column: 9

                  def test_no_deadlock(self):
        results = self.run_deadlock_avoidance_test(False)
        self.assertEqual(results.count((True, False)), 0)
        self.assertEqual(results.count((True, True)), len(results))


DEADLOCK_ERRORS = {kind: splitinit._bootstrap._DeadlockError
                   for kind, splitinit in init.items()}


            

Reported by Pylint.

Instance of 'LifetimeTests' has no 'init' member
Error

Line: 118 Column: 16

              
    @property
    def bootstrap(self):
        return self.init._bootstrap

    def test_lock_lifetime(self):
        name = "xyzzy"
        self.assertNotIn(name, self.bootstrap._module_locks)
        lock = self.bootstrap._get_module_lock(name)

            

Reported by Pylint.

Instance of 'LifetimeTests' has no 'assertNotIn' member
Error

Line: 122 Column: 9

              
    def test_lock_lifetime(self):
        name = "xyzzy"
        self.assertNotIn(name, self.bootstrap._module_locks)
        lock = self.bootstrap._get_module_lock(name)
        self.assertIn(name, self.bootstrap._module_locks)
        wr = weakref.ref(lock)
        del lock
        support.gc_collect()

            

Reported by Pylint.

Tools/c-analyzer/cpython/_capi.py
62 issues
Attempted relative import beyond top-level package
Error

Line: 10 Column: 1

              
from c_common.tables import build_table, resolve_columns
from c_parser.parser._regexes import _ind
from ._files import iter_header_files, resolve_filename
from . import REPO_ROOT


logger = logging.getLogger(__name__)


            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 11 Column: 1

              from c_common.tables import build_table, resolve_columns
from c_parser.parser._regexes import _ind
from ._files import iter_header_files, resolve_filename
from . import REPO_ROOT


logger = logging.getLogger(__name__)



            

Reported by Pylint.

Unused resolve_filename imported from _files
Error

Line: 10 Column: 1

              
from c_common.tables import build_table, resolve_columns
from c_parser.parser._regexes import _ind
from ._files import iter_header_files, resolve_filename
from . import REPO_ROOT


logger = logging.getLogger(__name__)


            

Reported by Pylint.

Access to a protected member _text of a client class
Error

Line: 195 Column: 13

                      level = _get_level(filename, name)
        self = cls(filename, lno, name, kind, level)
        if prev:
            self._text = (prev + line).rstrip().splitlines()
        else:
            self._text = [line.rstrip()]
        return self, None

    @property

            

Reported by Pylint.

Attribute '_text' defined outside __init__
Error

Line: 195 Column: 13

                      level = _get_level(filename, name)
        self = cls(filename, lno, name, kind, level)
        if prev:
            self._text = (prev + line).rstrip().splitlines()
        else:
            self._text = [line.rstrip()]
        return self, None

    @property

            

Reported by Pylint.

Attribute '_text' defined outside __init__
Error

Line: 197 Column: 13

                      if prev:
            self._text = (prev + line).rstrip().splitlines()
        else:
            self._text = [line.rstrip()]
        return self, None

    @property
    def relfile(self):
        return self.file[len(REPO_ROOT) + 1:]

            

Reported by Pylint.

Access to a protected member _text of a client class
Error

Line: 197 Column: 13

                      if prev:
            self._text = (prev + line).rstrip().splitlines()
        else:
            self._text = [line.rstrip()]
        return self, None

    @property
    def relfile(self):
        return self.file[len(REPO_ROOT) + 1:]

            

Reported by Pylint.

XXX Actually ready the text from disk?.
Error

Line: 209 Column: 3

                      try:
            return self._text
        except AttributeError:
            # XXX Actually ready the text from disk?.
            self._text = []
            if self.kind == 'data':
                self._text = [
                    f'PyAPI_DATA(...) {self.name}',
                ]

            

Reported by Pylint.

Attribute '_text' defined outside __init__
Error

Line: 210 Column: 13

                          return self._text
        except AttributeError:
            # XXX Actually ready the text from disk?.
            self._text = []
            if self.kind == 'data':
                self._text = [
                    f'PyAPI_DATA(...) {self.name}',
                ]
            elif self.kind == 'func':

            

Reported by Pylint.

Attribute '_text' defined outside __init__
Error

Line: 212 Column: 17

                          # XXX Actually ready the text from disk?.
            self._text = []
            if self.kind == 'data':
                self._text = [
                    f'PyAPI_DATA(...) {self.name}',
                ]
            elif self.kind == 'func':
                self._text = [
                    f'PyAPI_FUNC(...) {self.name}(...);',

            

Reported by Pylint.

Lib/lib2to3/refactor.py
62 issues
Attempted relative import beyond top-level package
Error

Line: 25 Column: 1

              from itertools import chain

# Local imports
from .pgen2 import driver, tokenize, token
from .fixer_util import find_root
from . import pytree, pygram
from . import btm_matcher as bm



            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 26 Column: 1

              
# Local imports
from .pgen2 import driver, tokenize, token
from .fixer_util import find_root
from . import pytree, pygram
from . import btm_matcher as bm


def get_all_fix_names(fixer_pkg, remove_prefix=True):

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 27 Column: 1

              # Local imports
from .pgen2 import driver, tokenize, token
from .fixer_util import find_root
from . import pytree, pygram
from . import btm_matcher as bm


def get_all_fix_names(fixer_pkg, remove_prefix=True):
    """Return a sorted list of all available fix names in the given package."""

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 28 Column: 1

              from .pgen2 import driver, tokenize, token
from .fixer_util import find_root
from . import pytree, pygram
from . import btm_matcher as bm


def get_all_fix_names(fixer_pkg, remove_prefix=True):
    """Return a sorted list of all available fix names in the given package."""
    pkg = __import__(fixer_pkg, [], [], ["*"])

            

Reported by Pylint.

The raise statement is not inside an except clause
Error

Line: 261 Column: 9

              
    def log_error(self, msg, *args, **kwds):
        """Called when an error occurs."""
        raise

    def log_message(self, msg, *args):
        """Hook to log a message."""
        if args:
            msg = msg % args

            

Reported by Pylint.

Unused variable 'finder'
Error

Line: 35 Column: 9

                  """Return a sorted list of all available fix names in the given package."""
    pkg = __import__(fixer_pkg, [], [], ["*"])
    fix_names = []
    for finder, name, ispkg in pkgutil.iter_modules(pkg.__path__):
        if name.startswith("fix_"):
            if remove_prefix:
                name = name[4:]
            fix_names.append(name)
    return fix_names

            

Reported by Pylint.

Unused variable 'ispkg'
Error

Line: 35 Column: 23

                  """Return a sorted list of all available fix names in the given package."""
    pkg = __import__(fixer_pkg, [], [], ["*"])
    fix_names = []
    for finder, name, ispkg in pkgutil.iter_modules(pkg.__path__):
        if name.startswith("fix_"):
            if remove_prefix:
                name = name[4:]
            fix_names.append(name)
    return fix_names

            

Reported by Pylint.

Access to a protected member _accept_type of a client class
Error

Line: 90 Column: 16

                              for node_type in heads:
                    head_nodes[node_type].append(fixer)
        else:
            if fixer._accept_type is not None:
                head_nodes[fixer._accept_type].append(fixer)
            else:
                every.append(fixer)
    for node_type in chain(pygram.python_grammar.symbol2number.values(),
                           pygram.python_grammar.tokens):

            

Reported by Pylint.

Access to a protected member _accept_type of a client class
Error

Line: 91 Column: 28

                                  head_nodes[node_type].append(fixer)
        else:
            if fixer._accept_type is not None:
                head_nodes[fixer._accept_type].append(fixer)
            else:
                every.append(fixer)
    for node_type in chain(pygram.python_grammar.symbol2number.values(),
                           pygram.python_grammar.tokens):
        head_nodes[node_type].extend(every)

            

Reported by Pylint.

Unnecessary pass statement
Error

Line: 277 Column: 9

                  def print_output(self, old_text, new_text, filename, equal):
        """Called with the old version, new version, and filename of a
        refactored file."""
        pass

    def refactor(self, items, write=False, doctests_only=False):
        """Refactor a list of files and directories."""

        for dir_or_file in items:

            

Reported by Pylint.

Lib/test/test_importlib/import_/test_packages.py
62 issues
Attempted relative import beyond top-level package
Error

Line: 1 Column: 1

              from .. import util
import sys
import unittest
from test import support
from test.support import import_helper


class ParentModuleTests:


            

Reported by Pylint.

Instance of 'ParentModuleTests' has no '__import__' member
Error

Line: 15 Column: 26

                  def test_import_parent(self):
        with util.mock_spec('pkg.__init__', 'pkg.module') as mock:
            with util.import_state(meta_path=[mock]):
                module = self.__import__('pkg.module')
                self.assertIn('pkg', sys.modules)

    def test_bad_parent(self):
        with util.mock_spec('pkg.module') as mock:
            with util.import_state(meta_path=[mock]):

            

Reported by Pylint.

Instance of 'ParentModuleTests' has no 'assertIn' member
Error

Line: 16 Column: 17

                      with util.mock_spec('pkg.__init__', 'pkg.module') as mock:
            with util.import_state(meta_path=[mock]):
                module = self.__import__('pkg.module')
                self.assertIn('pkg', sys.modules)

    def test_bad_parent(self):
        with util.mock_spec('pkg.module') as mock:
            with util.import_state(meta_path=[mock]):
                with self.assertRaises(ImportError) as cm:

            

Reported by Pylint.

Instance of 'ParentModuleTests' has no 'assertRaises' member
Error

Line: 21 Column: 22

                  def test_bad_parent(self):
        with util.mock_spec('pkg.module') as mock:
            with util.import_state(meta_path=[mock]):
                with self.assertRaises(ImportError) as cm:
                    self.__import__('pkg.module')
                self.assertEqual(cm.exception.name, 'pkg')

    def test_raising_parent_after_importing_child(self):
        def __init__():

            

Reported by Pylint.

Instance of 'ParentModuleTests' has no '__import__' member
Error

Line: 22 Column: 21

                      with util.mock_spec('pkg.module') as mock:
            with util.import_state(meta_path=[mock]):
                with self.assertRaises(ImportError) as cm:
                    self.__import__('pkg.module')
                self.assertEqual(cm.exception.name, 'pkg')

    def test_raising_parent_after_importing_child(self):
        def __init__():
            import pkg.module

            

Reported by Pylint.

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

Line: 23 Column: 17

                          with util.import_state(meta_path=[mock]):
                with self.assertRaises(ImportError) as cm:
                    self.__import__('pkg.module')
                self.assertEqual(cm.exception.name, 'pkg')

    def test_raising_parent_after_importing_child(self):
        def __init__():
            import pkg.module
            1/0

            

Reported by Pylint.

Unable to import 'pkg.module'
Error

Line: 27 Column: 13

              
    def test_raising_parent_after_importing_child(self):
        def __init__():
            import pkg.module
            1/0
        mock = util.mock_spec('pkg.__init__', 'pkg.module',
                                 module_code={'pkg': __init__})
        with mock:
            with util.import_state(meta_path=[mock]):

            

Reported by Pylint.

Instance of 'ParentModuleTests' has no 'assertRaises' member
Error

Line: 33 Column: 22

                                               module_code={'pkg': __init__})
        with mock:
            with util.import_state(meta_path=[mock]):
                with self.assertRaises(ZeroDivisionError):
                    self.__import__('pkg')
                self.assertNotIn('pkg', sys.modules)
                self.assertIn('pkg.module', sys.modules)
                with self.assertRaises(ZeroDivisionError):
                    self.__import__('pkg.module')

            

Reported by Pylint.

Instance of 'ParentModuleTests' has no '__import__' member
Error

Line: 34 Column: 21

                      with mock:
            with util.import_state(meta_path=[mock]):
                with self.assertRaises(ZeroDivisionError):
                    self.__import__('pkg')
                self.assertNotIn('pkg', sys.modules)
                self.assertIn('pkg.module', sys.modules)
                with self.assertRaises(ZeroDivisionError):
                    self.__import__('pkg.module')
                self.assertNotIn('pkg', sys.modules)

            

Reported by Pylint.

Instance of 'ParentModuleTests' has no 'assertNotIn' member
Error

Line: 35 Column: 17

                          with util.import_state(meta_path=[mock]):
                with self.assertRaises(ZeroDivisionError):
                    self.__import__('pkg')
                self.assertNotIn('pkg', sys.modules)
                self.assertIn('pkg.module', sys.modules)
                with self.assertRaises(ZeroDivisionError):
                    self.__import__('pkg.module')
                self.assertNotIn('pkg', sys.modules)
                self.assertIn('pkg.module', sys.modules)

            

Reported by Pylint.

Lib/test/test_posixpath.py
62 issues
Redefining name 'dirname' from outer scope (line 5)
Error

Line: 33 Column: 16

                  msg = "ABSTFN is not a posix path - tests fail"
    return [test, unittest.skip(msg)(test)][found_backslash]

def safe_rmdir(dirname):
    try:
        os.rmdir(dirname)
    except OSError:
        pass


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import os
import posixpath
import sys
import unittest
from posixpath import realpath, abspath, dirname, basename
from test import test_genericpath
from test.support import import_helper
from test.support import os_helper
from test.support.os_helper import FakePath

            

Reported by Pylint.

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

Line: 23 Column: 1

              
ABSTFN = abspath(os_helper.TESTFN)

def skip_if_ABSTFN_contains_backslash(test):
    """
    On Windows, posixpath.abspath still returns paths with backslashes
    instead of posix forward slashes. If this is the case, several tests
    fail, so skip them.
    """

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 33 Column: 1

                  msg = "ABSTFN is not a posix path - tests fail"
    return [test, unittest.skip(msg)(test)][found_backslash]

def safe_rmdir(dirname):
    try:
        os.rmdir(dirname)
    except OSError:
        pass


            

Reported by Pylint.

Too many public methods (34/20)
Error

Line: 39 Column: 1

                  except OSError:
        pass

class PosixPathTest(unittest.TestCase):

    def setUp(self):
        self.tearDown()

    def tearDown(self):

            

Reported by Pylint.

Missing class docstring
Error

Line: 39 Column: 1

                  except OSError:
        pass

class PosixPathTest(unittest.TestCase):

    def setUp(self):
        self.tearDown()

    def tearDown(self):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 49 Column: 5

                          os_helper.unlink(os_helper.TESTFN + suffix)
            safe_rmdir(os_helper.TESTFN + suffix)

    def test_join(self):
        self.assertEqual(posixpath.join("/foo", "bar", "/bar", "baz"),
                         "/bar/baz")
        self.assertEqual(posixpath.join("/foo", "bar", "baz"), "/foo/bar/baz")
        self.assertEqual(posixpath.join("/foo/", "bar/", "baz/"),
                         "/foo/bar/baz/")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 63 Column: 5

                      self.assertEqual(posixpath.join(b"/foo/", b"bar/", b"baz/"),
                         b"/foo/bar/baz/")

    def test_split(self):
        self.assertEqual(posixpath.split("/foo/bar"), ("/foo", "bar"))
        self.assertEqual(posixpath.split("/"), ("/", ""))
        self.assertEqual(posixpath.split("foo"), ("", "foo"))
        self.assertEqual(posixpath.split("////foo"), ("////", "foo"))
        self.assertEqual(posixpath.split("//foo//bar"), ("//foo", "bar"))

            

Reported by Pylint.

Method name "splitextTest" doesn't conform to snake_case naming style
Error

Line: 76 Column: 5

                      self.assertEqual(posixpath.split(b"////foo"), (b"////", b"foo"))
        self.assertEqual(posixpath.split(b"//foo//bar"), (b"//foo", b"bar"))

    def splitextTest(self, path, filename, ext):
        self.assertEqual(posixpath.splitext(path), (filename, ext))
        self.assertEqual(posixpath.splitext("/" + path), ("/" + filename, ext))
        self.assertEqual(posixpath.splitext("abc/" + path),
                         ("abc/" + filename, ext))
        self.assertEqual(posixpath.splitext("abc.def/" + path),

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 76 Column: 5

                      self.assertEqual(posixpath.split(b"////foo"), (b"////", b"foo"))
        self.assertEqual(posixpath.split(b"//foo//bar"), (b"//foo", b"bar"))

    def splitextTest(self, path, filename, ext):
        self.assertEqual(posixpath.splitext(path), (filename, ext))
        self.assertEqual(posixpath.splitext("/" + path), ("/" + filename, ext))
        self.assertEqual(posixpath.splitext("abc/" + path),
                         ("abc/" + filename, ext))
        self.assertEqual(posixpath.splitext("abc.def/" + path),

            

Reported by Pylint.

Lib/unittest/test/test_skipping.py
62 issues
class already defined line 9
Error

Line: 20 Column: 9

                      self.assertEqual(result.skipped, [(test, "skip")])

        # Try letting setUp skip the test now.
        class Foo(unittest.TestCase):
            def setUp(self):
                self.skipTest("testing")
            def test_nothing(self): pass
        events = []
        result = LoggingResult(events)

            

Reported by Pylint.

Redundant use of assertTrue with constant value False
Error

Line: 127 Column: 17

                      @unittest.expectedFailure
        class Foo(unittest.TestCase):
            def test_1(self):
                self.assertTrue(False)

        events = []
        result = LoggingResult(events)
        test = Foo("test_1")
        test.run(result)

            

Reported by Pylint.

Redundant use of assertTrue with constant value False
Error

Line: 141 Column: 17

                  def test_expected_failure_with_wrapped_subclass(self):
        class Foo(unittest.TestCase):
            def test_1(self):
                self.assertTrue(False)

        @unittest.expectedFailure
        class Bar(Foo):
            pass


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import unittest

from unittest.test.support import LoggingResult


class Test_TestSkipping(unittest.TestCase):

    def test_skipping(self):
        class Foo(unittest.TestCase):

            

Reported by Pylint.

Missing class docstring
Error

Line: 6 Column: 1

              from unittest.test.support import LoggingResult


class Test_TestSkipping(unittest.TestCase):

    def test_skipping(self):
        class Foo(unittest.TestCase):
            def test_skip_me(self):
                self.skipTest("skip")

            

Reported by Pylint.

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

Line: 6 Column: 1

              from unittest.test.support import LoggingResult


class Test_TestSkipping(unittest.TestCase):

    def test_skipping(self):
        class Foo(unittest.TestCase):
            def test_skip_me(self):
                self.skipTest("skip")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 5

              
class Test_TestSkipping(unittest.TestCase):

    def test_skipping(self):
        class Foo(unittest.TestCase):
            def test_skip_me(self):
                self.skipTest("skip")
        events = []
        result = LoggingResult(events)

            

Reported by Pylint.

Missing class docstring
Error

Line: 9 Column: 9

              class Test_TestSkipping(unittest.TestCase):

    def test_skipping(self):
        class Foo(unittest.TestCase):
            def test_skip_me(self):
                self.skipTest("skip")
        events = []
        result = LoggingResult(events)
        test = Foo("test_skip_me")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 13

              
    def test_skipping(self):
        class Foo(unittest.TestCase):
            def test_skip_me(self):
                self.skipTest("skip")
        events = []
        result = LoggingResult(events)
        test = Foo("test_skip_me")
        test.run(result)

            

Reported by Pylint.

Missing class docstring
Error

Line: 20 Column: 9

                      self.assertEqual(result.skipped, [(test, "skip")])

        # Try letting setUp skip the test now.
        class Foo(unittest.TestCase):
            def setUp(self):
                self.skipTest("testing")
            def test_nothing(self): pass
        events = []
        result = LoggingResult(events)

            

Reported by Pylint.

PC/launcher.c
62 issues
Uninitialized variable: executable
Error

Line: 2003 CWE codes: 908

                          executable = ip->executable;
        }
    }
    if (executable != NULL)
        invoke_child(executable, NULL, command);
    else
        rc = RC_NO_PYTHON;
    return rc;
}

            

Reported by Cppcheck.

fwprintf - If format strings can be influenced by an attacker, they can be exploited
Security

Line: 1605 Column: 17 CWE codes: 134
Suggestion: Use a constant for the format specification

                          }

            if (ip->exe_display[0]) {
                fwprintf(stdout, fmt, version, ip->exe_display);
            }
            else {
                fwprintf(stdout, fmt, version, ip->executable);
            }
            /* If there is a default indicate it */

            

Reported by FlawFinder.

fwprintf - If format strings can be influenced by an attacker, they can be exploited
Security

Line: 1608 Column: 17 CWE codes: 134
Suggestion: Use a constant for the format specification

                              fwprintf(stdout, fmt, version, ip->exe_display);
            }
            else {
                fwprintf(stdout, fmt, version, ip->executable);
            }
            /* If there is a default indicate it */
            if (defpy == ip)
                fwprintf(stderr, defind);
        }

            

Reported by FlawFinder.

fwprintf - If format strings can be influenced by an attacker, they can be exploited
Security

Line: 1612 Column: 17 CWE codes: 134
Suggestion: Use a constant for the format specification

                          }
            /* If there is a default indicate it */
            if (defpy == ip)
                fwprintf(stderr, defind);
        }
    }

    if ((defpy == NULL) && (num_installed_pythons > 0))
        /* We have pythons but none is the default */

            

Reported by FlawFinder.

fwprintf - If format strings can be influenced by an attacker, they can be exploited
Security

Line: 1963 Column: 17 CWE codes: 134
Suggestion: Use a constant for the format specification

                          ip = locate_python(&p[1], FALSE);
            if (ip == NULL)
            {
                fwprintf(stdout, \
                         L"Python %ls not found!\n", &p[1]);
                valid = show_python_list(argv);
                error(RC_NO_PYTHON, L"Requested Python version (%ls) not \
installed, use -0 for available pythons", &p[1]);
            }

            

Reported by FlawFinder.

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

Line: 90 Column: 5 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              error(int rc, wchar_t * format, ... )
{
    va_list va;
    wchar_t message[MSGSIZE];
    wchar_t win_message[MSGSIZE];
    int len;

    va_start(va, format);
    len = _vsnwprintf_s(message, MSGSIZE, _TRUNCATE, format, va);

            

Reported by FlawFinder.

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

Line: 91 Column: 5 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              {
    va_list va;
    wchar_t message[MSGSIZE];
    wchar_t win_message[MSGSIZE];
    int len;

    va_start(va, format);
    len = _vsnwprintf_s(message, MSGSIZE, _TRUNCATE, format, va);
    va_end(va);

            

Reported by FlawFinder.

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

Line: 122 Column: 12 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              static wchar_t * get_env(wchar_t * key)
{
    /* This is not thread-safe, just like getenv */
    static wchar_t buf[BUFSIZE];
    DWORD result = GetEnvironmentVariableW(key, buf, BUFSIZE);

    if (result >= BUFSIZE) {
        /* Large environment variable. Accept some leakage */
        wchar_t *buf2 = (wchar_t*)malloc(sizeof(wchar_t) * (result+1));

            

Reported by FlawFinder.

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

Line: 172 Column: 5 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              #define MAX_VERSION_SIZE    8

typedef struct {
    wchar_t version[MAX_VERSION_SIZE]; /* m.n */
    int bits;   /* 32 or 64 */
    wchar_t executable[MAX_PATH];
    wchar_t exe_display[MAX_PATH];
} INSTALLED_PYTHON;


            

Reported by FlawFinder.

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

Line: 174 Column: 5 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              typedef struct {
    wchar_t version[MAX_VERSION_SIZE]; /* m.n */
    int bits;   /* 32 or 64 */
    wchar_t executable[MAX_PATH];
    wchar_t exe_display[MAX_PATH];
} INSTALLED_PYTHON;

/*
 * To avoid messing about with heap allocations, just assume we can allocate

            

Reported by FlawFinder.

Lib/multiprocessing/process.py
61 issues
Too many positional arguments for method call
Error

Line: 121 Column: 23

                      assert not _current_process._config.get('daemon'), \
               'daemonic processes are not allowed to have children'
        _cleanup()
        self._popen = self._Popen(self)
        self._sentinel = self._popen.sentinel
        # Avoid a refcycle if the target function holds an indirect
        # reference to the process object (see bpo-30775)
        del self._target, self._args, self._kwargs
        _children.add(self)

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 291 Column: 9

                  ##

    def _bootstrap(self, parent_sentinel=None):
        from . import util, context
        global _current_process, _parent_process, _process_counter, _children

        try:
            if self._start_method is not None:
                context._force_start_method(self._start_method)

            

Reported by Pylint.

Instance of 'BaseProcess' has no '_start_method' member
Error

Line: 295 Column: 16

                      global _current_process, _parent_process, _process_counter, _children

        try:
            if self._start_method is not None:
                context._force_start_method(self._start_method)
            _process_counter = itertools.count(1)
            _children = set()
            util._close_stdin()
            old_process = _current_process

            

Reported by Pylint.

Instance of 'BaseProcess' has no '_start_method' member
Error

Line: 296 Column: 45

              
        try:
            if self._start_method is not None:
                context._force_start_method(self._start_method)
            _process_counter = itertools.count(1)
            _children = set()
            util._close_stdin()
            old_process = _current_process
            _current_process = self

            

Reported by Pylint.

Cannot import 'traceback' due to syntax error 'invalid syntax (<unknown>, line 576)'
Error

Line: 329 Column: 1

                              exitcode = 1
        except:
            exitcode = 1
            import traceback
            sys.stderr.write('Process %s:\n' % self.name)
            traceback.print_exc()
        finally:
            threading._shutdown()
            util.info('process exiting with exitcode %d' % exitcode)

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 345 Column: 9

              
class AuthenticationString(bytes):
    def __reduce__(self):
        from .context import get_spawning_popen
        if get_spawning_popen() is None:
            raise TypeError(
                'Pickling an AuthenticationString object is '
                'disallowed for security reasons'
                )

            

Reported by Pylint.

Access to a protected member _popen of a client class
Error

Line: 64 Column: 12

              def _cleanup():
    # check for processes which have finished
    for p in list(_children):
        if p._popen.poll() is not None:
            _children.discard(p)

#
# The `Process` class
#

            

Reported by Pylint.

Redefining name 'name' from outer scope (line 427)
Error

Line: 80 Column: 49

                  def _Popen(self):
        raise NotImplementedError

    def __init__(self, group=None, target=None, name=None, args=(), kwargs={},
                 *, daemon=None):
        assert group is None, 'group argument must be None for now'
        count = next(_process_counter)
        self._identity = _current_process._identity + (count,)
        self._config = _current_process._config.copy()

            

Reported by Pylint.

Dangerous default value {} as argument
Error

Line: 80 Column: 5

                  def _Popen(self):
        raise NotImplementedError

    def __init__(self, group=None, target=None, name=None, args=(), kwargs={},
                 *, daemon=None):
        assert group is None, 'group argument must be None for now'
        count = next(_process_counter)
        self._identity = _current_process._identity + (count,)
        self._config = _current_process._config.copy()

            

Reported by Pylint.

Access to a protected member _config of a client class
Error

Line: 118 Column: 20

                      assert self._popen is None, 'cannot start a process twice'
        assert self._parent_pid == os.getpid(), \
               'can only start a process object created by current process'
        assert not _current_process._config.get('daemon'), \
               'daemonic processes are not allowed to have children'
        _cleanup()
        self._popen = self._Popen(self)
        self._sentinel = self._popen.sentinel
        # Avoid a refcycle if the target function holds an indirect

            

Reported by Pylint.

Lib/encodings/mac_arabic.py
61 issues
Redefining built-in 'input'
Error

Line: 11 Column: 21

              
class Codec(codecs.Codec):

    def encode(self,input,errors='strict'):
        return codecs.charmap_encode(input,errors,encoding_map)

    def decode(self,input,errors='strict'):
        return codecs.charmap_decode(input,errors,decoding_table)


            

Reported by Pylint.

Redefining built-in 'input'
Error

Line: 14 Column: 21

                  def encode(self,input,errors='strict'):
        return codecs.charmap_encode(input,errors,encoding_map)

    def decode(self,input,errors='strict'):
        return codecs.charmap_decode(input,errors,decoding_table)

class IncrementalEncoder(codecs.IncrementalEncoder):
    def encode(self, input, final=False):
        return codecs.charmap_encode(input,self.errors,encoding_map)[0]

            

Reported by Pylint.

Redefining built-in 'input'
Error

Line: 18 Column: 22

                      return codecs.charmap_decode(input,errors,decoding_table)

class IncrementalEncoder(codecs.IncrementalEncoder):
    def encode(self, input, final=False):
        return codecs.charmap_encode(input,self.errors,encoding_map)[0]

class IncrementalDecoder(codecs.IncrementalDecoder):
    def decode(self, input, final=False):
        return codecs.charmap_decode(input,self.errors,decoding_table)[0]

            

Reported by Pylint.

Redefining built-in 'input'
Error

Line: 22 Column: 22

                      return codecs.charmap_encode(input,self.errors,encoding_map)[0]

class IncrementalDecoder(codecs.IncrementalDecoder):
    def decode(self, input, final=False):
        return codecs.charmap_decode(input,self.errors,decoding_table)[0]

class StreamWriter(Codec,codecs.StreamWriter):
    pass


            

Reported by Pylint.

Duplicate key 36 in dictionary
Error

Line: 441 Column: 16

              
### Encoding Map

encoding_map = {
    0x0000: 0x0000,     #  CONTROL CHARACTER
    0x0001: 0x0001,     #  CONTROL CHARACTER
    0x0002: 0x0002,     #  CONTROL CHARACTER
    0x0003: 0x0003,     #  CONTROL CHARACTER
    0x0004: 0x0004,     #  CONTROL CHARACTER

            

Reported by Pylint.

Duplicate key 39 in dictionary
Error

Line: 441 Column: 16

              
### Encoding Map

encoding_map = {
    0x0000: 0x0000,     #  CONTROL CHARACTER
    0x0001: 0x0001,     #  CONTROL CHARACTER
    0x0002: 0x0002,     #  CONTROL CHARACTER
    0x0003: 0x0003,     #  CONTROL CHARACTER
    0x0004: 0x0004,     #  CONTROL CHARACTER

            

Reported by Pylint.

Duplicate key 92 in dictionary
Error

Line: 441 Column: 16

              
### Encoding Map

encoding_map = {
    0x0000: 0x0000,     #  CONTROL CHARACTER
    0x0001: 0x0001,     #  CONTROL CHARACTER
    0x0002: 0x0002,     #  CONTROL CHARACTER
    0x0003: 0x0003,     #  CONTROL CHARACTER
    0x0004: 0x0004,     #  CONTROL CHARACTER

            

Reported by Pylint.

Duplicate key 91 in dictionary
Error

Line: 441 Column: 16

              
### Encoding Map

encoding_map = {
    0x0000: 0x0000,     #  CONTROL CHARACTER
    0x0001: 0x0001,     #  CONTROL CHARACTER
    0x0002: 0x0002,     #  CONTROL CHARACTER
    0x0003: 0x0003,     #  CONTROL CHARACTER
    0x0004: 0x0004,     #  CONTROL CHARACTER

            

Reported by Pylint.

Duplicate key 62 in dictionary
Error

Line: 441 Column: 16

              
### Encoding Map

encoding_map = {
    0x0000: 0x0000,     #  CONTROL CHARACTER
    0x0001: 0x0001,     #  CONTROL CHARACTER
    0x0002: 0x0002,     #  CONTROL CHARACTER
    0x0003: 0x0003,     #  CONTROL CHARACTER
    0x0004: 0x0004,     #  CONTROL CHARACTER

            

Reported by Pylint.

Duplicate key 61 in dictionary
Error

Line: 441 Column: 16

              
### Encoding Map

encoding_map = {
    0x0000: 0x0000,     #  CONTROL CHARACTER
    0x0001: 0x0001,     #  CONTROL CHARACTER
    0x0002: 0x0002,     #  CONTROL CHARACTER
    0x0003: 0x0003,     #  CONTROL CHARACTER
    0x0004: 0x0004,     #  CONTROL CHARACTER

            

Reported by Pylint.

Lib/tabnanny.py
61 issues
XXX Note: this is now a standard library module.
Error

Line: 17 Column: 3

              
# Released to the public domain, by Tim Peters, 15 April 1998.

# XXX Note: this is now a standard library module.
# XXX The API needs to undergo changes however; the current code is too
# XXX script-like.  This will be addressed later.

__version__ = "6"


            

Reported by Pylint.

XXX The API needs to undergo changes however; the current code is too
Error

Line: 18 Column: 3

              # Released to the public domain, by Tim Peters, 15 April 1998.

# XXX Note: this is now a standard library module.
# XXX The API needs to undergo changes however; the current code is too
# XXX script-like.  This will be addressed later.

__version__ = "6"

import os

            

Reported by Pylint.

XXX script-like. This will be addressed later.
Error

Line: 19 Column: 3

              
# XXX Note: this is now a standard library module.
# XXX The API needs to undergo changes however; the current code is too
# XXX script-like.  This will be addressed later.

__version__ = "6"

import os
import sys

            

Reported by Pylint.

Using the global statement
Error

Line: 44 Column: 5

              def main():
    import getopt

    global verbose, filename_only
    try:
        opts, args = getopt.getopt(sys.argv[1:], "qv")
    except getopt.error as msg:
        errprint(msg)
        return

            

Reported by Pylint.

Unused variable 'a'
Error

Line: 50 Column: 12

                  except getopt.error as msg:
        errprint(msg)
        return
    for o, a in opts:
        if o == '-q':
            filename_only = filename_only + 1
        if o == '-v':
            verbose = verbose + 1
    if not args:

            

Reported by Pylint.

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

Line: 66 Column: 5

                  Raised by process_tokens() if detecting an ambiguous indent.
    Captured and handled in check().
    """
    def __init__(self, lineno, msg, line):
        self.lineno, self.msg, self.line = lineno, msg, line
    def get_lineno(self):
        return self.lineno
    def get_msg(self):
        return self.msg

            

Reported by Pylint.

Redefining built-in 'type'
Error

Line: 285 Column: 10

                  indents = [Whitespace("")]
    check_equal = 0

    for (type, token, start, end, line) in tokens:
        if type == NEWLINE:
            # a program statement, or ENDMARKER, will eventually follow,
            # after some (possibly empty) run of tokens of the form
            #     (NL | COMMENT)* (INDENT | DEDENT+)?
            # If an INDENT appears, setting check_equal is wrong, and will

            

Reported by Pylint.

Unused variable 'end'
Error

Line: 285 Column: 30

                  indents = [Whitespace("")]
    check_equal = 0

    for (type, token, start, end, line) in tokens:
        if type == NEWLINE:
            # a program statement, or ENDMARKER, will eventually follow,
            # after some (possibly empty) run of tokens of the form
            #     (NL | COMMENT)* (INDENT | DEDENT+)?
            # If an INDENT appears, setting check_equal is wrong, and will

            

Reported by Pylint.

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

Line: 31 Column: 1

              
__all__ = ["check", "NannyNag", "process_tokens"]

verbose = 0
filename_only = 0

def errprint(*args):
    sep = ""
    for arg in args:

            

Reported by Pylint.

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

Line: 32 Column: 1

              __all__ = ["check", "NannyNag", "process_tokens"]

verbose = 0
filename_only = 0

def errprint(*args):
    sep = ""
    for arg in args:
        sys.stderr.write(sep + str(arg))

            

Reported by Pylint.