The following issues were found
Tools/c-analyzer/c_common/fsutil.py
28 issues
Line: 8
Column: 1
import shutil
import stat
from .iterutil import iter_many
USE_CWD = object()
Reported by Pylint.
Line: 159
Column: 3
def expand_filenames(filenames):
for filename in filenames:
# XXX Do we need to use glob.escape (a la commit 9355868458, GH-20994)?
if '**/' in filename:
yield from glob.glob(filename.replace('**/', ''))
yield from glob.glob(filename)
Reported by Pylint.
Line: 286
Column: 26
def iter_files_by_suffix(root, suffixes, relparent=None, *,
walk=walk_tree,
_iter_files=iter_files,
):
"""Yield each file in the tree that has the given suffixes.
Unlike iter_files(), the results are in the original suffix order.
Reported by Pylint.
Line: 295
Column: 3
"""
if isinstance(suffixes, str):
suffixes = [suffixes]
# XXX Ignore repeated suffixes?
for suffix in suffixes:
yield from _iter_files(root, suffix, relparent)
##################################
Reported by Pylint.
Line: 303
Column: 3
##################################
# file info
# XXX posix-only?
S_IRANY = stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH
S_IWANY = stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH
S_IXANY = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
Reported by Pylint.
Line: 1
Column: 1
import fnmatch
import glob
import os
import os.path
import shutil
import stat
from .iterutil import iter_many
Reported by Pylint.
Line: 17
Column: 1
C_SOURCE_SUFFIXES = ('.c', '.h')
def create_backup(old, backup=None):
if isinstance(old, str):
filename = old
else:
filename = getattr(old, 'name', None)
if not filename:
Reported by Pylint.
Line: 71
Column: 1
return filename
def fix_filenames(filenames, relroot=USE_CWD):
if not relroot or relroot is USE_CWD:
filenames = (os.path.abspath(v) for v in filenames)
else:
relroot = os.path.abspath(relroot)
filenames = (_fix_filename(v, relroot) for v in filenames)
Reported by Pylint.
Line: 89
Column: 5
orig = filename
if normalize:
filename = os.path.normpath(filename)
if relroot is None:
# Otherwise leave it as-is.
return filename
elif relroot is USE_CWD:
# Make it relative to CWD.
filename = os.path.relpath(filename)
Reported by Pylint.
Line: 110
Column: 1
##################################
# find files
def match_glob(filename, pattern):
if fnmatch.fnmatch(filename, pattern):
return True
# fnmatch doesn't handle ** quite right. It will not match the
# following:
Reported by Pylint.
Tools/demo/queens.py
27 issues
Line: 56
Column: 9
silent = 0 # If true, count solutions only
def display(self):
self.nfound = self.nfound + 1
if self.silent:
return
print('+-' + '--'*self.n + '+')
for y in range(self.n-1, -1, -1):
print('|', end=' ')
Reported by Pylint.
Line: 14
Column: 1
N = 8 # Default; command line overrides
class Queens:
def __init__(self, n=N):
self.n = n
self.reset()
Reported by Pylint.
Line: 17
Column: 9
class Queens:
def __init__(self, n=N):
self.n = n
self.reset()
def reset(self):
n = self.n
self.y = [None] * n # Where is the queen in column x
Reported by Pylint.
Line: 20
Column: 5
self.n = n
self.reset()
def reset(self):
n = self.n
self.y = [None] * n # Where is the queen in column x
self.row = [0] * n # Is row[y] safe?
self.up = [0] * (2*n-1) # Is upward diagonal[x-y] safe?
self.down = [0] * (2*n-1) # Is downward diagonal[x+y] safe?
Reported by Pylint.
Line: 21
Column: 9
self.reset()
def reset(self):
n = self.n
self.y = [None] * n # Where is the queen in column x
self.row = [0] * n # Is row[y] safe?
self.up = [0] * (2*n-1) # Is upward diagonal[x-y] safe?
self.down = [0] * (2*n-1) # Is downward diagonal[x+y] safe?
self.nfound = 0 # Instrumentation
Reported by Pylint.
Line: 22
Column: 9
def reset(self):
n = self.n
self.y = [None] * n # Where is the queen in column x
self.row = [0] * n # Is row[y] safe?
self.up = [0] * (2*n-1) # Is upward diagonal[x-y] safe?
self.down = [0] * (2*n-1) # Is downward diagonal[x+y] safe?
self.nfound = 0 # Instrumentation
Reported by Pylint.
Line: 24
Column: 9
n = self.n
self.y = [None] * n # Where is the queen in column x
self.row = [0] * n # Is row[y] safe?
self.up = [0] * (2*n-1) # Is upward diagonal[x-y] safe?
self.down = [0] * (2*n-1) # Is downward diagonal[x+y] safe?
self.nfound = 0 # Instrumentation
def solve(self, x=0): # Recursive solver
for y in range(self.n):
Reported by Pylint.
Line: 28
Column: 5
self.down = [0] * (2*n-1) # Is downward diagonal[x+y] safe?
self.nfound = 0 # Instrumentation
def solve(self, x=0): # Recursive solver
for y in range(self.n):
if self.safe(x, y):
self.place(x, y)
if x+1 == self.n:
self.display()
Reported by Pylint.
Line: 28
Column: 5
self.down = [0] * (2*n-1) # Is downward diagonal[x+y] safe?
self.nfound = 0 # Instrumentation
def solve(self, x=0): # Recursive solver
for y in range(self.n):
if self.safe(x, y):
self.place(x, y)
if x+1 == self.n:
self.display()
Reported by Pylint.
Line: 29
Column: 13
self.nfound = 0 # Instrumentation
def solve(self, x=0): # Recursive solver
for y in range(self.n):
if self.safe(x, y):
self.place(x, y)
if x+1 == self.n:
self.display()
else:
Reported by Pylint.
Lib/test/test_rlcompleter.py
27 issues
Line: 46
Column: 3
['CompleteMe()'])
self.assertEqual(self.completer.global_matches('eg'),
['egg('])
# XXX: see issue5256
self.assertEqual(self.completer.global_matches('CompleteM'),
['CompleteMe()'])
def test_attr_matches(self):
# test with builtins namespace
Reported by Pylint.
Line: 1
Column: 1
import unittest
from unittest.mock import patch
import builtins
import rlcompleter
class CompleteMe:
""" Trivial class used in testing rlcompleter.Completer. """
spam = 1
_ham = 2
Reported by Pylint.
Line: 6
Column: 1
import builtins
import rlcompleter
class CompleteMe:
""" Trivial class used in testing rlcompleter.Completer. """
spam = 1
_ham = 2
Reported by Pylint.
Line: 12
Column: 1
_ham = 2
class TestRlcompleter(unittest.TestCase):
def setUp(self):
self.stdcompleter = rlcompleter.Completer()
self.completer = rlcompleter.Completer(dict(spam=int,
egg=str,
CompleteMe=CompleteMe))
Reported by Pylint.
Line: 22
Column: 5
# forces stdcompleter to bind builtins namespace
self.stdcompleter.complete('', 0)
def test_namespace(self):
class A(dict):
pass
class B(list):
pass
Reported by Pylint.
Line: 23
Column: 9
self.stdcompleter.complete('', 0)
def test_namespace(self):
class A(dict):
pass
class B(list):
pass
self.assertTrue(self.stdcompleter.use_main_ns)
Reported by Pylint.
Line: 23
Column: 9
self.stdcompleter.complete('', 0)
def test_namespace(self):
class A(dict):
pass
class B(list):
pass
self.assertTrue(self.stdcompleter.use_main_ns)
Reported by Pylint.
Line: 25
Column: 9
def test_namespace(self):
class A(dict):
pass
class B(list):
pass
self.assertTrue(self.stdcompleter.use_main_ns)
self.assertFalse(self.completer.use_main_ns)
self.assertFalse(rlcompleter.Completer(A()).use_main_ns)
Reported by Pylint.
Line: 25
Column: 9
def test_namespace(self):
class A(dict):
pass
class B(list):
pass
self.assertTrue(self.stdcompleter.use_main_ns)
self.assertFalse(self.completer.use_main_ns)
self.assertFalse(rlcompleter.Completer(A()).use_main_ns)
Reported by Pylint.
Line: 33
Column: 5
self.assertFalse(rlcompleter.Completer(A()).use_main_ns)
self.assertRaises(TypeError, rlcompleter.Completer, B((1,)))
def test_global_matches(self):
# test with builtins namespace
self.assertEqual(sorted(self.stdcompleter.global_matches('di')),
[x+'(' for x in dir(builtins) if x.startswith('di')])
self.assertEqual(sorted(self.stdcompleter.global_matches('st')),
[x+'(' for x in dir(builtins) if x.startswith('st')])
Reported by Pylint.
Tools/c-analyzer/c_parser/preprocessor/__init__.py
27 issues
Line: 8
Column: 1
from c_common.fsutil import match_glob as _match_glob
from c_common.tables import parse_table as _parse_table
from ..source import (
resolve as _resolve_source,
good_file as _good_file,
)
from . import errors as _errors
from . import (
Reported by Pylint.
Line: 12
Column: 1
resolve as _resolve_source,
good_file as _good_file,
)
from . import errors as _errors
from . import (
pure as _pure,
gcc as _gcc,
)
Reported by Pylint.
Line: 13
Column: 1
good_file as _good_file,
)
from . import errors as _errors
from . import (
pure as _pure,
gcc as _gcc,
)
Reported by Pylint.
Line: 13
Column: 1
good_file as _good_file,
)
from . import errors as _errors
from . import (
pure as _pure,
gcc as _gcc,
)
Reported by Pylint.
Line: 183
Column: 1
##################################
# aliases
from .errors import (
PreprocessorError,
PreprocessorFailure,
ErrorDirectiveError,
MissingDependenciesError,
OSMismatchError,
Reported by Pylint.
Line: 190
Column: 1
MissingDependenciesError,
OSMismatchError,
)
from .common import FileInfo, SourceLine
Reported by Pylint.
Line: 12
Column: 1
resolve as _resolve_source,
good_file as _good_file,
)
from . import errors as _errors
from . import (
pure as _pure,
gcc as _gcc,
)
Reported by Pylint.
Line: 13
Column: 1
good_file as _good_file,
)
from . import errors as _errors
from . import (
pure as _pure,
gcc as _gcc,
)
Reported by Pylint.
Line: 13
Column: 1
good_file as _good_file,
)
from . import errors as _errors
from . import (
pure as _pure,
gcc as _gcc,
)
Reported by Pylint.
Line: 31
Column: 3
# * sequence of SourceLine
# * text (string)
# * something that combines all those
# XXX Add the missing support from above.
# XXX Add more low-level functions to handle permutations?
def preprocess(source, *,
incldirs=None,
macros=None,
Reported by Pylint.
Lib/multiprocessing/resource_tracker.py
27 issues
Line: 24
Column: 1
import threading
import warnings
from . import spawn
from . import util
__all__ = ['ensure_running', 'register', 'unregister']
_HAVE_SIGMASK = hasattr(signal, 'pthread_sigmask')
Reported by Pylint.
Line: 25
Column: 1
import warnings
from . import spawn
from . import util
__all__ = ['ensure_running', 'register', 'unregister']
_HAVE_SIGMASK = hasattr(signal, 'pthread_sigmask')
_IGNORED_SIGNALS = (signal.SIGINT, signal.SIGTERM)
Reported by Pylint.
Line: 110
Column: 20
fds_to_pass = []
try:
fds_to_pass.append(sys.stderr.fileno())
except Exception:
pass
cmd = 'from multiprocessing.resource_tracker import main;main(%d)'
r, w = os.pipe()
try:
fds_to_pass.append(r)
Reported by Pylint.
Line: 118
Column: 32
fds_to_pass.append(r)
# process will out live us, so no need to wait on pid
exe = spawn.get_executable()
args = [exe] + util._args_from_interpreter_flags()
args += ['-c', cmd % r]
# bpo-33613: Register a signal mask that will block the signals.
# This signal mask will be inherited by the child that is going
# to be spawned and will protect the child from a race condition
# that can make the child die before it registers signal handlers
Reported by Pylint.
Line: 190
Column: 16
for f in (sys.stdin, sys.stdout):
try:
f.close()
except Exception:
pass
cache = {rtype: set() for rtype in _CLEANUP_FUNCS.keys()}
try:
# keep track of registered/unregistered resources
Reported by Pylint.
Line: 214
Column: 24
pass
else:
raise RuntimeError('unrecognized command %r' % cmd)
except Exception:
try:
sys.excepthook(*sys.exc_info())
except:
pass
finally:
Reported by Pylint.
Line: 217
Column: 21
except Exception:
try:
sys.excepthook(*sys.exc_info())
except:
pass
finally:
# all processes have terminated; cleanup any remaining resources
for rtype, rtype_cache in cache.items():
if rtype_cache:
Reported by Pylint.
Line: 227
Column: 24
warnings.warn('resource_tracker: There appear to be %d '
'leaked %s objects to clean up at shutdown' %
(len(rtype_cache), rtype))
except Exception:
pass
for name in rtype_cache:
# For some reason the process which created and registered this
# resource has failed to unregister it. Presumably it has
# died. We therefore unlink it.
Reported by Pylint.
Line: 236
Column: 28
try:
try:
_CLEANUP_FUNCS[rtype](name)
except Exception as e:
warnings.warn('resource_tracker: %r: %s' % (name, e))
finally:
pass
Reported by Pylint.
Line: 1
Column: 1
###############################################################################
# Server process to keep track of unlinked resources (like shared memory
# segments, semaphores etc.) and clean them.
#
# On Unix we run a server process which keeps track of unlinked
# resources. The server ignores SIGINT and SIGTERM and reads from a
# pipe. Every other process of the program has a copy of the writable
# end of the pipe, so we get EOF when all other processes have exited.
# Then the server process unlinks any remaining resource names.
Reported by Pylint.
Lib/test/test_eof.py
27 issues
Line: 14
Column: 17
expect = "unterminated string literal (detected at line 1) (<string>, line 1)"
for quote in ("'", "\""):
try:
eval(f"""{quote}this is a test\
""")
except SyntaxError as msg:
self.assertEqual(str(msg), expect)
self.assertEqual(msg.offset, 1)
else:
Reported by Pylint.
Line: 14
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval
expect = "unterminated string literal (detected at line 1) (<string>, line 1)"
for quote in ("'", "\""):
try:
eval(f"""{quote}this is a test\
""")
except SyntaxError as msg:
self.assertEqual(str(msg), expect)
self.assertEqual(msg.offset, 1)
else:
Reported by Bandit.
Line: 25
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval
def test_EOFS(self):
expect = ("unterminated triple-quoted string literal (detected at line 1) (<string>, line 1)")
try:
eval("""'''this is a test""")
except SyntaxError as msg:
self.assertEqual(str(msg), expect)
self.assertEqual(msg.offset, 1)
else:
raise support.TestFailed
Reported by Bandit.
Line: 25
Column: 13
def test_EOFS(self):
expect = ("unterminated triple-quoted string literal (detected at line 1) (<string>, line 1)")
try:
eval("""'''this is a test""")
except SyntaxError as msg:
self.assertEqual(str(msg), expect)
self.assertEqual(msg.offset, 1)
else:
raise support.TestFailed
Reported by Pylint.
Line: 33
Column: 9
raise support.TestFailed
def test_EOFS_with_file(self):
expect = ("(<string>, line 1)")
with os_helper.temp_dir() as temp_dir:
file_name = script_helper.make_script(temp_dir, 'foo', """'''this is \na \ntest""")
rc, out, err = script_helper.assert_python_failure(file_name)
self.assertIn(b'unterminated triple-quoted string literal (detected at line 3)', err)
Reported by Pylint.
Line: 36
Column: 17
expect = ("(<string>, line 1)")
with os_helper.temp_dir() as temp_dir:
file_name = script_helper.make_script(temp_dir, 'foo', """'''this is \na \ntest""")
rc, out, err = script_helper.assert_python_failure(file_name)
self.assertIn(b'unterminated triple-quoted string literal (detected at line 3)', err)
def test_eof_with_line_continuation(self):
expect = "unexpected EOF while parsing (<string>, line 1)"
try:
Reported by Pylint.
Line: 36
Column: 13
expect = ("(<string>, line 1)")
with os_helper.temp_dir() as temp_dir:
file_name = script_helper.make_script(temp_dir, 'foo', """'''this is \na \ntest""")
rc, out, err = script_helper.assert_python_failure(file_name)
self.assertIn(b'unterminated triple-quoted string literal (detected at line 3)', err)
def test_eof_with_line_continuation(self):
expect = "unexpected EOF while parsing (<string>, line 1)"
try:
Reported by Pylint.
Line: 52
Column: 13
"""A continuation at the end of input must be an error; bpo2180."""
expect = 'unexpected EOF while parsing (<string>, line 1)'
with self.assertRaises(SyntaxError) as excinfo:
exec('x = 5\\')
self.assertEqual(str(excinfo.exception), expect)
with self.assertRaises(SyntaxError) as excinfo:
exec('\\')
self.assertEqual(str(excinfo.exception), expect)
Reported by Pylint.
Line: 52
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html
"""A continuation at the end of input must be an error; bpo2180."""
expect = 'unexpected EOF while parsing (<string>, line 1)'
with self.assertRaises(SyntaxError) as excinfo:
exec('x = 5\\')
self.assertEqual(str(excinfo.exception), expect)
with self.assertRaises(SyntaxError) as excinfo:
exec('\\')
self.assertEqual(str(excinfo.exception), expect)
Reported by Bandit.
Line: 55
Column: 13
exec('x = 5\\')
self.assertEqual(str(excinfo.exception), expect)
with self.assertRaises(SyntaxError) as excinfo:
exec('\\')
self.assertEqual(str(excinfo.exception), expect)
@unittest.skipIf(not sys.executable, "sys.executable required")
def test_line_continuation_EOF_from_file_bpo2180(self):
"""Ensure tok_nextc() does not add too many ending newlines."""
Reported by Pylint.
Lib/multiprocessing/popen_forkserver.py
27 issues
Line: 4
Column: 1
import io
import os
from .context import reduction, set_spawning_popen
if not reduction.HAVE_SEND_HANDLE:
raise ImportError('No support for sending fds between processes')
from . import forkserver
from . import popen_fork
from . import spawn
Reported by Pylint.
Line: 7
Column: 1
from .context import reduction, set_spawning_popen
if not reduction.HAVE_SEND_HANDLE:
raise ImportError('No support for sending fds between processes')
from . import forkserver
from . import popen_fork
from . import spawn
from . import util
Reported by Pylint.
Line: 8
Column: 1
if not reduction.HAVE_SEND_HANDLE:
raise ImportError('No support for sending fds between processes')
from . import forkserver
from . import popen_fork
from . import spawn
from . import util
__all__ = ['Popen']
Reported by Pylint.
Line: 9
Column: 1
raise ImportError('No support for sending fds between processes')
from . import forkserver
from . import popen_fork
from . import spawn
from . import util
__all__ = ['Popen']
Reported by Pylint.
Line: 10
Column: 1
from . import forkserver
from . import popen_fork
from . import spawn
from . import util
__all__ = ['Popen']
#
Reported by Pylint.
Line: 62
Column: 12
self.pid = forkserver.read_signed(self.sentinel)
def poll(self, flag=os.WNOHANG):
if self.returncode is None:
from multiprocessing.connection import wait
timeout = 0 if flag == os.WNOHANG else None
if not wait([self.sentinel], timeout):
return None
try:
Reported by Pylint.
Line: 42
Column: 48
return len(self._fds) - 1
def _launch(self, process_obj):
prep_data = spawn.get_preparation_data(process_obj._name)
buf = io.BytesIO()
set_spawning_popen(self)
try:
reduction.dump(prep_data, buf)
reduction.dump(process_obj, buf)
Reported by Pylint.
Line: 51
Column: 9
finally:
set_spawning_popen(None)
self.sentinel, w = forkserver.connect_to_new_process(self._fds)
# Keep a duplicate of the data pipe's write end as a sentinel of the
# parent process used by the child process.
_parent_w = os.dup(w)
self.finalizer = util.Finalize(self, util.close_fds,
(_parent_w, self.sentinel))
Reported by Pylint.
Line: 55
Column: 9
# Keep a duplicate of the data pipe's write end as a sentinel of the
# parent process used by the child process.
_parent_w = os.dup(w)
self.finalizer = util.Finalize(self, util.close_fds,
(_parent_w, self.sentinel))
with open(w, 'wb', closefd=True) as f:
f.write(buf.getbuffer())
self.pid = forkserver.read_signed(self.sentinel)
Reported by Pylint.
Line: 59
Column: 9
(_parent_w, self.sentinel))
with open(w, 'wb', closefd=True) as f:
f.write(buf.getbuffer())
self.pid = forkserver.read_signed(self.sentinel)
def poll(self, flag=os.WNOHANG):
if self.returncode is None:
from multiprocessing.connection import wait
timeout = 0 if flag == os.WNOHANG else None
Reported by Pylint.
Lib/test/test_json/test_separators.py
27 issues
Line: 32
Column: 14
]""")
d1 = self.dumps(h)
d2 = self.dumps(h, indent=2, sort_keys=True, separators=(' ,', ' : '))
h1 = self.loads(d1)
h2 = self.loads(d2)
Reported by Pylint.
Line: 33
Column: 14
d1 = self.dumps(h)
d2 = self.dumps(h, indent=2, sort_keys=True, separators=(' ,', ' : '))
h1 = self.loads(d1)
h2 = self.loads(d2)
self.assertEqual(h1, h)
Reported by Pylint.
Line: 35
Column: 14
d1 = self.dumps(h)
d2 = self.dumps(h, indent=2, sort_keys=True, separators=(' ,', ' : '))
h1 = self.loads(d1)
h2 = self.loads(d2)
self.assertEqual(h1, h)
self.assertEqual(h2, h)
self.assertEqual(d2, expect)
Reported by Pylint.
Line: 36
Column: 14
d2 = self.dumps(h, indent=2, sort_keys=True, separators=(' ,', ' : '))
h1 = self.loads(d1)
h2 = self.loads(d2)
self.assertEqual(h1, h)
self.assertEqual(h2, h)
self.assertEqual(d2, expect)
Reported by Pylint.
Line: 38
Column: 9
h1 = self.loads(d1)
h2 = self.loads(d2)
self.assertEqual(h1, h)
self.assertEqual(h2, h)
self.assertEqual(d2, expect)
def test_illegal_separators(self):
h = {1: 2, 3: 4}
Reported by Pylint.
Line: 39
Column: 9
h2 = self.loads(d2)
self.assertEqual(h1, h)
self.assertEqual(h2, h)
self.assertEqual(d2, expect)
def test_illegal_separators(self):
h = {1: 2, 3: 4}
self.assertRaises(TypeError, self.dumps, h, separators=(b', ', ': '))
Reported by Pylint.
Line: 40
Column: 9
self.assertEqual(h1, h)
self.assertEqual(h2, h)
self.assertEqual(d2, expect)
def test_illegal_separators(self):
h = {1: 2, 3: 4}
self.assertRaises(TypeError, self.dumps, h, separators=(b', ', ': '))
self.assertRaises(TypeError, self.dumps, h, separators=(', ', b': '))
Reported by Pylint.
Line: 44
Column: 9
def test_illegal_separators(self):
h = {1: 2, 3: 4}
self.assertRaises(TypeError, self.dumps, h, separators=(b', ', ': '))
self.assertRaises(TypeError, self.dumps, h, separators=(', ', b': '))
self.assertRaises(TypeError, self.dumps, h, separators=(b', ', b': '))
class TestPySeparators(TestSeparators, PyTest): pass
Reported by Pylint.
Line: 44
Column: 38
def test_illegal_separators(self):
h = {1: 2, 3: 4}
self.assertRaises(TypeError, self.dumps, h, separators=(b', ', ': '))
self.assertRaises(TypeError, self.dumps, h, separators=(', ', b': '))
self.assertRaises(TypeError, self.dumps, h, separators=(b', ', b': '))
class TestPySeparators(TestSeparators, PyTest): pass
Reported by Pylint.
Line: 45
Column: 9
def test_illegal_separators(self):
h = {1: 2, 3: 4}
self.assertRaises(TypeError, self.dumps, h, separators=(b', ', ': '))
self.assertRaises(TypeError, self.dumps, h, separators=(', ', b': '))
self.assertRaises(TypeError, self.dumps, h, separators=(b', ', b': '))
class TestPySeparators(TestSeparators, PyTest): pass
class TestCSeparators(TestSeparators, CTest): pass
Reported by Pylint.
Lib/test/test_audit.py
27 issues
Line: 33
Column: 9
self.fail("".join(p.stderr))
def run_python(self, *args):
events = []
with subprocess.Popen(
[sys.executable, "-X utf8", AUDIT_TESTS_PY, *args],
encoding="utf-8",
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
Reported by Pylint.
Line: 4
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess
"""Tests for sys.audit and sys.addaudithook
"""
import subprocess
import sys
import unittest
from test import support
from test.support import import_helper
from test.support import os_helper
Reported by Bandit.
Line: 18
Column: 1
AUDIT_TESTS_PY = support.findfile("audit-tests.py")
class AuditTest(unittest.TestCase):
def do_test(self, *args):
with subprocess.Popen(
[sys.executable, "-X utf8", AUDIT_TESTS_PY, *args],
encoding="utf-8",
stdout=subprocess.PIPE,
Reported by Pylint.
Line: 19
Column: 5
class AuditTest(unittest.TestCase):
def do_test(self, *args):
with subprocess.Popen(
[sys.executable, "-X utf8", AUDIT_TESTS_PY, *args],
encoding="utf-8",
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
Reported by Pylint.
Line: 20
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html
class AuditTest(unittest.TestCase):
def do_test(self, *args):
with subprocess.Popen(
[sys.executable, "-X utf8", AUDIT_TESTS_PY, *args],
encoding="utf-8",
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
) as p:
Reported by Bandit.
Line: 25
Column: 14
encoding="utf-8",
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
) as p:
p.wait()
sys.stdout.writelines(p.stdout)
sys.stderr.writelines(p.stderr)
if p.returncode:
self.fail("".join(p.stderr))
Reported by Pylint.
Line: 32
Column: 5
if p.returncode:
self.fail("".join(p.stderr))
def run_python(self, *args):
events = []
with subprocess.Popen(
[sys.executable, "-X utf8", AUDIT_TESTS_PY, *args],
encoding="utf-8",
stdout=subprocess.PIPE,
Reported by Pylint.
Line: 32
Column: 5
if p.returncode:
self.fail("".join(p.stderr))
def run_python(self, *args):
events = []
with subprocess.Popen(
[sys.executable, "-X utf8", AUDIT_TESTS_PY, *args],
encoding="utf-8",
stdout=subprocess.PIPE,
Reported by Pylint.
Line: 34
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html
def run_python(self, *args):
events = []
with subprocess.Popen(
[sys.executable, "-X utf8", AUDIT_TESTS_PY, *args],
encoding="utf-8",
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
) as p:
Reported by Bandit.
Line: 39
Column: 14
encoding="utf-8",
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
) as p:
p.wait()
sys.stderr.writelines(p.stderr)
return (
p.returncode,
[line.strip().partition(" ") for line in p.stdout],
Reported by Pylint.
Lib/idlelib/sidebar.py
27 issues
Line: 35
Column: 3
def get_widget_padding(widget):
"""Get the total padding of a Tk widget, including its border."""
# TODO: use also in codecontext.py
manager = widget.winfo_manager()
if manager == 'pack':
info = widget.pack_info()
elif manager == 'grid':
info = widget.grid_info()
Reported by Pylint.
Line: 122
Column: 38
self.editwin.vbar.set(*args)
return self.yscroll_event(*args, **kwargs)
def redirect_focusin_event(self, event):
"""Redirect focus-in events to the main editor text widget."""
self.text.focus_set()
return 'break'
def redirect_mousebutton_event(self, event, event_name):
Reported by Pylint.
Line: 257
Column: 30
self.main_widget.after(0, text_auto_scroll)
self.main_widget.bind('<B1-Leave>', b1_leave_handler)
def b1_enter_handler(event):
# Cancel the scheduling of text_auto_scroll(), if it exists.
nonlocal auto_scrolling_after_id
if auto_scrolling_after_id is not None:
self.main_widget.after_cancel(auto_scrolling_after_id)
auto_scrolling_after_id = None
Reported by Pylint.
Line: 353
Column: 42
[''],
map(str, range(self.prev_end + 1, end + 1)),
))
self.sidebar_text.insert(f'end -1c', new_text, 'linenumber')
else:
self.sidebar_text.delete(f'{end+1}.0 -1c', 'end -1c')
self.prev_end = end
Reported by Pylint.
Line: 357
Column: 9
else:
self.sidebar_text.delete(f'{end+1}.0 -1c', 'end -1c')
self.prev_end = end
def yscroll_event(self, *args, **kwargs):
self.sidebar_text.yview_moveto(args[0])
return 'break'
Reported by Pylint.
Line: 60
Column: 1
@contextlib.contextmanager
def temp_enable_text_widget(text):
text.configure(state=tk.NORMAL)
try:
yield
finally:
text.configure(state=tk.DISABLED)
Reported by Pylint.
Line: 100
Column: 5
"""Layout the widget, always using grid layout."""
raise NotImplementedError
def show_sidebar(self):
if not self.is_shown:
self.grid()
self.is_shown = True
def hide_sidebar(self):
Reported by Pylint.
Line: 105
Column: 5
self.grid()
self.is_shown = True
def hide_sidebar(self):
if self.is_shown:
self.main_widget.grid_forget()
self.is_shown = False
def yscroll_event(self, *args, **kwargs):
Reported by Pylint.
Line: 139
Column: 5
x=0, y=event.y, delta=event.delta)
return 'break'
def bind_events(self):
self.text['yscrollcommand'] = self.redirect_yscroll_event
# Ensure focus is always redirected to the main editor text widget.
self.main_widget.bind('<FocusIn>', self.redirect_focusin_event)
Reported by Pylint.
Line: 139
Column: 5
x=0, y=event.y, delta=event.delta)
return 'break'
def bind_events(self):
self.text['yscrollcommand'] = self.redirect_yscroll_event
# Ensure focus is always redirected to the main editor text widget.
self.main_widget.bind('<FocusIn>', self.redirect_focusin_event)
Reported by Pylint.