The following issues were found
Lib/dbm/ndbm.py
5 issues
Line: 3
Column: 1
"""Provide the _dbm module as a dbm submodule."""
from _dbm import *
Reported by Pylint.
Line: 3
Column: 1
"""Provide the _dbm module as a dbm submodule."""
from _dbm import *
Reported by Pylint.
Line: 3
Column: 1
"""Provide the _dbm module as a dbm submodule."""
from _dbm import *
Reported by Pylint.
Line: 3
Column: 1
"""Provide the _dbm module as a dbm submodule."""
from _dbm import *
Reported by Pylint.
Line: 3
Column: 1
"""Provide the _dbm module as a dbm submodule."""
from _dbm import *
Reported by Pylint.
Lib/distutils/tests/test_install_scripts.py
5 issues
Line: 13
Column: 1
from test.support import run_unittest
class InstallScriptsTestCase(support.TempdirManager,
support.LoggingSilencer,
unittest.TestCase):
def test_default_settings(self):
dist = Distribution()
Reported by Pylint.
Line: 17
Column: 5
support.LoggingSilencer,
unittest.TestCase):
def test_default_settings(self):
dist = Distribution()
dist.command_obj["build"] = support.DummyCommand(
build_scripts="/foo/bar")
dist.command_obj["install"] = support.DummyCommand(
install_scripts="/splat/funk",
Reported by Pylint.
Line: 39
Column: 5
self.assertEqual(cmd.build_dir, "/foo/bar")
self.assertEqual(cmd.install_dir, "/splat/funk")
def test_installation(self):
source = self.mkdtemp()
expected = []
def write_script(name, text):
expected.append(name)
Reported by Pylint.
Line: 45
Column: 13
def write_script(name, text):
expected.append(name)
f = open(os.path.join(source, name), "w")
try:
f.write(text)
finally:
f.close()
Reported by Pylint.
Line: 78
Column: 1
self.assertIn(name, installed)
def test_suite():
return unittest.makeSuite(InstallScriptsTestCase)
if __name__ == "__main__":
run_unittest(test_suite())
Reported by Pylint.
Lib/distutils/command/install_scripts.py
5 issues
Line: 44
Column: 9
def run(self):
if not self.skip_build:
self.run_command('build_scripts')
self.outfiles = self.copy_tree(self.build_dir, self.install_dir)
if os.name == 'posix':
# Set the executable bits (owner, group, and world) on
# all the scripts we just installed.
for file in self.get_outputs():
if self.dry_run:
Reported by Pylint.
Line: 14
Column: 1
from stat import ST_MODE
class install_scripts(Command):
description = "install scripts (Python or otherwise)"
user_options = [
('install-dir=', 'd', "directory to install scripts to"),
Reported by Pylint.
Line: 14
Column: 1
from stat import ST_MODE
class install_scripts(Command):
description = "install scripts (Python or otherwise)"
user_options = [
('install-dir=', 'd', "directory to install scripts to"),
Reported by Pylint.
Line: 56
Column: 5
log.info("changing mode of %s to %o", file, mode)
os.chmod(file, mode)
def get_inputs(self):
return self.distribution.scripts or []
def get_outputs(self):
return self.outfiles or []
Reported by Pylint.
Line: 59
Column: 5
def get_inputs(self):
return self.distribution.scripts or []
def get_outputs(self):
return self.outfiles or []
Reported by Pylint.
Doc/includes/email-mime.py
5 issues
Line: 15
Column: 15
msg['Subject'] = 'Our family reunion'
# me == the sender's email address
# family = the list of all recipients' email addresses
msg['From'] = me
msg['To'] = ', '.join(family)
msg.preamble = 'You will not see this in a MIME-aware mail reader.\n'
# Open the files in binary mode. Use imghdr to figure out the
# MIME subtype for each specific image.
Reported by Pylint.
Line: 16
Column: 23
# me == the sender's email address
# family = the list of all recipients' email addresses
msg['From'] = me
msg['To'] = ', '.join(family)
msg.preamble = 'You will not see this in a MIME-aware mail reader.\n'
# Open the files in binary mode. Use imghdr to figure out the
# MIME subtype for each specific image.
for file in pngfiles:
Reported by Pylint.
Line: 21
Column: 13
# Open the files in binary mode. Use imghdr to figure out the
# MIME subtype for each specific image.
for file in pngfiles:
with open(file, 'rb') as fp:
img_data = fp.read()
msg.add_attachment(img_data, maintype='image',
subtype=imghdr.what(None, img_data))
Reported by Pylint.
Line: 1
Column: 1
# Import smtplib for the actual sending function
import smtplib
# And imghdr to find the types of our images
import imghdr
# Here are the email package modules we'll need
from email.message import EmailMessage
Reported by Pylint.
Line: 1
Column: 1
# Import smtplib for the actual sending function
import smtplib
# And imghdr to find the types of our images
import imghdr
# Here are the email package modules we'll need
from email.message import EmailMessage
Reported by Pylint.
Doc/includes/sqlite3/rowclass.py
5 issues
Line: 1
Column: 1
import sqlite3
con = sqlite3.connect(":memory:")
con.row_factory = sqlite3.Row
cur = con.cursor()
cur.execute("select 'John' as name, 42 as age")
for row in cur:
assert row[0] == row["name"]
Reported by Pylint.
Line: 9
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
cur = con.cursor()
cur.execute("select 'John' as name, 42 as age")
for row in cur:
assert row[0] == row["name"]
assert row["name"] == row["nAmE"]
assert row[1] == row["age"]
assert row[1] == row["AgE"]
con.close()
Reported by Bandit.
Line: 10
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
cur.execute("select 'John' as name, 42 as age")
for row in cur:
assert row[0] == row["name"]
assert row["name"] == row["nAmE"]
assert row[1] == row["age"]
assert row[1] == row["AgE"]
con.close()
Reported by Bandit.
Line: 11
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
for row in cur:
assert row[0] == row["name"]
assert row["name"] == row["nAmE"]
assert row[1] == row["age"]
assert row[1] == row["AgE"]
con.close()
Reported by Bandit.
Line: 12
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert row[0] == row["name"]
assert row["name"] == row["nAmE"]
assert row[1] == row["age"]
assert row[1] == row["AgE"]
con.close()
Reported by Bandit.
Lib/distutils/tests/test_clean.py
5 issues
Line: 9
Column: 1
from distutils.tests import support
from test.support import run_unittest
class cleanTestCase(support.TempdirManager,
support.LoggingSilencer,
unittest.TestCase):
def test_simple_run(self):
pkg_dir, dist = self.create_dist()
Reported by Pylint.
Line: 9
Column: 1
from distutils.tests import support
from test.support import run_unittest
class cleanTestCase(support.TempdirManager,
support.LoggingSilencer,
unittest.TestCase):
def test_simple_run(self):
pkg_dir, dist = self.create_dist()
Reported by Pylint.
Line: 13
Column: 5
support.LoggingSilencer,
unittest.TestCase):
def test_simple_run(self):
pkg_dir, dist = self.create_dist()
cmd = clean(dist)
# let's add some elements clean should remove
dirs = [(d, os.path.join(pkg_dir, d))
Reported by Pylint.
Line: 27
Column: 17
setattr(cmd, name, path)
if name == 'build_base':
continue
for f in ('one', 'two', 'three'):
self.write_file(os.path.join(path, f))
# let's run the command
cmd.all = 1
cmd.ensure_finalized()
Reported by Pylint.
Line: 45
Column: 1
cmd.ensure_finalized()
cmd.run()
def test_suite():
return unittest.makeSuite(cleanTestCase)
if __name__ == "__main__":
run_unittest(test_suite())
Reported by Pylint.
Lib/distutils/tests/test_dep_util.py
5 issues
Line: 10
Column: 1
from distutils.tests import support
from test.support import run_unittest
class DepUtilTestCase(support.TempdirManager, unittest.TestCase):
def test_newer(self):
tmpdir = self.mkdtemp()
new_file = os.path.join(tmpdir, 'new')
Reported by Pylint.
Line: 12
Column: 5
class DepUtilTestCase(support.TempdirManager, unittest.TestCase):
def test_newer(self):
tmpdir = self.mkdtemp()
new_file = os.path.join(tmpdir, 'new')
old_file = os.path.abspath(__file__)
Reported by Pylint.
Line: 31
Column: 5
# than 'new_file'.
self.assertFalse(newer(old_file, new_file))
def test_newer_pairwise(self):
tmpdir = self.mkdtemp()
sources = os.path.join(tmpdir, 'sources')
targets = os.path.join(tmpdir, 'targets')
os.mkdir(sources)
os.mkdir(targets)
Reported by Pylint.
Line: 48
Column: 5
self.assertEqual(newer_pairwise([one, two], [three, four]),
([one],[three]))
def test_newer_group(self):
tmpdir = self.mkdtemp()
sources = os.path.join(tmpdir, 'sources')
os.mkdir(sources)
one = os.path.join(sources, 'one')
two = os.path.join(sources, 'two')
Reported by Pylint.
Line: 76
Column: 1
missing='newer'))
def test_suite():
return unittest.makeSuite(DepUtilTestCase)
if __name__ == "__main__":
run_unittest(test_suite())
Reported by Pylint.
Modules/_sqlite/clinic/connection.c.h
5 issues
Line: 237
Column: 9
CWE codes:
126
if (name == NULL) {
goto exit;
}
if (strlen(name) != (size_t)name_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
narg = _PyLong_AsInt(args[1]);
if (narg == -1 && PyErr_Occurred()) {
Reported by FlawFinder.
Line: 298
Column: 9
CWE codes:
126
if (name == NULL) {
goto exit;
}
if (strlen(name) != (size_t)name_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
n_arg = _PyLong_AsInt(args[1]);
if (n_arg == -1 && PyErr_Occurred()) {
Reported by FlawFinder.
Line: 483
Column: 9
CWE codes:
126
if (extension_name == NULL) {
goto exit;
}
if (strlen(extension_name) != (size_t)extension_name_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = pysqlite_connection_load_extension_impl(self, extension_name);
Reported by FlawFinder.
Line: 689
Column: 13
CWE codes:
126
if (name == NULL) {
goto exit;
}
if (strlen(name) != (size_t)name_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
if (!--noptargs) {
goto skip_optional_kwonly;
Reported by FlawFinder.
Line: 747
Column: 9
CWE codes:
126
if (name == NULL) {
goto exit;
}
if (strlen(name) != (size_t)name_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
callable = args[1];
return_value = pysqlite_connection_create_collation_impl(self, name, callable);
Reported by FlawFinder.
Lib/xml/dom/NodeFilter.py
5 issues
Line: 1
Column: 1
# This is the Python mapping for interface NodeFilter from
# DOM2-Traversal-Range. It contains only constants.
class NodeFilter:
"""
This is the DOM2 NodeFilter interface. It contains only constants.
"""
FILTER_ACCEPT = 1
FILTER_REJECT = 2
Reported by Pylint.
Line: 1
Column: 1
# This is the Python mapping for interface NodeFilter from
# DOM2-Traversal-Range. It contains only constants.
class NodeFilter:
"""
This is the DOM2 NodeFilter interface. It contains only constants.
"""
FILTER_ACCEPT = 1
FILTER_REJECT = 2
Reported by Pylint.
Line: 4
Column: 1
# This is the Python mapping for interface NodeFilter from
# DOM2-Traversal-Range. It contains only constants.
class NodeFilter:
"""
This is the DOM2 NodeFilter interface. It contains only constants.
"""
FILTER_ACCEPT = 1
FILTER_REJECT = 2
Reported by Pylint.
Line: 26
Column: 5
SHOW_DOCUMENT_FRAGMENT = 0x00000400
SHOW_NOTATION = 0x00000800
def acceptNode(self, node):
raise NotImplementedError
Reported by Pylint.
Line: 26
Column: 5
SHOW_DOCUMENT_FRAGMENT = 0x00000400
SHOW_NOTATION = 0x00000800
def acceptNode(self, node):
raise NotImplementedError
Reported by Pylint.
Lib/wsgiref/util.py
5 issues
Line: 21
Column: 9
self.close = filelike.close
def __getitem__(self,key):
import warnings
warnings.warn(
"FileWrapper's __getitem__ method ignores 'key' parameter. "
"Use iterator protocol instead.",
DeprecationWarning,
stacklevel=2
Reported by Pylint.
Line: 45
Column: 5
def guess_scheme(environ):
"""Return a guess for whether 'wsgi.url_scheme' should be 'http' or 'https'
"""
if environ.get("HTTPS") in ('yes','on','1'):
return 'https'
else:
return 'http'
def application_uri(environ):
Reported by Pylint.
Line: 53
Column: 5
def application_uri(environ):
"""Return the application's base URI (no PATH_INFO or QUERY_STRING)"""
url = environ['wsgi.url_scheme']+'://'
from urllib.parse import quote
if environ.get('HTTP_HOST'):
url += environ['HTTP_HOST']
else:
url += environ['SERVER_NAME']
Reported by Pylint.
Line: 73
Column: 5
def request_uri(environ, include_query=True):
"""Return the full request URI, optionally including the query string"""
url = application_uri(environ)
from urllib.parse import quote
path_info = quote(environ.get('PATH_INFO',''), safe='/;=,', encoding='latin1')
if not environ.get('SCRIPT_NAME'):
url += path_info[1:]
else:
url += path_info
Reported by Pylint.
Line: 152
Column: 5
environ.setdefault('wsgi.multithread', 0)
environ.setdefault('wsgi.multiprocess', 0)
from io import StringIO, BytesIO
environ.setdefault('wsgi.input', BytesIO())
environ.setdefault('wsgi.errors', StringIO())
environ.setdefault('wsgi.url_scheme',guess_scheme(environ))
if environ['wsgi.url_scheme']=='http':
Reported by Pylint.