The following issues were found

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.

Tools/unicode/genmap_japanese.py
61 issues
Wildcard import genmap_support
Error

Line: 9 Column: 1

              #
import os

from genmap_support import *

JISX0208_C1 = (0x21, 0x74)
JISX0208_C2 = (0x21, 0x7e)
JISX0212_C1 = (0x22, 0x6d)
JISX0212_C2 = (0x21, 0x7e)

            

Reported by Pylint.

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

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

                          continue

        row = line.split()
        loc = eval('0x' + row[0][2:])
        level = eval(row[0][0])
        m = None
        if len(row[1].split('+')) == 2: # single unicode
            uni = eval('0x' + row[1][2:])
            if level == 3:

            

Reported by Bandit.

Use of eval
Error

Line: 40 Column: 15

                          continue

        row = line.split()
        loc = eval('0x' + row[0][2:])
        level = eval(row[0][0])
        m = None
        if len(row[1].split('+')) == 2: # single unicode
            uni = eval('0x' + row[1][2:])
            if level == 3:

            

Reported by Pylint.

Use of eval
Error

Line: 41 Column: 17

              
        row = line.split()
        loc = eval('0x' + row[0][2:])
        level = eval(row[0][0])
        m = None
        if len(row[1].split('+')) == 2: # single unicode
            uni = eval('0x' + row[1][2:])
            if level == 3:
                if uni < 0x10000:

            

Reported by Pylint.

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

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

              
        row = line.split()
        loc = eval('0x' + row[0][2:])
        level = eval(row[0][0])
        m = None
        if len(row[1].split('+')) == 2: # single unicode
            uni = eval('0x' + row[1][2:])
            if level == 3:
                if uni < 0x10000:

            

Reported by Bandit.

Use of eval
Error

Line: 44 Column: 19

                      level = eval(row[0][0])
        m = None
        if len(row[1].split('+')) == 2: # single unicode
            uni = eval('0x' + row[1][2:])
            if level == 3:
                if uni < 0x10000:
                    m = decmap3
                elif 0x20000 <= uni < 0x30000:
                    uni -= 0x20000

            

Reported by Pylint.

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

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

                      level = eval(row[0][0])
        m = None
        if len(row[1].split('+')) == 2: # single unicode
            uni = eval('0x' + row[1][2:])
            if level == 3:
                if uni < 0x10000:
                    m = decmap3
                elif 0x20000 <= uni < 0x30000:
                    uni -= 0x20000

            

Reported by Bandit.

Use of eval
Error

Line: 60 Column: 25

                          m.setdefault((loc >> 8), {})
            m[(loc >> 8)][(loc & 0xff)] = uni
        else: # pair
            uniprefix = eval('0x' + row[1][2:6]) # body
            uni = eval('0x' + row[1][7:11]) # modifier
            if level != 3:
                raise ValueError("invalid map")
            decmap3_pair.setdefault(uniprefix, {})
            m = decmap3_pair[uniprefix]

            

Reported by Pylint.

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

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

                          m.setdefault((loc >> 8), {})
            m[(loc >> 8)][(loc & 0xff)] = uni
        else: # pair
            uniprefix = eval('0x' + row[1][2:6]) # body
            uni = eval('0x' + row[1][7:11]) # modifier
            if level != 3:
                raise ValueError("invalid map")
            decmap3_pair.setdefault(uniprefix, {})
            m = decmap3_pair[uniprefix]

            

Reported by Bandit.

Use of eval
Error

Line: 61 Column: 19

                          m[(loc >> 8)][(loc & 0xff)] = uni
        else: # pair
            uniprefix = eval('0x' + row[1][2:6]) # body
            uni = eval('0x' + row[1][7:11]) # modifier
            if level != 3:
                raise ValueError("invalid map")
            decmap3_pair.setdefault(uniprefix, {})
            m = decmap3_pair[uniprefix]


            

Reported by Pylint.

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

Line: 9 Column: 1

              import os
import sys
import time
import traceback
import unittest

from test import support
from test.support import os_helper
from test.libregrtest.cmdline import Namespace

            

Reported by Pylint.

Value 'list' is unsubscriptable
Error

Line: 24 Column: 19

                      self,
        name: str,
        duration_sec: float = 0.0,
        xml_data: list[str] | None = None,
    ) -> None:
        self.name = name
        self.duration_sec = duration_sec
        self.xml_data = xml_data


            

Reported by Pylint.

Value 'list' is unsubscriptable
Error

Line: 44 Column: 19

                      self,
        name: str,
        duration_sec: float = 0.0,
        xml_data: list[str] | None = None,
        errors: list[tuple[str, str]] | None = None,
        failures: list[tuple[str, str]] | None = None,
    ) -> None:
        super().__init__(name, duration_sec=duration_sec, xml_data=xml_data)
        self.errors = errors

            

Reported by Pylint.

Value 'list' is unsubscriptable
Error

Line: 45 Column: 17

                      name: str,
        duration_sec: float = 0.0,
        xml_data: list[str] | None = None,
        errors: list[tuple[str, str]] | None = None,
        failures: list[tuple[str, str]] | None = None,
    ) -> None:
        super().__init__(name, duration_sec=duration_sec, xml_data=xml_data)
        self.errors = errors
        self.failures = failures

            

Reported by Pylint.

Value 'tuple' is unsubscriptable
Error

Line: 45 Column: 22

                      name: str,
        duration_sec: float = 0.0,
        xml_data: list[str] | None = None,
        errors: list[tuple[str, str]] | None = None,
        failures: list[tuple[str, str]] | None = None,
    ) -> None:
        super().__init__(name, duration_sec=duration_sec, xml_data=xml_data)
        self.errors = errors
        self.failures = failures

            

Reported by Pylint.

Value 'tuple' is unsubscriptable
Error

Line: 46 Column: 24

                      duration_sec: float = 0.0,
        xml_data: list[str] | None = None,
        errors: list[tuple[str, str]] | None = None,
        failures: list[tuple[str, str]] | None = None,
    ) -> None:
        super().__init__(name, duration_sec=duration_sec, xml_data=xml_data)
        self.errors = errors
        self.failures = failures


            

Reported by Pylint.

Value 'list' is unsubscriptable
Error

Line: 46 Column: 19

                      duration_sec: float = 0.0,
        xml_data: list[str] | None = None,
        errors: list[tuple[str, str]] | None = None,
        failures: list[tuple[str, str]] | None = None,
    ) -> None:
        super().__init__(name, duration_sec=duration_sec, xml_data=xml_data)
        self.errors = errors
        self.failures = failures


            

Reported by Pylint.

Dangerous default value STDTESTS (builtins.list) as argument
Error

Line: 155 Column: 1

                  return path or os.path.dirname(os.path.dirname(__file__)) or os.curdir


def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS):
    """Return a list of all applicable test modules."""
    testdir = findtestdir(testdir)
    names = os.listdir(testdir)
    tests = []
    others = set(stdtests) | nottests

            

Reported by Pylint.

Dangerous default value NOTTESTS (builtins.set) as argument
Error

Line: 155 Column: 1

                  return path or os.path.dirname(os.path.dirname(__file__)) or os.curdir


def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS):
    """Return a list of all applicable test modules."""
    testdir = findtestdir(testdir)
    names = os.listdir(testdir)
    tests = []
    others = set(stdtests) | nottests

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 246 Column: 5

                  """
    try:
        return _runtest(ns, test_name)
    except:
        if not ns.pgo:
            msg = traceback.format_exc()
            print(f"test {test_name} crashed -- {msg}",
                  file=sys.stderr, flush=True)
        return Failed(test_name)

            

Reported by Pylint.

Lib/mimetypes.py
61 issues
Redefining built-in 'type'
Error

Line: 79 Column: 19

                      self.suffix_map = _suffix_map_default.copy()
        self.types_map = ({}, {}) # dict for (non-strict, strict)
        self.types_map_inv = ({}, {})
        for (ext, type) in _types_map_default.items():
            self.add_type(type, ext, True)
        for (ext, type) in _common_types_default.items():
            self.add_type(type, ext, False)
        for name in filenames:
            self.read(name, strict)

            

Reported by Pylint.

Redefining built-in 'type'
Error

Line: 86 Column: 24

                      for name in filenames:
            self.read(name, strict)

    def add_type(self, type, ext, strict=True):
        """Add a mapping between a type and an extension.

        When the extension is already known, the new
        type will replace the old one. When the type
        is already known the extension will be added

            

Reported by Pylint.

Access to a protected member _splittype of a client class
Error

Line: 123 Column: 23

                      but non-standard types.
        """
        url = os.fspath(url)
        scheme, url = urllib.parse._splittype(url)
        if scheme == 'data':
            # syntax of data URLs:
            # dataurl   := "data:" [ mediatype ] [ ";base64" ] "," data
            # mediatype := [ type "/" subtype ] *( ";" parameter )
            # data      := *urlchar

            

Reported by Pylint.

Redefining built-in 'type'
Error

Line: 137 Column: 17

                              return None, None
            semi = url.find(';', 0, comma)
            if semi >= 0:
                type = url[:semi]
            else:
                type = url[:comma]
            if '=' in type or '/' not in type:
                type = 'text/plain'
            return type, None           # never compressed, so encoding is None

            

Reported by Pylint.

Redefining name 'types_map' from outer scope (line 384)
Error

Line: 151 Column: 9

                          base, ext = posixpath.splitext(base)
        else:
            encoding = None
        types_map = self.types_map[True]
        if ext in types_map:
            return types_map[ext], encoding
        elif ext.lower() in types_map:
            return types_map[ext.lower()], encoding
        elif strict:

            

Reported by Pylint.

Redefining built-in 'type'
Error

Line: 166 Column: 36

                      else:
            return None, encoding

    def guess_all_extensions(self, type, strict=True):
        """Guess the extensions for a file based on its MIME type.

        Return value is a list of strings giving the possible filename
        extensions, including the leading dot ('.').  The extension is not
        guaranteed to have been associated with any particular data stream,

            

Reported by Pylint.

Redefining built-in 'type'
Error

Line: 185 Column: 31

                                  extensions.append(ext)
        return extensions

    def guess_extension(self, type, strict=True):
        """Guess the extension for a file based on its MIME type.

        Return value is a string giving a filename extension,
        including the leading dot ('.').  The extension is not
        guaranteed to have been associated with any particular data

            

Reported by Pylint.

Redefining built-in 'type'
Error

Line: 233 Column: 13

                                  break
            if not words:
                continue
            type, suffixes = words[0], words[1:]
            for suff in suffixes:
                self.add_type(type, '.' + suff, strict)

    def read_windows_registry(self, strict=True):
        """

            

Reported by Pylint.

Redefining name 'add_type' from outer scope (line 345)
Error

Line: 249 Column: 9

                      if not _mimetypes_read_windows_registry and not _winreg:
            return

        add_type = self.add_type
        if strict:
            add_type = lambda type, ext: self.add_type(type, ext, True)

        # Accelerated function if it is available
        if _mimetypes_read_windows_registry:

            

Reported by Pylint.

Redefining name 'add_type' from outer scope (line 345)
Error

Line: 260 Column: 37

                          self._read_windows_registry(add_type)

    @classmethod
    def _read_windows_registry(cls, add_type):
        def enum_types(mimedb):
            i = 0
            while True:
                try:
                    ctype = _winreg.EnumKey(mimedb, i)

            

Reported by Pylint.

Lib/test/test_poll.py
61 issues
subprocess call with shell=True identified, security issue.
Security injection

Line: 125
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html

              
    def test_poll2(self):
        cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 1; done'
        proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
                                bufsize=0)
        proc.__enter__()
        self.addCleanup(proc.__exit__, None, None, None)
        p = proc.stdout
        pollster = select.poll()

            

Reported by Bandit.

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

Line: 18 Column: 5

              try:
    select.poll
except AttributeError:
    raise unittest.SkipTest("select.poll not defined")


def find_ready_matching(ready, flag):
    match = []
    for fd, mode in ready:

            

Reported by Pylint.

Unused variable 'i'
Error

Line: 44 Column: 13

                      r2w = {}
        w2r = {}

        for i in range(NUM_PIPES):
            rd, wr = os.pipe()
            p.register(rd)
            p.modify(rd, select.POLLIN)
            p.register(wr, select.POLLOUT)
            readers.append(rd)

            

Reported by Pylint.

Unused variable 'fd'
Error

Line: 136 Column: 13

                          fdlist = pollster.poll(tout)
            if (fdlist == []):
                continue
            fd, flags = fdlist[0]
            if flags & select.POLLHUP:
                line = p.readline()
                if line != b"":
                    self.fail('error: pipe seems to be closed, but still returns data')
                continue

            

Reported by Pylint.

Unused variable 'i'
Error

Line: 187 Column: 13

                      self.addCleanup(os.close, r)
        self.addCleanup(os.close, w)
        rfds = []
        for i in range(10):
            fd = os.dup(r)
            self.addCleanup(os.close, fd)
            rfds.append(fd)
        pollster = select.poll()
        for fd in rfds:

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Test case for the os.poll() function

import os
import subprocess
import random
import select
import threading
import time
import unittest

            

Reported by Pylint.

Consider possible security implications associated with subprocess module.
Security blacklist

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

              # Test case for the os.poll() function

import os
import subprocess
import random
import select
import threading
import time
import unittest

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 21 Column: 1

                  raise unittest.SkipTest("select.poll not defined")


def find_ready_matching(ready, flag):
    match = []
    for fd, mode in ready:
        if mode & flag:
            match.append(fd)
    return match

            

Reported by Pylint.

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

Line: 23 Column: 9

              
def find_ready_matching(ready, flag):
    match = []
    for fd, mode in ready:
        if mode & flag:
            match.append(fd)
    return match

class PollTests(unittest.TestCase):

            

Reported by Pylint.

Missing class docstring
Error

Line: 28 Column: 1

                          match.append(fd)
    return match

class PollTests(unittest.TestCase):

    def test_poll1(self):
        # Basic functional test of poll object
        # Create a bunch of pipe and test that poll works with them.


            

Reported by Pylint.

Lib/smtplib.py
61 issues
Argument 'builtins.bytes' does not match format type 'a'
Error

Line: 421 Column: 31

              
        errmsg = b"\n".join(resp)
        if self.debuglevel > 0:
            self._print_debug('reply: retcode (%s); Msg: %a' % (errcode, errmsg))
        return errcode, errmsg

    def docmd(self, cmd, args=""):
        """Send a command, and return its response code."""
        self.putcmd(cmd, args)

            

Reported by Pylint.

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

Line: 99 Column: 5

                  is set to the error message.
    """

    def __init__(self, code, msg):
        self.smtp_code = code
        self.smtp_error = msg
        self.args = (code, msg)

class SMTPSenderRefused(SMTPResponseException):

            

Reported by Pylint.

Redefining name 'msg' from outer scope (line 1124)
Error

Line: 99 Column: 30

                  is set to the error message.
    """

    def __init__(self, code, msg):
        self.smtp_code = code
        self.smtp_error = msg
        self.args = (code, msg)

class SMTPSenderRefused(SMTPResponseException):

            

Reported by Pylint.

Redefining name 'msg' from outer scope (line 1124)
Error

Line: 111 Column: 30

                  exceptions, this sets `sender' to the string that the SMTP refused.
    """

    def __init__(self, code, msg, sender):
        self.smtp_code = code
        self.smtp_error = msg
        self.sender = sender
        self.args = (code, msg, sender)


            

Reported by Pylint.

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

Line: 111 Column: 5

                  exceptions, this sets `sender' to the string that the SMTP refused.
    """

    def __init__(self, code, msg, sender):
        self.smtp_code = code
        self.smtp_error = msg
        self.sender = sender
        self.args = (code, msg, sender)


            

Reported by Pylint.

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

Line: 125 Column: 5

                  SMTP.sendmail() returns.
    """

    def __init__(self, recipients):
        self.recipients = recipients
        self.args = (recipients,)


class SMTPDataError(SMTPResponseException):

            

Reported by Pylint.

Redefining name 'msg' from outer scope (line 1124)
Error

Line: 255 Column: 20

                      self._auth_challenge_count = 0

        if host:
            (code, msg) = self.connect(host, port)
            if code != 220:
                self.close()
                raise SMTPConnectError(code, msg)
        if local_hostname is not None:
            self.local_hostname = local_hostname

            

Reported by Pylint.

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

Line: 337 Column: 21

                              try:
                    port = int(port)
                except ValueError:
                    raise OSError("nonnumeric port")
        if not port:
            port = self.default_port
        sys.audit("smtplib.connect", self, host, port)
        self.sock = self._get_socket(host, port, self.timeout)
        self.file = None

            

Reported by Pylint.

Redefining name 'msg' from outer scope (line 1124)
Error

Line: 343 Column: 16

                      sys.audit("smtplib.connect", self, host, port)
        self.sock = self._get_socket(host, port, self.timeout)
        self.file = None
        (code, msg) = self.getreply()
        if self.debuglevel > 0:
            self._print_debug('connect:', repr(msg))
        return (code, msg)

    def send(self, s):

            

Reported by Pylint.

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

Line: 363 Column: 17

                              self.sock.sendall(s)
            except OSError:
                self.close()
                raise SMTPServerDisconnected('Server not connected')
        else:
            raise SMTPServerDisconnected('please run connect() first')

    def putcmd(self, cmd, args=""):
        """Send a command to the server."""

            

Reported by Pylint.

Modules/posixmodule.c
61 issues
chmod - This accepts filename arguments; if an attacker can move those files, a race condition results.
Security

Line: 3315 Column: 18 CWE codes: 362
Suggestion: Use fchmod( ) instead

                  }
    else
#endif /* HAVE_FHCMODAT */
        result = chmod(path->narrow, mode);
    Py_END_ALLOW_THREADS

    if (result) {
#ifdef HAVE_FCHMODAT
        if (fchmodat_unsupported) {

            

Reported by FlawFinder.

chown - This accepts filename arguments; if an attacker can move those files, a race condition results.
Security

Line: 3665 Column: 18 CWE codes: 362
Suggestion: Use fchown( ) instead

                    }
    } else
#endif
        result = chown(path->narrow, uid, gid);
    Py_END_ALLOW_THREADS

#ifdef HAVE_FCHOWNAT
    if (fchownat_unsupported) {
        /* This would be incorrect if the current platform

            

Reported by FlawFinder.

There is an unknown macro here somewhere. Configuration is required. If Py_END_ALLOW_THREADS is a macro then please configure it.
Error

Line: 4874

              
    Py_BEGIN_ALLOW_THREADS
    result = system(bytes);
    Py_END_ALLOW_THREADS
    return result;
}
#endif
#endif /* HAVE_SYSTEM */


            

Reported by Cppcheck.

readlink - This accepts filename arguments; if an attacker can move those files or change the link content, a race condition results. Also, it does not terminate with ASCII NUL.
Security

Line: 8558 Column: 18 CWE codes: 362 20
Suggestion: Reconsider approach

                      }
    } else
#endif
        length = readlink(path->narrow, buffer, MAXPATHLEN);
    Py_END_ALLOW_THREADS

#ifdef HAVE_READLINKAT
    if (readlinkat_unavailable) {
        argument_unavailable_error(NULL, "dir_fd");

            

Reported by FlawFinder.

access - This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition
Security

Line: 1902 Column: 31 CWE codes: 362/367!
Suggestion: Set up the correct permissions (e.g., using setuid()) and try to open the file directly

                      flags |= FILE_FLAG_OPEN_REPARSE_POINT;
    }

    hFile = CreateFileW(path, access, 0, NULL, OPEN_EXISTING, flags, NULL);
    if (hFile == INVALID_HANDLE_VALUE) {
        /* Either the path doesn't exist, or the caller lacks access. */
        error = GetLastError();
        switch (error) {
        case ERROR_ACCESS_DENIED:     /* Cannot sync or read attributes. */

            

Reported by FlawFinder.

access - This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition
Security

Line: 1927 Column: 39 CWE codes: 362/367!
Suggestion: Set up the correct permissions (e.g., using setuid()) and try to open the file directly

              
        case ERROR_INVALID_PARAMETER:
            /* \\.\con requires read or write access. */
            hFile = CreateFileW(path, access | GENERIC_READ,
                        FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
                        OPEN_EXISTING, flags, NULL);
            if (hFile == INVALID_HANDLE_VALUE) {
                SetLastError(error);
                return -1;

            

Reported by FlawFinder.

access - This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition
Security

Line: 1941 Column: 43 CWE codes: 362/367!
Suggestion: Set up the correct permissions (e.g., using setuid()) and try to open the file directly

                          if (traverse) {
                traverse = FALSE;
                isUnhandledTag = TRUE;
                hFile = CreateFileW(path, access, 0, NULL, OPEN_EXISTING,
                            flags | FILE_FLAG_OPEN_REPARSE_POINT, NULL);
            }
            if (hFile == INVALID_HANDLE_VALUE) {
                SetLastError(error);
                return -1;

            

Reported by FlawFinder.

access - This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition
Security

Line: 3024 Column: 18 CWE codes: 362/367!
Suggestion: Set up the correct permissions (e.g., using setuid()) and try to open the file directly

                  }
    else
#endif
        result = access(path->narrow, mode);
    Py_END_ALLOW_THREADS

#ifdef HAVE_FACCESSAT
    if (faccessat_unavailable) {
        if (dir_fd != DEFAULT_DIR_FD) {

            

Reported by FlawFinder.

wcscpy - Does not check for buffer overflows when copying to destination [MS-banned]
Security

Line: 4034 Column: 5 CWE codes: 120
Suggestion: Consider using a function version that stops copying at the end of the buffer

                      PyErr_NoMemory();
        goto exit;
    }
    wcscpy(wnamebuf, po_wchars);
    if (len > 0) {
        wchar_t wch = wnamebuf[len-1];
        if (wch != SEP && wch != ALTSEP && wch != L':')
            wnamebuf[len++] = SEP;
        wcscpy(wnamebuf + len, L"*.*");

            

Reported by FlawFinder.

wcscpy - Does not check for buffer overflows when copying to destination [MS-banned]
Security

Line: 4439 Column: 5 CWE codes: 120
Suggestion: Consider using a function version that stops copying at the end of the buffer

                  if (!buffer) {
        return NULL;
    }
    wcscpy(buffer, path->wide);
    for (wchar_t *p = wcschr(buffer, L'/'); p; p = wcschr(p, L'/')) {
        *p = L'\\';
    }

    Py_BEGIN_ALLOW_THREADS

            

Reported by FlawFinder.

Lib/idlelib/idle_test/test_pyparse.py
61 issues
No value for argument 'is_char_in_string' in method call
Error

Line: 85 Column: 13

              
        # Passing no value or non-callable should fail (issue 32989).
        with self.assertRaises(TypeError):
            start()
        with self.assertRaises(TypeError):
            start(False)

        # Make text look like a string.  This returns pos as the start
        # position, but it's set to None.

            

Reported by Pylint.

Unused variable 'parser'
Error

Line: 19 Column: 9

              
    def test_trans(self):
        # trans is the production instance of ParseMap, used in _study1
        parser = pyparse.Parser(4, 4)
        self.assertEqual('\t a([{b}])b"c\'d\n'.translate(pyparse.trans),
                         'xxx(((x)))x"x\'x\n')


class PyParseTest(unittest.TestCase):

            

Reported by Pylint.

Unused argument 'index'
Error

Line: 61 Column: 34

                      p = self.parser
        setcode = p.set_code
        start = p.find_good_parse_start
        def char_in_string_false(index): return False

        # First line starts with 'def' and ends with ':', then 0 is the pos.
        setcode('def spam():\n')
        eq(start(char_in_string_false), 0)


            

Reported by Pylint.

Access to a protected member _study1 of a client class
Error

Line: 149 Column: 17

                      eq = self.assertEqual
        p = self.parser
        setcode = p.set_code
        study = p._study1

        (NONE, BACKSLASH, FIRST, NEXT, BRACKET) = range(5)
        TestInfo = namedtuple('TestInfo', ['string', 'goodlines',
                                           'continuation'])
        tests = (

            

Reported by Pylint.

Access to a protected member _study2 of a client class
Error

Line: 220 Column: 17

                      eq = self.assertEqual
        p = self.parser
        setcode = p.set_code
        study = p._study2

        TestInfo = namedtuple('TestInfo', ['string', 'start', 'end', 'lastch',
                                           'openbracket', 'bracketing'])
        tests = (
            TestInfo('', 0, 0, '', None, ((0, 0),)),

            

Reported by Pylint.

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

Line: 4 Column: 1

              "Test pyparse, coverage 96%."

from idlelib import pyparse
import unittest
from collections import namedtuple


class ParseMapTest(unittest.TestCase):


            

Reported by Pylint.

standard import "from collections import namedtuple" should be placed before "from idlelib import pyparse"
Error

Line: 5 Column: 1

              
from idlelib import pyparse
import unittest
from collections import namedtuple


class ParseMapTest(unittest.TestCase):

    def test_parsemap(self):

            

Reported by Pylint.

Missing class docstring
Error

Line: 8 Column: 1

              from collections import namedtuple


class ParseMapTest(unittest.TestCase):

    def test_parsemap(self):
        keepwhite = {ord(c): ord(c) for c in ' \t\n\r'}
        mapping = pyparse.ParseMap(keepwhite)
        self.assertEqual(mapping[ord('\t')], ord('\t'))

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 5

              
class ParseMapTest(unittest.TestCase):

    def test_parsemap(self):
        keepwhite = {ord(c): ord(c) for c in ' \t\n\r'}
        mapping = pyparse.ParseMap(keepwhite)
        self.assertEqual(mapping[ord('\t')], ord('\t'))
        self.assertEqual(mapping[ord('a')], ord('x'))
        self.assertEqual(mapping[1000], ord('x'))

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 5

                      self.assertEqual(mapping[ord('a')], ord('x'))
        self.assertEqual(mapping[1000], ord('x'))

    def test_trans(self):
        # trans is the production instance of ParseMap, used in _study1
        parser = pyparse.Parser(4, 4)
        self.assertEqual('\t a([{b}])b"c\'d\n'.translate(pyparse.trans),
                         'xxx(((x)))x"x\'x\n')


            

Reported by Pylint.

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/test/test_robotparser.py
61 issues
Instance of 'BaseRobotTest' has no 'subTest' member
Error

Line: 33 Column: 18

                  def test_good_urls(self):
        for url in self.good:
            agent, url = self.get_agent_and_url(url)
            with self.subTest(url=url, agent=agent):
                self.assertTrue(self.parser.can_fetch(agent, url))

    def test_bad_urls(self):
        for url in self.bad:
            agent, url = self.get_agent_and_url(url)

            

Reported by Pylint.

Instance of 'BaseRobotTest' has no 'assertTrue' member
Error

Line: 34 Column: 17

                      for url in self.good:
            agent, url = self.get_agent_and_url(url)
            with self.subTest(url=url, agent=agent):
                self.assertTrue(self.parser.can_fetch(agent, url))

    def test_bad_urls(self):
        for url in self.bad:
            agent, url = self.get_agent_and_url(url)
            with self.subTest(url=url, agent=agent):

            

Reported by Pylint.

Instance of 'BaseRobotTest' has no 'subTest' member
Error

Line: 39 Column: 18

                  def test_bad_urls(self):
        for url in self.bad:
            agent, url = self.get_agent_and_url(url)
            with self.subTest(url=url, agent=agent):
                self.assertFalse(self.parser.can_fetch(agent, url))

    def test_site_maps(self):
        self.assertEqual(self.parser.site_maps(), self.site_maps)


            

Reported by Pylint.

Instance of 'BaseRobotTest' has no 'assertFalse' member
Error

Line: 40 Column: 17

                      for url in self.bad:
            agent, url = self.get_agent_and_url(url)
            with self.subTest(url=url, agent=agent):
                self.assertFalse(self.parser.can_fetch(agent, url))

    def test_site_maps(self):
        self.assertEqual(self.parser.site_maps(), self.site_maps)



            

Reported by Pylint.

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

Line: 43 Column: 9

                              self.assertFalse(self.parser.can_fetch(agent, url))

    def test_site_maps(self):
        self.assertEqual(self.parser.site_maps(), self.site_maps)


class UserAgentWildcardTest(BaseRobotTest, unittest.TestCase):
    robots_txt = """\
User-agent: *

            

Reported by Pylint.

Instance of 'BaseRequestRateTest' has no 'subTest' member
Error

Line: 109 Column: 18

                      parser = self.parser
        for url in self.good + self.bad:
            agent, url = self.get_agent_and_url(url)
            with self.subTest(url=url, agent=agent):
                self.assertEqual(parser.crawl_delay(agent), self.crawl_delay)

                parsed_request_rate = parser.request_rate(agent)
                self.assertEqual(parsed_request_rate, self.request_rate)
                if self.request_rate is not None:

            

Reported by Pylint.

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

Line: 110 Column: 17

                      for url in self.good + self.bad:
            agent, url = self.get_agent_and_url(url)
            with self.subTest(url=url, agent=agent):
                self.assertEqual(parser.crawl_delay(agent), self.crawl_delay)

                parsed_request_rate = parser.request_rate(agent)
                self.assertEqual(parsed_request_rate, self.request_rate)
                if self.request_rate is not None:
                    self.assertIsInstance(

            

Reported by Pylint.

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

Line: 113 Column: 17

                              self.assertEqual(parser.crawl_delay(agent), self.crawl_delay)

                parsed_request_rate = parser.request_rate(agent)
                self.assertEqual(parsed_request_rate, self.request_rate)
                if self.request_rate is not None:
                    self.assertIsInstance(
                        parsed_request_rate,
                        urllib.robotparser.RequestRate
                    )

            

Reported by Pylint.

Instance of 'BaseRequestRateTest' has no 'assertIsInstance' member
Error

Line: 115 Column: 21

                              parsed_request_rate = parser.request_rate(agent)
                self.assertEqual(parsed_request_rate, self.request_rate)
                if self.request_rate is not None:
                    self.assertIsInstance(
                        parsed_request_rate,
                        urllib.robotparser.RequestRate
                    )
                    self.assertEqual(
                        parsed_request_rate.requests,

            

Reported by Pylint.

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

Line: 119 Column: 21

                                      parsed_request_rate,
                        urllib.robotparser.RequestRate
                    )
                    self.assertEqual(
                        parsed_request_rate.requests,
                        self.request_rate.requests
                    )
                    self.assertEqual(
                        parsed_request_rate.seconds,

            

Reported by Pylint.