The following issues were found
Tools/scripts/ndiff.py
17 issues
Line: 84
Column: 10
# crack args (sys.argv[1:] is normal) & compare;
# return false iff a problem
def main(args):
import getopt
try:
opts, args = getopt.getopt(args, "qr:")
except getopt.error as detail:
return fail(str(detail))
Reported by Pylint.
Line: 51
Column: 1
__version__ = 1, 7, 0
import difflib, sys
def fail(msg):
out = sys.stderr.write
out(msg + "\n\n")
out(__doc__)
Reported by Pylint.
Line: 53
Column: 1
import difflib, sys
def fail(msg):
out = sys.stderr.write
out(msg + "\n\n")
out(__doc__)
return 0
Reported by Pylint.
Line: 61
Column: 1
# open a file & return the file object; gripe and return 0 if it
# couldn't be opened
def fopen(fname):
try:
return open(fname)
except IOError as detail:
return fail("couldn't open " + fname + ": " + str(detail))
Reported by Pylint.
Line: 68
Column: 1
return fail("couldn't open " + fname + ": " + str(detail))
# open two files & spray the diff to stdout; return false iff a problem
def fcompare(f1name, f2name):
f1 = fopen(f1name)
f2 = fopen(f2name)
if not f1 or not f2:
return 0
Reported by Pylint.
Line: 69
Column: 5
# open two files & spray the diff to stdout; return false iff a problem
def fcompare(f1name, f2name):
f1 = fopen(f1name)
f2 = fopen(f2name)
if not f1 or not f2:
return 0
a = f1.readlines(); f1.close()
Reported by Pylint.
Line: 70
Column: 5
# open two files & spray the diff to stdout; return false iff a problem
def fcompare(f1name, f2name):
f1 = fopen(f1name)
f2 = fopen(f2name)
if not f1 or not f2:
return 0
a = f1.readlines(); f1.close()
b = f2.readlines(); f2.close()
Reported by Pylint.
Line: 74
Column: 5
if not f1 or not f2:
return 0
a = f1.readlines(); f1.close()
b = f2.readlines(); f2.close()
for line in difflib.ndiff(a, b):
print(line, end=' ')
return 1
Reported by Pylint.
Line: 74
Column: 25
if not f1 or not f2:
return 0
a = f1.readlines(); f1.close()
b = f2.readlines(); f2.close()
for line in difflib.ndiff(a, b):
print(line, end=' ')
return 1
Reported by Pylint.
Line: 75
Column: 5
return 0
a = f1.readlines(); f1.close()
b = f2.readlines(); f2.close()
for line in difflib.ndiff(a, b):
print(line, end=' ')
return 1
Reported by Pylint.
Lib/rlcompleter.py
17 issues
Line: 90
Column: 17
if state == 0:
if "." in text:
self.matches = self.attr_matches(text)
else:
self.matches = self.global_matches(text)
try:
return self.matches[state]
except IndexError:
Reported by Pylint.
Line: 92
Column: 17
if "." in text:
self.matches = self.attr_matches(text)
else:
self.matches = self.global_matches(text)
try:
return self.matches[state]
except IndexError:
return None
Reported by Pylint.
Line: 155
Column: 26
return []
expr, attr = m.group(1, 3)
try:
thisobject = eval(expr, self.namespace)
except Exception:
return []
# get the content of the object, except __builtins__
words = set(dir(thisobject))
Reported by Pylint.
Line: 155
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval
return []
expr, attr = m.group(1, 3)
try:
thisobject = eval(expr, self.namespace)
except Exception:
return []
# get the content of the object, except __builtins__
words = set(dir(thisobject))
Reported by Bandit.
Line: 156
Column: 16
expr, attr = m.group(1, 3)
try:
thisobject = eval(expr, self.namespace)
except Exception:
return []
# get the content of the object, except __builtins__
words = set(dir(thisobject))
words.discard("__builtins__")
Reported by Pylint.
Line: 39
Column: 1
__all__ = ["Completer"]
class Completer:
def __init__(self, namespace = None):
"""Create a new completer for the command line.
Completer([namespace]) -> completer instance.
Reported by Pylint.
Line: 79
Column: 17
if not text.strip():
if state == 0:
if _readline_available:
readline.insert_text('\t')
readline.redisplay()
return ''
else:
return '\t'
Reported by Pylint.
Line: 98
Column: 5
except IndexError:
return None
def _callable_postfix(self, val, word):
if callable(val):
word += "("
try:
if not inspect.signature(val).parameters:
word += ")"
Reported by Pylint.
Line: 116
Column: 9
defined in self.namespace that match.
"""
import keyword
matches = []
seen = {"__builtins__"}
n = len(text)
for word in keyword.kwlist:
if word[:n] == text:
Reported by Pylint.
Line: 119
Column: 9
import keyword
matches = []
seen = {"__builtins__"}
n = len(text)
for word in keyword.kwlist:
if word[:n] == text:
seen.add(word)
if word in {'finally', 'try'}:
word = word + ':'
Reported by Pylint.
Lib/test/test_grp.py
17 issues
Line: 60
Column: 23
# try to get some errors
bynames = {}
bygids = {}
for (n, p, g, mem) in grp.getgrall():
if not n or n == '+':
continue # skip NIS entries etc.
bynames[n] = g
bygids[g] = n
Reported by Pylint.
Line: 60
Column: 17
# try to get some errors
bynames = {}
bygids = {}
for (n, p, g, mem) in grp.getgrall():
if not n or n == '+':
continue # skip NIS entries etc.
bynames[n] = g
bygids[g] = n
Reported by Pylint.
Line: 9
Column: 1
grp = import_helper.import_module('grp')
class GroupDatabaseTestCase(unittest.TestCase):
def check_value(self, value):
# check that a grp tuple has the entries and
# attributes promised by the docs
self.assertEqual(len(value), 4)
Reported by Pylint.
Line: 11
Column: 5
class GroupDatabaseTestCase(unittest.TestCase):
def check_value(self, value):
# check that a grp tuple has the entries and
# attributes promised by the docs
self.assertEqual(len(value), 4)
self.assertEqual(value[0], value.gr_name)
self.assertIsInstance(value.gr_name, str)
Reported by Pylint.
Line: 24
Column: 5
self.assertEqual(value[3], value.gr_mem)
self.assertIsInstance(value.gr_mem, list)
def test_values(self):
entries = grp.getgrall()
for e in entries:
self.check_value(e)
Reported by Pylint.
Line: 27
Column: 13
def test_values(self):
entries = grp.getgrall()
for e in entries:
self.check_value(e)
def test_values_extended(self):
entries = grp.getgrall()
if len(entries) > 1000: # Huge group file (NIS?) -- skip the rest
Reported by Pylint.
Line: 30
Column: 5
for e in entries:
self.check_value(e)
def test_values_extended(self):
entries = grp.getgrall()
if len(entries) > 1000: # Huge group file (NIS?) -- skip the rest
self.skipTest('huge group file, extended test skipped')
for e in entries:
Reported by Pylint.
Line: 35
Column: 13
if len(entries) > 1000: # Huge group file (NIS?) -- skip the rest
self.skipTest('huge group file, extended test skipped')
for e in entries:
e2 = grp.getgrgid(e.gr_gid)
self.check_value(e2)
self.assertEqual(e2.gr_gid, e.gr_gid)
name = e.gr_name
if name.startswith('+') or name.startswith('-'):
Reported by Pylint.
Line: 36
Column: 13
self.skipTest('huge group file, extended test skipped')
for e in entries:
e2 = grp.getgrgid(e.gr_gid)
self.check_value(e2)
self.assertEqual(e2.gr_gid, e.gr_gid)
name = e.gr_name
if name.startswith('+') or name.startswith('-'):
# NIS-related entry
Reported by Pylint.
Line: 43
Column: 13
if name.startswith('+') or name.startswith('-'):
# NIS-related entry
continue
e2 = grp.getgrnam(name)
self.check_value(e2)
# There are instances where getgrall() returns group names in
# lowercase while getgrgid() returns proper casing.
# Discovered on Ubuntu 5.04 (custom).
self.assertEqual(e2.gr_name.lower(), name.lower())
Reported by Pylint.
Lib/test/test_importlib/builtin/test_finder.py
17 issues
Line: 1
Column: 1
from .. import abc
from .. import util
machinery = util.import_importlib('importlib.machinery')
import sys
import unittest
import warnings
Reported by Pylint.
Line: 2
Column: 1
from .. import abc
from .. import util
machinery = util.import_importlib('importlib.machinery')
import sys
import unittest
import warnings
Reported by Pylint.
Line: 1
Column: 1
from .. import abc
from .. import util
machinery = util.import_importlib('importlib.machinery')
import sys
import unittest
import warnings
Reported by Pylint.
Line: 6
Column: 1
machinery = util.import_importlib('importlib.machinery')
import sys
import unittest
import warnings
@unittest.skipIf(util.BUILTINS.good_name is None, 'no reasonable builtin module')
Reported by Pylint.
Line: 6
Column: 1
machinery = util.import_importlib('importlib.machinery')
import sys
import unittest
import warnings
@unittest.skipIf(util.BUILTINS.good_name is None, 'no reasonable builtin module')
Reported by Pylint.
Line: 7
Column: 1
machinery = util.import_importlib('importlib.machinery')
import sys
import unittest
import warnings
@unittest.skipIf(util.BUILTINS.good_name is None, 'no reasonable builtin module')
class FindSpecTests(abc.FinderTests):
Reported by Pylint.
Line: 7
Column: 1
machinery = util.import_importlib('importlib.machinery')
import sys
import unittest
import warnings
@unittest.skipIf(util.BUILTINS.good_name is None, 'no reasonable builtin module')
class FindSpecTests(abc.FinderTests):
Reported by Pylint.
Line: 8
Column: 1
import sys
import unittest
import warnings
@unittest.skipIf(util.BUILTINS.good_name is None, 'no reasonable builtin module')
class FindSpecTests(abc.FinderTests):
Reported by Pylint.
Line: 8
Column: 1
import sys
import unittest
import warnings
@unittest.skipIf(util.BUILTINS.good_name is None, 'no reasonable builtin module')
class FindSpecTests(abc.FinderTests):
Reported by Pylint.
Line: 16
Column: 5
"""Test find_spec() for built-in modules."""
def test_module(self):
# Common case.
with util.uncache(util.BUILTINS.good_name):
found = self.machinery.BuiltinImporter.find_spec(util.BUILTINS.good_name)
self.assertTrue(found)
self.assertEqual(found.origin, 'built-in')
Reported by Pylint.
Lib/symtable.py
17 issues
Line: 4
Column: 1
"""Interface to the compiler's internal symbol tables"""
import _symtable
from _symtable import (USE, DEF_GLOBAL, DEF_NONLOCAL, DEF_LOCAL, DEF_PARAM,
DEF_IMPORT, DEF_BOUND, DEF_ANNOT, SCOPE_OFF, SCOPE_MASK, FREE,
LOCAL, GLOBAL_IMPLICIT, GLOBAL_EXPLICIT, CELL)
import weakref
Reported by Pylint.
Line: 4
Column: 1
"""Interface to the compiler's internal symbol tables"""
import _symtable
from _symtable import (USE, DEF_GLOBAL, DEF_NONLOCAL, DEF_LOCAL, DEF_PARAM,
DEF_IMPORT, DEF_BOUND, DEF_ANNOT, SCOPE_OFF, SCOPE_MASK, FREE,
LOCAL, GLOBAL_IMPLICIT, GLOBAL_EXPLICIT, CELL)
import weakref
Reported by Pylint.
Line: 8
Column: 1
DEF_IMPORT, DEF_BOUND, DEF_ANNOT, SCOPE_OFF, SCOPE_MASK, FREE,
LOCAL, GLOBAL_IMPLICIT, GLOBAL_EXPLICIT, CELL)
import weakref
__all__ = ["symtable", "SymbolTable", "Class", "Function", "Symbol"]
def symtable(code, filename, compile_type):
""" Return the toplevel *SymbolTable* for the source code.
Reported by Pylint.
Line: 21
Column: 1
top = _symtable.symtable(code, filename, compile_type)
return _newSymbolTable(top, filename)
class SymbolTableFactory:
def __init__(self):
self.__memo = weakref.WeakValueDictionary()
def new(self, table, filename):
if table.type == _symtable.TYPE_FUNCTION:
Reported by Pylint.
Line: 25
Column: 5
def __init__(self):
self.__memo = weakref.WeakValueDictionary()
def new(self, table, filename):
if table.type == _symtable.TYPE_FUNCTION:
return Function(table, filename)
if table.type == _symtable.TYPE_CLASS:
return Class(table, filename)
return SymbolTable(table, filename)
Reported by Pylint.
Line: 25
Column: 5
def __init__(self):
self.__memo = weakref.WeakValueDictionary()
def new(self, table, filename):
if table.type == _symtable.TYPE_FUNCTION:
return Function(table, filename)
if table.type == _symtable.TYPE_CLASS:
return Class(table, filename)
return SymbolTable(table, filename)
Reported by Pylint.
Line: 42
Column: 1
_newSymbolTable = SymbolTableFactory()
class SymbolTable:
def __init__(self, raw_table, filename):
self._table = raw_table
self._filename = filename
self._symbols = {}
Reported by Pylint.
Line: 55
Column: 9
else:
kind = "%s " % self.__class__.__name__
if self._table.name == "top":
return "<{0}SymbolTable for module {1}>".format(kind, self._filename)
else:
return "<{0}SymbolTable for {1} in {2}>".format(kind,
self._table.name,
self._filename)
Reported by Pylint.
Line: 62
Column: 5
self._table.name,
self._filename)
def get_type(self):
"""Return the type of the symbol table.
The values returned are 'class', 'module' and
'function'.
"""
Reported by Pylint.
Line: 74
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
return "function"
if self._table.type == _symtable.TYPE_CLASS:
return "class"
assert self._table.type in (1, 2, 3), \
"unexpected type: {0}".format(self._table.type)
def get_id(self):
"""Return an identifier for the table.
"""
Reported by Bandit.
Lib/test/test_asyncio/test_protocols.py
17 issues
Line: 1
Column: 1
import unittest
from unittest import mock
import asyncio
class ProtocolsAbsTests(unittest.TestCase):
def test_base_protocol(self):
Reported by Pylint.
Line: 7
Column: 1
import asyncio
class ProtocolsAbsTests(unittest.TestCase):
def test_base_protocol(self):
f = mock.Mock()
p = asyncio.BaseProtocol()
self.assertIsNone(p.connection_made(f))
Reported by Pylint.
Line: 9
Column: 5
class ProtocolsAbsTests(unittest.TestCase):
def test_base_protocol(self):
f = mock.Mock()
p = asyncio.BaseProtocol()
self.assertIsNone(p.connection_made(f))
self.assertIsNone(p.connection_lost(f))
self.assertIsNone(p.pause_writing())
Reported by Pylint.
Line: 10
Column: 9
class ProtocolsAbsTests(unittest.TestCase):
def test_base_protocol(self):
f = mock.Mock()
p = asyncio.BaseProtocol()
self.assertIsNone(p.connection_made(f))
self.assertIsNone(p.connection_lost(f))
self.assertIsNone(p.pause_writing())
self.assertIsNone(p.resume_writing())
Reported by Pylint.
Line: 11
Column: 9
def test_base_protocol(self):
f = mock.Mock()
p = asyncio.BaseProtocol()
self.assertIsNone(p.connection_made(f))
self.assertIsNone(p.connection_lost(f))
self.assertIsNone(p.pause_writing())
self.assertIsNone(p.resume_writing())
self.assertFalse(hasattr(p, '__dict__'))
Reported by Pylint.
Line: 18
Column: 5
self.assertIsNone(p.resume_writing())
self.assertFalse(hasattr(p, '__dict__'))
def test_protocol(self):
f = mock.Mock()
p = asyncio.Protocol()
self.assertIsNone(p.connection_made(f))
self.assertIsNone(p.connection_lost(f))
self.assertIsNone(p.data_received(f))
Reported by Pylint.
Line: 19
Column: 9
self.assertFalse(hasattr(p, '__dict__'))
def test_protocol(self):
f = mock.Mock()
p = asyncio.Protocol()
self.assertIsNone(p.connection_made(f))
self.assertIsNone(p.connection_lost(f))
self.assertIsNone(p.data_received(f))
self.assertIsNone(p.eof_received())
Reported by Pylint.
Line: 20
Column: 9
def test_protocol(self):
f = mock.Mock()
p = asyncio.Protocol()
self.assertIsNone(p.connection_made(f))
self.assertIsNone(p.connection_lost(f))
self.assertIsNone(p.data_received(f))
self.assertIsNone(p.eof_received())
self.assertIsNone(p.pause_writing())
Reported by Pylint.
Line: 29
Column: 5
self.assertIsNone(p.resume_writing())
self.assertFalse(hasattr(p, '__dict__'))
def test_buffered_protocol(self):
f = mock.Mock()
p = asyncio.BufferedProtocol()
self.assertIsNone(p.connection_made(f))
self.assertIsNone(p.connection_lost(f))
self.assertIsNone(p.get_buffer(100))
Reported by Pylint.
Line: 30
Column: 9
self.assertFalse(hasattr(p, '__dict__'))
def test_buffered_protocol(self):
f = mock.Mock()
p = asyncio.BufferedProtocol()
self.assertIsNone(p.connection_made(f))
self.assertIsNone(p.connection_lost(f))
self.assertIsNone(p.get_buffer(100))
self.assertIsNone(p.buffer_updated(150))
Reported by Pylint.
Lib/test/test_importlib/frozen/test_finder.py
17 issues
Line: 1
Column: 1
from .. import abc
from .. import util
machinery = util.import_importlib('importlib.machinery')
import unittest
import warnings
Reported by Pylint.
Line: 2
Column: 1
from .. import abc
from .. import util
machinery = util.import_importlib('importlib.machinery')
import unittest
import warnings
Reported by Pylint.
Line: 1
Column: 1
from .. import abc
from .. import util
machinery = util.import_importlib('importlib.machinery')
import unittest
import warnings
Reported by Pylint.
Line: 6
Column: 1
machinery = util.import_importlib('importlib.machinery')
import unittest
import warnings
class FindSpecTests(abc.FinderTests):
Reported by Pylint.
Line: 6
Column: 1
machinery = util.import_importlib('importlib.machinery')
import unittest
import warnings
class FindSpecTests(abc.FinderTests):
Reported by Pylint.
Line: 7
Column: 1
machinery = util.import_importlib('importlib.machinery')
import unittest
import warnings
class FindSpecTests(abc.FinderTests):
"""Test finding frozen modules."""
Reported by Pylint.
Line: 7
Column: 1
machinery = util.import_importlib('importlib.machinery')
import unittest
import warnings
class FindSpecTests(abc.FinderTests):
"""Test finding frozen modules."""
Reported by Pylint.
Line: 14
Column: 5
"""Test finding frozen modules."""
def find(self, name, path=None):
finder = self.machinery.FrozenImporter
return finder.find_spec(name, path)
def test_module(self):
name = '__hello__'
Reported by Pylint.
Line: 18
Column: 5
finder = self.machinery.FrozenImporter
return finder.find_spec(name, path)
def test_module(self):
name = '__hello__'
spec = self.find(name)
self.assertEqual(spec.origin, 'frozen')
def test_package(self):
Reported by Pylint.
Line: 23
Column: 5
spec = self.find(name)
self.assertEqual(spec.origin, 'frozen')
def test_package(self):
spec = self.find('__phello__')
self.assertIsNotNone(spec)
def test_module_in_package(self):
spec = self.find('__phello__.spam', ['__phello__'])
Reported by Pylint.
Lib/test/test_importlib/source/test_case_sensitivity.py
17 issues
Line: 4
Column: 1
"""Test case-sensitivity (PEP 235)."""
import sys
from .. import util
importlib = util.import_importlib('importlib')
machinery = util.import_importlib('importlib.machinery')
import os
Reported by Pylint.
Line: 9
Column: 1
importlib = util.import_importlib('importlib')
machinery = util.import_importlib('importlib.machinery')
import os
from test.support import os_helper
import unittest
import warnings
Reported by Pylint.
Line: 9
Column: 1
importlib = util.import_importlib('importlib')
machinery = util.import_importlib('importlib.machinery')
import os
from test.support import os_helper
import unittest
import warnings
Reported by Pylint.
Line: 10
Column: 1
machinery = util.import_importlib('importlib.machinery')
import os
from test.support import os_helper
import unittest
import warnings
@util.case_insensitive_tests
Reported by Pylint.
Line: 10
Column: 1
machinery = util.import_importlib('importlib.machinery')
import os
from test.support import os_helper
import unittest
import warnings
@util.case_insensitive_tests
Reported by Pylint.
Line: 11
Column: 1
import os
from test.support import os_helper
import unittest
import warnings
@util.case_insensitive_tests
class CaseSensitivityTest(util.CASEOKTestBase):
Reported by Pylint.
Line: 11
Column: 1
import os
from test.support import os_helper
import unittest
import warnings
@util.case_insensitive_tests
class CaseSensitivityTest(util.CASEOKTestBase):
Reported by Pylint.
Line: 12
Column: 1
import os
from test.support import os_helper
import unittest
import warnings
@util.case_insensitive_tests
class CaseSensitivityTest(util.CASEOKTestBase):
Reported by Pylint.
Line: 12
Column: 1
import os
from test.support import os_helper
import unittest
import warnings
@util.case_insensitive_tests
class CaseSensitivityTest(util.CASEOKTestBase):
Reported by Pylint.
Line: 23
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
variable is set."""
name = 'MoDuLe'
assert name != name.lower()
def finder(self, path):
return self.machinery.FileFinder(path,
(self.machinery.SourceFileLoader,
self.machinery.SOURCE_SUFFIXES),
Reported by Bandit.
Lib/test/support/threading_helper.py
17 issues
Line: 24
Column: 12
def threading_setup():
return _thread._count(), threading._dangling.copy()
def threading_cleanup(*original_values):
_MAX_COUNT = 100
Reported by Pylint.
Line: 24
Column: 30
def threading_setup():
return _thread._count(), threading._dangling.copy()
def threading_cleanup(*original_values):
_MAX_COUNT = 100
Reported by Pylint.
Line: 31
Column: 18
_MAX_COUNT = 100
for count in range(_MAX_COUNT):
values = _thread._count(), threading._dangling
if values == original_values:
break
if not count:
# Display a warning at the first iteration
Reported by Pylint.
Line: 31
Column: 36
_MAX_COUNT = 100
for count in range(_MAX_COUNT):
values = _thread._count(), threading._dangling
if values == original_values:
break
if not count:
# Display a warning at the first iteration
Reported by Pylint.
Line: 85
Column: 17
"""
if timeout is None:
timeout = support.SHORT_TIMEOUT
old_count = _thread._count()
try:
yield
finally:
start_time = time.monotonic()
deadline = start_time + timeout
Reported by Pylint.
Line: 92
Column: 21
start_time = time.monotonic()
deadline = start_time + timeout
while True:
count = _thread._count()
if count <= old_count:
break
if time.monotonic() > deadline:
dt = time.monotonic() - start_time
msg = (f"wait_threads() failed to cleanup {count - old_count} "
Reported by Pylint.
Line: 1
Column: 1
import _thread
import contextlib
import functools
import sys
import threading
import time
from test import support
Reported by Pylint.
Line: 23
Column: 1
# at the end of a test run.
def threading_setup():
return _thread._count(), threading._dangling.copy()
def threading_cleanup(*original_values):
_MAX_COUNT = 100
Reported by Pylint.
Line: 27
Column: 1
return _thread._count(), threading._dangling.copy()
def threading_cleanup(*original_values):
_MAX_COUNT = 100
for count in range(_MAX_COUNT):
values = _thread._count(), threading._dangling
if values == original_values:
Reported by Pylint.
Line: 28
Column: 5
def threading_cleanup(*original_values):
_MAX_COUNT = 100
for count in range(_MAX_COUNT):
values = _thread._count(), threading._dangling
if values == original_values:
break
Reported by Pylint.
Lib/sqlite3/dump.py
17 issues
Line: 31
Column: 21
ORDER BY "name"
"""
schema_res = cu.execute(q)
for table_name, type, sql in schema_res.fetchall():
if table_name == 'sqlite_sequence':
yield('DELETE FROM "sqlite_sequence";')
elif table_name == 'sqlite_stat1':
yield('ANALYZE "sqlite_master";')
elif table_name.startswith('sqlite_'):
Reported by Pylint.
Line: 31
Column: 21
ORDER BY "name"
"""
schema_res = cu.execute(q)
for table_name, type, sql in schema_res.fetchall():
if table_name == 'sqlite_sequence':
yield('DELETE FROM "sqlite_sequence";')
elif table_name == 'sqlite_stat1':
yield('ANALYZE "sqlite_master";')
elif table_name.startswith('sqlite_'):
Reported by Pylint.
Line: 52
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b608_hardcoded_sql_expressions.html
table_name_ident = table_name.replace('"', '""')
res = cu.execute('PRAGMA table_info("{0}")'.format(table_name_ident))
column_names = [str(table_info[1]) for table_info in res.fetchall()]
q = """SELECT 'INSERT INTO "{0}" VALUES({1})' FROM "{0}";""".format(
table_name_ident,
",".join("""'||quote("{0}")||'""".format(col.replace('"', '""')) for col in column_names))
query_res = cu.execute(q)
for row in query_res:
yield("{0};".format(row[0]))
Reported by Bandit.
Line: 67
Column: 9
"type" IN ('index', 'trigger', 'view')
"""
schema_res = cu.execute(q)
for name, type, sql in schema_res.fetchall():
yield('{0};'.format(sql))
yield('COMMIT;')
Reported by Pylint.
Line: 1
Column: 1
# Mimic the sqlite3 console shell's .dump command
# Author: Paul Kippes <kippesp@gmail.com>
# Every identifier in sql is quoted based on a comment in sqlite
# documentation "SQLite adds new keywords from time to time when it
# takes on new features. So to prevent your code from being broken by
# future enhancements, you should normally quote any identifier that
# is an English language word, even if you do not have to."
Reported by Pylint.
Line: 19
Column: 5
directly but instead called from the Connection method, iterdump().
"""
cu = connection.cursor()
yield('BEGIN TRANSACTION;')
# sqlite_master table contains the SQL CREATE statements for the database.
q = """
SELECT "name", "type", "sql"
Reported by Pylint.
Line: 20
Column: 1
"""
cu = connection.cursor()
yield('BEGIN TRANSACTION;')
# sqlite_master table contains the SQL CREATE statements for the database.
q = """
SELECT "name", "type", "sql"
FROM "sqlite_master"
Reported by Pylint.
Line: 23
Column: 5
yield('BEGIN TRANSACTION;')
# sqlite_master table contains the SQL CREATE statements for the database.
q = """
SELECT "name", "type", "sql"
FROM "sqlite_master"
WHERE "sql" NOT NULL AND
"type" == 'table'
ORDER BY "name"
Reported by Pylint.
Line: 33
Column: 1
schema_res = cu.execute(q)
for table_name, type, sql in schema_res.fetchall():
if table_name == 'sqlite_sequence':
yield('DELETE FROM "sqlite_sequence";')
elif table_name == 'sqlite_stat1':
yield('ANALYZE "sqlite_master";')
elif table_name.startswith('sqlite_'):
continue
# NOTE: Virtual table support not implemented
Reported by Pylint.
Line: 35
Column: 1
if table_name == 'sqlite_sequence':
yield('DELETE FROM "sqlite_sequence";')
elif table_name == 'sqlite_stat1':
yield('ANALYZE "sqlite_master";')
elif table_name.startswith('sqlite_'):
continue
# NOTE: Virtual table support not implemented
#elif sql.startswith('CREATE VIRTUAL TABLE'):
# qtable = table_name.replace("'", "''")
Reported by Pylint.