The following issues were found
Lib/test/test_tk.py
3 issues
Line: 1
Column: 1
from test import support
from test.support import import_helper
# Skip test if _tkinter wasn't built.
import_helper.import_module('_tkinter')
# Skip test if tk cannot be initialized.
support.requires('gui')
from tkinter.test import runtktests
Reported by Pylint.
Line: 9
Column: 1
# Skip test if tk cannot be initialized.
support.requires('gui')
from tkinter.test import runtktests
def test_main():
support.run_unittest(
*runtktests.get_tests(text=False, packages=['test_tkinter']))
Reported by Pylint.
Line: 11
Column: 1
from tkinter.test import runtktests
def test_main():
support.run_unittest(
*runtktests.get_tests(text=False, packages=['test_tkinter']))
if __name__ == '__main__':
test_main()
Reported by Pylint.
Mac/IDLE/IDLE.app/Contents/Resources/idlemain.py
3 issues
Line: 71
Column: 1
break
# Now it is safe to import idlelib.
from idlelib.pyshell import main
if __name__ == '__main__':
main()
Reported by Pylint.
Line: 4
Column: 1
"""
Bootstrap script for IDLE as an application bundle.
"""
import sys, os
# Change the current directory the user's home directory, that way we'll get
# a more useful default location in the open/save dialogs.
os.chdir(os.path.expanduser('~/Documents'))
Reported by Pylint.
Line: 71
Column: 1
break
# Now it is safe to import idlelib.
from idlelib.pyshell import main
if __name__ == '__main__':
main()
Reported by Pylint.
Lib/test/test_tools/test_gprof2html.py
3 issues
Line: 13
Column: 1
skip_if_missing()
class Gprof2htmlTests(unittest.TestCase):
def setUp(self):
self.gprof = import_tool('gprof2html')
oldargv = sys.argv
def fixup():
Reported by Pylint.
Line: 23
Column: 5
self.addCleanup(fixup)
sys.argv = []
def test_gprof(self):
# Issue #14508: this used to fail with a NameError.
with mock.patch.object(self.gprof, 'webbrowser') as wmock, \
tempfile.TemporaryDirectory() as tmpdir:
fn = os.path.join(tmpdir, 'abc')
open(fn, 'w').close()
Reported by Pylint.
Line: 27
Column: 13
# Issue #14508: this used to fail with a NameError.
with mock.patch.object(self.gprof, 'webbrowser') as wmock, \
tempfile.TemporaryDirectory() as tmpdir:
fn = os.path.join(tmpdir, 'abc')
open(fn, 'w').close()
sys.argv = ['gprof2html', fn]
self.gprof.main()
self.assertTrue(wmock.open.called)
Reported by Pylint.
Modules/_blake2/blake2b_impl.c
3 issues
Line: 124
Column: 9
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
BLAKE2B_SALTBYTES);
goto error;
}
memcpy(self->param.salt, salt->buf, salt->len);
}
/* Set personalization parameter. */
if ((person->obj != NULL) && person->len) {
if (person->len > BLAKE2B_PERSONALBYTES) {
Reported by FlawFinder.
Line: 135
Column: 9
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
BLAKE2B_PERSONALBYTES);
goto error;
}
memcpy(self->param.personal, person->buf, person->len);
}
/* Set tree parameters. */
if (fanout < 0 || fanout > 255) {
PyErr_SetString(PyExc_ValueError,
Reported by FlawFinder.
Line: 212
Column: 9
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
if (self->param.key_length) {
uint8_t block[BLAKE2B_BLOCKBYTES];
memset(block, 0, sizeof(block));
memcpy(block, key->buf, key->len);
blake2b_update(&self->state, block, sizeof(block));
secure_zero_memory(block, sizeof(block));
}
/* Process initial data if any. */
Reported by FlawFinder.
Modules/_blake2/blake2s_impl.c
3 issues
Line: 123
Column: 9
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
BLAKE2S_SALTBYTES);
goto error;
}
memcpy(self->param.salt, salt->buf, salt->len);
}
/* Set personalization parameter. */
if ((person->obj != NULL) && person->len) {
if (person->len > BLAKE2S_PERSONALBYTES) {
Reported by FlawFinder.
Line: 134
Column: 9
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
BLAKE2S_PERSONALBYTES);
goto error;
}
memcpy(self->param.personal, person->buf, person->len);
}
/* Set tree parameters. */
if (fanout < 0 || fanout > 255) {
PyErr_SetString(PyExc_ValueError,
Reported by FlawFinder.
Line: 211
Column: 9
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
if (self->param.key_length) {
uint8_t block[BLAKE2S_BLOCKBYTES];
memset(block, 0, sizeof(block));
memcpy(block, key->buf, key->len);
blake2s_update(&self->state, block, sizeof(block));
secure_zero_memory(block, sizeof(block));
}
/* Process initial data if any. */
Reported by FlawFinder.
Objects/fileobject.c
3 issues
Line: 427
Py_BEGIN_ALLOW_THREADS
res = isatty(self->fd);
Py_END_ALLOW_THREADS
return PyBool_FromLong(res);
}
static PyMethodDef stdprinter_methods[] = {
Reported by Cppcheck.
Line: 28
Column: 16
CWE codes:
362
extern "C" {
#endif
_Py_IDENTIFIER(open);
/* External C interface */
PyObject *
PyFile_FromFd(int fd, const char *name, const char *mode, int buffering, const char *encoding,
Reported by FlawFinder.
Line: 13
Column: 17
CWE codes:
120
20
#define FLOCKFILE(f) flockfile(f)
#define FUNLOCKFILE(f) funlockfile(f)
#else
#define GETC(f) getc(f)
#define FLOCKFILE(f)
#define FUNLOCKFILE(f)
#endif
/* Newline flags */
Reported by FlawFinder.
Objects/stringlib/find.h
3 issues
Line: 94
Column: 5
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
Py_ssize_t tmp_start = 0;
Py_ssize_t tmp_end = PY_SSIZE_T_MAX;
PyObject *obj_start=Py_None, *obj_end=Py_None;
char format[FORMAT_BUFFER_SIZE] = "O|OO:";
size_t len = strlen(format);
strncpy(format + len, function_name, FORMAT_BUFFER_SIZE - len - 1);
format[FORMAT_BUFFER_SIZE - 1] = '\0';
Reported by FlawFinder.
Line: 95
Column: 18
CWE codes:
126
Py_ssize_t tmp_end = PY_SSIZE_T_MAX;
PyObject *obj_start=Py_None, *obj_end=Py_None;
char format[FORMAT_BUFFER_SIZE] = "O|OO:";
size_t len = strlen(format);
strncpy(format + len, function_name, FORMAT_BUFFER_SIZE - len - 1);
format[FORMAT_BUFFER_SIZE - 1] = '\0';
if (!PyArg_ParseTuple(args, format, &tmp_subobj, &obj_start, &obj_end))
Reported by FlawFinder.
Line: 97
Column: 5
CWE codes:
120
char format[FORMAT_BUFFER_SIZE] = "O|OO:";
size_t len = strlen(format);
strncpy(format + len, function_name, FORMAT_BUFFER_SIZE - len - 1);
format[FORMAT_BUFFER_SIZE - 1] = '\0';
if (!PyArg_ParseTuple(args, format, &tmp_subobj, &obj_start, &obj_end))
return 0;
Reported by FlawFinder.
Objects/stringlib/join.h
3 issues
Line: 128
Column: 13
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
for (i = 0; i < nbufs; i++) {
Py_ssize_t n = buffers[i].len;
char *q = buffers[i].buf;
memcpy(p, q, n);
p += n;
}
}
else {
for (i = 0; i < nbufs; i++) {
Reported by FlawFinder.
Line: 137
Column: 17
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
Py_ssize_t n;
char *q;
if (i) {
memcpy(p, sepstr, seplen);
p += seplen;
}
n = buffers[i].len;
q = buffers[i].buf;
memcpy(p, q, n);
Reported by FlawFinder.
Line: 142
Column: 13
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
}
n = buffers[i].len;
q = buffers[i].buf;
memcpy(p, q, n);
p += n;
}
}
if (drop_gil) {
PyEval_RestoreThread(save);
Reported by FlawFinder.
Lib/test/test_peg_generator/__main__.py
3 issues
Line: 2
Column: 1
import unittest
from . import load_tests
unittest.main()
Reported by Pylint.
Line: 2
Column: 1
import unittest
from . import load_tests
unittest.main()
Reported by Pylint.
Line: 1
Column: 1
import unittest
from . import load_tests
unittest.main()
Reported by Pylint.
Lib/test/test_ttk_textonly.py
3 issues
Line: 1
Column: 1
from test import support
from test.support import import_helper
# Skip this test if _tkinter does not exist.
import_helper.import_module('_tkinter')
from tkinter.test import runtktests
Reported by Pylint.
Line: 8
Column: 1
# Skip this test if _tkinter does not exist.
import_helper.import_module('_tkinter')
from tkinter.test import runtktests
def test_main():
support.run_unittest(
*runtktests.get_tests(gui=False, packages=['test_ttk']))
Reported by Pylint.
Line: 10
Column: 1
from tkinter.test import runtktests
def test_main():
support.run_unittest(
*runtktests.get_tests(gui=False, packages=['test_ttk']))
if __name__ == '__main__':
test_main()
Reported by Pylint.