The following issues were found
Lib/idlelib/idle_test/test_percolator.py
23 issues
Line: 15
Column: 9
Delegator.__init__(self, None)
def insert(self, *args):
self.insert_called_with = args
self.delegate.insert(*args)
def delete(self, *args):
self.delete_called_with = args
self.delegate.delete(*args)
Reported by Pylint.
Line: 19
Column: 9
self.delegate.insert(*args)
def delete(self, *args):
self.delete_called_with = args
self.delegate.delete(*args)
def uppercase_insert(self, index, chars, tags=None):
chars = chars.upper()
self.delegate.insert(index, chars)
Reported by Pylint.
Line: 22
Column: 46
self.delete_called_with = args
self.delegate.delete(*args)
def uppercase_insert(self, index, chars, tags=None):
chars = chars.upper()
self.delegate.insert(index, chars)
def lowercase_insert(self, index, chars, tags=None):
chars = chars.lower()
Reported by Pylint.
Line: 26
Column: 46
chars = chars.upper()
self.delegate.insert(index, chars)
def lowercase_insert(self, index, chars, tags=None):
chars = chars.lower()
self.delegate.insert(index, chars)
def dont_insert(self, index, chars, tags=None):
pass
Reported by Pylint.
Line: 4
Column: 1
"Test percolator, coverage 100%."
from idlelib.percolator import Percolator, Delegator
import unittest
from test.support import requires
requires('gui')
from tkinter import Text, Tk, END
Reported by Pylint.
Line: 5
Column: 1
from idlelib.percolator import Percolator, Delegator
import unittest
from test.support import requires
requires('gui')
from tkinter import Text, Tk, END
class MyFilter(Delegator):
Reported by Pylint.
Line: 7
Column: 1
import unittest
from test.support import requires
requires('gui')
from tkinter import Text, Tk, END
class MyFilter(Delegator):
def __init__(self):
Delegator.__init__(self, None)
Reported by Pylint.
Line: 7
Column: 1
import unittest
from test.support import requires
requires('gui')
from tkinter import Text, Tk, END
class MyFilter(Delegator):
def __init__(self):
Delegator.__init__(self, None)
Reported by Pylint.
Line: 10
Column: 1
from tkinter import Text, Tk, END
class MyFilter(Delegator):
def __init__(self):
Delegator.__init__(self, None)
def insert(self, *args):
self.insert_called_with = args
Reported by Pylint.
Line: 14
Column: 5
def __init__(self):
Delegator.__init__(self, None)
def insert(self, *args):
self.insert_called_with = args
self.delegate.insert(*args)
def delete(self, *args):
self.delete_called_with = args
Reported by Pylint.
Lib/idlelib/searchbase.py
23 issues
Line: 82
Column: 30
Replace and Find-in-Files add another entry row.
'''
top = Toplevel(self.root)
top.bind("<Return>", self.default_command)
top.bind("<Escape>", self.close)
top.protocol("WM_DELETE_WINDOW", self.close)
top.wm_title(self.title)
top.wm_iconname(self.icon)
_setup_dialog(top)
Reported by Pylint.
Line: 53
Column: 9
def open(self, text, searchphrase=None):
"Make dialog visible on top of others and ready to use."
self.text = text
if not self.top:
self.create_widgets()
else:
self.top.deiconify()
self.top.tkraise()
Reported by Pylint.
Line: 68
Column: 21
self.ent.icursor(0)
self.top.grab_set()
def close(self, event=None):
"Put dialog away for later use."
if self.top:
self.top.grab_release()
self.top.transient('')
self.top.withdraw()
Reported by Pylint.
Line: 89
Column: 9
top.wm_iconname(self.icon)
_setup_dialog(top)
self.top = top
self.frame = Frame(top, padding="5px")
self.frame.grid(sticky="nwes")
top.grid_columnconfigure(0, weight=100)
top.grid_rowconfigure(0, weight=100)
self.row = 0
Reported by Pylint.
Line: 94
Column: 9
top.grid_columnconfigure(0, weight=100)
top.grid_rowconfigure(0, weight=100)
self.row = 0
self.frame.grid_columnconfigure(0, pad=2, weight=0)
self.frame.grid_columnconfigure(1, pad=2, minsize=100, weight=100)
self.create_entries() # row 0 (and maybe 1), cols 0, 1
self.create_option_buttons() # next row, cols 0, 1
Reported by Pylint.
Line: 113
Column: 9
label.grid(row=self.row, column=0, sticky="nw")
entry = Entry(self.frame, textvariable=var, exportselection=0)
entry.grid(row=self.row, column=1, sticky="nwe")
self.row = self.row + 1
return entry, label
def create_entries(self):
"Create one or more entry lines with make_entry."
self.ent = self.make_entry("Find:", self.engine.patvar)[0]
Reported by Pylint.
Line: 118
Column: 9
def create_entries(self):
"Create one or more entry lines with make_entry."
self.ent = self.make_entry("Find:", self.engine.patvar)[0]
def make_frame(self,labeltext=None):
'''Return (frame, label).
frame - gridded labeled Frame for option or other buttons.
Reported by Pylint.
Line: 133
Column: 9
label = ''
frame = Frame(self.frame)
frame.grid(row=self.row, column=1, columnspan=1, sticky="nwe")
self.row = self.row + 1
return frame, label
def create_option_buttons(self):
'''Return (filled frame, options) for testing.
Reported by Pylint.
Line: 174
Column: 9
b = Button(self.buttonframe,
text=label, command=command,
default=isdef and "active" or "normal")
cols,rows=self.buttonframe.grid_size()
b.grid(pady=1,row=rows,column=0,sticky="ew")
self.buttonframe.grid(rowspan=rows+1)
return b
def create_command_buttons(self):
Reported by Pylint.
Line: 181
Column: 13
def create_command_buttons(self):
"Place buttons in vertical command frame gridded on right."
f = self.buttonframe = Frame(self.frame)
f.grid(row=0,column=2,padx=2,pady=2,ipadx=2,ipady=2)
b = self.make_button("Close", self.close)
b.lower()
Reported by Pylint.
Lib/distutils/tests/test_install.py
23 issues
Line: 70
Column: 48
libdir = os.path.join(destination, "lib", "python")
check_path(cmd.install_lib, libdir)
platlibdir = os.path.join(destination, sys.platlibdir, "python")
check_path(cmd.install_platlib, platlibdir)
check_path(cmd.install_purelib, libdir)
check_path(cmd.install_headers,
os.path.join(destination, "include", "python", "foopkg"))
check_path(cmd.install_scripts, os.path.join(destination, "bin"))
Reported by Pylint.
Line: 34
Column: 41
def setUp(self):
super().setUp()
self._backup_config_vars = dict(sysconfig._config_vars)
def tearDown(self):
super().tearDown()
sysconfig._config_vars.clear()
sysconfig._config_vars.update(self._backup_config_vars)
Reported by Pylint.
Line: 38
Column: 9
def tearDown(self):
super().tearDown()
sysconfig._config_vars.clear()
sysconfig._config_vars.update(self._backup_config_vars)
def test_home_installation_scheme(self):
# This ensure two things:
# - that --home generates the desired set of directory names
Reported by Pylint.
Line: 39
Column: 9
def tearDown(self):
super().tearDown()
sysconfig._config_vars.clear()
sysconfig._config_vars.update(self._backup_config_vars)
def test_home_installation_scheme(self):
# This ensure two things:
# - that --home generates the desired set of directory names
# - test --home is supported on all platforms
Reported by Pylint.
Line: 82
Column: 9
def test_user_site(self):
# test install with --user
# preparing the environment for the test
self.old_user_base = site.USER_BASE
self.old_user_site = site.USER_SITE
self.tmpdir = self.mkdtemp()
self.user_base = os.path.join(self.tmpdir, 'B')
self.user_site = os.path.join(self.tmpdir, 'S')
site.USER_BASE = self.user_base
Reported by Pylint.
Line: 83
Column: 9
# test install with --user
# preparing the environment for the test
self.old_user_base = site.USER_BASE
self.old_user_site = site.USER_SITE
self.tmpdir = self.mkdtemp()
self.user_base = os.path.join(self.tmpdir, 'B')
self.user_site = os.path.join(self.tmpdir, 'S')
site.USER_BASE = self.user_base
site.USER_SITE = self.user_site
Reported by Pylint.
Line: 84
Column: 9
# preparing the environment for the test
self.old_user_base = site.USER_BASE
self.old_user_site = site.USER_SITE
self.tmpdir = self.mkdtemp()
self.user_base = os.path.join(self.tmpdir, 'B')
self.user_site = os.path.join(self.tmpdir, 'S')
site.USER_BASE = self.user_base
site.USER_SITE = self.user_site
install_module.USER_BASE = self.user_base
Reported by Pylint.
Line: 85
Column: 9
self.old_user_base = site.USER_BASE
self.old_user_site = site.USER_SITE
self.tmpdir = self.mkdtemp()
self.user_base = os.path.join(self.tmpdir, 'B')
self.user_site = os.path.join(self.tmpdir, 'S')
site.USER_BASE = self.user_base
site.USER_SITE = self.user_site
install_module.USER_BASE = self.user_base
install_module.USER_SITE = self.user_site
Reported by Pylint.
Line: 86
Column: 9
self.old_user_site = site.USER_SITE
self.tmpdir = self.mkdtemp()
self.user_base = os.path.join(self.tmpdir, 'B')
self.user_site = os.path.join(self.tmpdir, 'S')
site.USER_BASE = self.user_base
site.USER_SITE = self.user_site
install_module.USER_BASE = self.user_base
install_module.USER_SITE = self.user_site
Reported by Pylint.
Line: 92
Column: 25
install_module.USER_BASE = self.user_base
install_module.USER_SITE = self.user_site
def _expanduser(path):
return self.tmpdir
self.old_expand = os.path.expanduser
os.path.expanduser = _expanduser
def cleanup():
Reported by Pylint.
Lib/importlib/readers.py
23 issues
Line: 6
Column: 1
import pathlib
import zipfile
from . import abc
from ._itertools import unique_everseen
def remove_duplicates(items):
Reported by Pylint.
Line: 8
Column: 1
from . import abc
from ._itertools import unique_everseen
def remove_duplicates(items):
return iter(collections.OrderedDict.fromkeys(items))
Reported by Pylint.
Line: 41
Column: 13
try:
return super().open_resource(resource)
except KeyError as exc:
raise FileNotFoundError(exc.args[0])
def is_resource(self, path):
# workaround for `zipfile.Path.is_file` returning true
# for non-existent paths.
target = self.files().joinpath(path)
Reported by Pylint.
Line: 1
Column: 1
import collections
import operator
import pathlib
import zipfile
from . import abc
from ._itertools import unique_everseen
Reported by Pylint.
Line: 11
Column: 1
from ._itertools import unique_everseen
def remove_duplicates(items):
return iter(collections.OrderedDict.fromkeys(items))
class FileReader(abc.TraversableResources):
def __init__(self, loader):
Reported by Pylint.
Line: 15
Column: 1
return iter(collections.OrderedDict.fromkeys(items))
class FileReader(abc.TraversableResources):
def __init__(self, loader):
self.path = pathlib.Path(loader.path).parent
def resource_path(self, resource):
"""
Reported by Pylint.
Line: 27
Column: 5
"""
return str(self.path.joinpath(resource))
def files(self):
return self.path
class ZipReader(abc.TraversableResources):
def __init__(self, loader, module):
Reported by Pylint.
Line: 31
Column: 1
return self.path
class ZipReader(abc.TraversableResources):
def __init__(self, loader, module):
_, _, name = module.rpartition('.')
self.prefix = loader.prefix.replace('\\', '/') + name + '/'
self.archive = loader.archive
Reported by Pylint.
Line: 37
Column: 5
self.prefix = loader.prefix.replace('\\', '/') + name + '/'
self.archive = loader.archive
def open_resource(self, resource):
try:
return super().open_resource(resource)
except KeyError as exc:
raise FileNotFoundError(exc.args[0])
Reported by Pylint.
Line: 43
Column: 5
except KeyError as exc:
raise FileNotFoundError(exc.args[0])
def is_resource(self, path):
# workaround for `zipfile.Path.is_file` returning true
# for non-existent paths.
target = self.files().joinpath(path)
return target.is_file() and target.exists()
Reported by Pylint.
Lib/distutils/tests/test_msvc9compiler.py
23 issues
Line: 133
Column: 9
v = Reg.get_value(path, 'dragfullwindows')
self.assertIn(v, ('0', '1', '2'))
import winreg
HKCU = winreg.HKEY_CURRENT_USER
keys = Reg.read_keys(HKCU, 'xxxx')
self.assertEqual(keys, None)
keys = Reg.read_keys(HKCU, r'Control Panel')
Reported by Pylint.
Line: 111
Column: 29
# a DistutilsPlatformError if the compiler
# is not found
from distutils.msvc9compiler import query_vcvarsall
def _find_vcvarsall(version):
return None
from distutils import msvc9compiler
old_find_vcvarsall = msvc9compiler.find_vcvarsall
msvc9compiler.find_vcvarsall = _find_vcvarsall
Reported by Pylint.
Line: 152
Column: 9
f.close()
compiler = MSVCCompiler()
compiler._remove_visual_c_ref(manifest)
# see what we got
f = open(manifest)
try:
# removing trailing spaces
Reported by Pylint.
Line: 176
Column: 15
f.close()
compiler = MSVCCompiler()
got = compiler._remove_visual_c_ref(manifest)
self.assertIsNone(got)
def test_suite():
return unittest.makeSuite(msvc9compilerTestCase)
Reported by Pylint.
Line: 94
Column: 5
</assembly>"""
if sys.platform=="win32":
from distutils.msvccompiler import get_build_version
if get_build_version()>=8.0:
SKIP_MESSAGE = None
else:
SKIP_MESSAGE = "These tests are only for MSVC8.0 or above"
else:
Reported by Pylint.
Line: 103
Column: 1
SKIP_MESSAGE = "These tests are only for win32"
@unittest.skipUnless(SKIP_MESSAGE is None, SKIP_MESSAGE)
class msvc9compilerTestCase(support.TempdirManager,
unittest.TestCase):
def test_no_compiler(self):
# makes sure query_vcvarsall raises
# a DistutilsPlatformError if the compiler
Reported by Pylint.
Line: 103
Column: 1
SKIP_MESSAGE = "These tests are only for win32"
@unittest.skipUnless(SKIP_MESSAGE is None, SKIP_MESSAGE)
class msvc9compilerTestCase(support.TempdirManager,
unittest.TestCase):
def test_no_compiler(self):
# makes sure query_vcvarsall raises
# a DistutilsPlatformError if the compiler
Reported by Pylint.
Line: 106
Column: 5
class msvc9compilerTestCase(support.TempdirManager,
unittest.TestCase):
def test_no_compiler(self):
# makes sure query_vcvarsall raises
# a DistutilsPlatformError if the compiler
# is not found
from distutils.msvc9compiler import query_vcvarsall
def _find_vcvarsall(version):
Reported by Pylint.
Line: 110
Column: 9
# makes sure query_vcvarsall raises
# a DistutilsPlatformError if the compiler
# is not found
from distutils.msvc9compiler import query_vcvarsall
def _find_vcvarsall(version):
return None
from distutils import msvc9compiler
old_find_vcvarsall = msvc9compiler.find_vcvarsall
Reported by Pylint.
Line: 114
Column: 9
def _find_vcvarsall(version):
return None
from distutils import msvc9compiler
old_find_vcvarsall = msvc9compiler.find_vcvarsall
msvc9compiler.find_vcvarsall = _find_vcvarsall
try:
self.assertRaises(DistutilsPlatformError, query_vcvarsall,
'wont find this version')
Reported by Pylint.
Lib/shlex.py
23 issues
Line: 190
Column: 3
if not nextchar: # end of file
if self.debug >= 2:
print("shlex: I see EOF in quotes state")
# XXX what error should be raised here?
raise ValueError("No closing quotation")
if nextchar == self.state:
if not self.posix:
self.token += nextchar
self.state = ' '
Reported by Pylint.
Line: 209
Column: 3
if not nextchar: # end of file
if self.debug >= 2:
print("shlex: I see EOF in escape state")
# XXX what error should be raised here?
raise ValueError("No escaped character")
# In posix shells, only the quote itself or the escape
# character may be escaped within quotes.
if (escapedstate in self.quotes and
nextchar != self.state and nextchar != escapedstate):
Reported by Pylint.
Line: 19
Column: 1
__all__ = ["shlex", "split", "quote", "join"]
class shlex:
"A lexical analyzer class for simple shell-like syntaxes."
def __init__(self, instream=None, infile=None, posix=False,
punctuation_chars=False):
if isinstance(instream, str):
instream = StringIO(instream)
Reported by Pylint.
Line: 19
Column: 1
__all__ = ["shlex", "split", "quote", "join"]
class shlex:
"A lexical analyzer class for simple shell-like syntaxes."
def __init__(self, instream=None, infile=None, posix=False,
punctuation_chars=False):
if isinstance(instream, str):
instream = StringIO(instream)
Reported by Pylint.
Line: 65
Column: 13
# these chars added because allowed in file names, args, wildcards
self.wordchars += '~-./*?='
#remove any punctuation chars from wordchars
t = self.wordchars.maketrans(dict.fromkeys(punctuation_chars))
self.wordchars = self.wordchars.translate(t)
@property
def punctuation_chars(self):
return self._punctuation_chars
Reported by Pylint.
Line: 69
Column: 5
self.wordchars = self.wordchars.translate(t)
@property
def punctuation_chars(self):
return self._punctuation_chars
def push_token(self, tok):
"Push a token onto the stack popped by the get_token method"
if self.debug >= 1:
Reported by Pylint.
Line: 120
Column: 13
raw = self.get_token()
# Maybe we got EOF instead?
while raw == self.eof:
if not self.filestack:
return self.eof
else:
self.pop_source()
raw = self.get_token()
# Neither inclusion nor EOF
Reported by Pylint.
Line: 133
Column: 5
print("shlex: token=EOF")
return raw
def read_token(self):
quoted = False
escapedstate = ' '
while True:
if self.punctuation_chars and self._pushback_chars:
nextchar = self._pushback_chars.pop()
Reported by Pylint.
Line: 133
Column: 5
print("shlex: token=EOF")
return raw
def read_token(self):
quoted = False
escapedstate = ' '
while True:
if self.punctuation_chars and self._pushback_chars:
nextchar = self._pushback_chars.pop()
Reported by Pylint.
Line: 133
Column: 5
print("shlex: token=EOF")
return raw
def read_token(self):
quoted = False
escapedstate = ' '
while True:
if self.punctuation_chars and self._pushback_chars:
nextchar = self._pushback_chars.pop()
Reported by Pylint.
Lib/multiprocessing/popen_spawn_posix.py
23 issues
Line: 4
Column: 1
import io
import os
from .context import reduction, set_spawning_popen
from . import popen_fork
from . import spawn
from . import util
__all__ = ['Popen']
Reported by Pylint.
Line: 5
Column: 1
import os
from .context import reduction, set_spawning_popen
from . import popen_fork
from . import spawn
from . import util
__all__ = ['Popen']
Reported by Pylint.
Line: 6
Column: 1
from .context import reduction, set_spawning_popen
from . import popen_fork
from . import spawn
from . import util
__all__ = ['Popen']
Reported by Pylint.
Line: 7
Column: 1
from .context import reduction, set_spawning_popen
from . import popen_fork
from . import spawn
from . import util
__all__ = ['Popen']
#
Reported by Pylint.
Line: 39
Column: 9
return fd
def _launch(self, process_obj):
from . import resource_tracker
tracker_fd = resource_tracker.getfd()
self._fds.append(tracker_fd)
prep_data = spawn.get_preparation_data(process_obj._name)
fp = io.BytesIO()
set_spawning_popen(self)
Reported by Pylint.
Line: 42
Column: 48
from . import resource_tracker
tracker_fd = resource_tracker.getfd()
self._fds.append(tracker_fd)
prep_data = spawn.get_preparation_data(process_obj._name)
fp = io.BytesIO()
set_spawning_popen(self)
try:
reduction.dump(prep_data, fp)
reduction.dump(process_obj, fp)
Reported by Pylint.
Line: 58
Column: 13
cmd = spawn.get_command_line(tracker_fd=tracker_fd,
pipe_handle=child_r)
self._fds.extend([child_r, child_w])
self.pid = util.spawnv_passfds(spawn.get_executable(),
cmd, self._fds)
self.sentinel = parent_r
with open(parent_w, 'wb', closefd=False) as f:
f.write(fp.getbuffer())
finally:
Reported by Pylint.
Line: 60
Column: 13
self._fds.extend([child_r, child_w])
self.pid = util.spawnv_passfds(spawn.get_executable(),
cmd, self._fds)
self.sentinel = parent_r
with open(parent_w, 'wb', closefd=False) as f:
f.write(fp.getbuffer())
finally:
fds_to_close = []
for fd in (parent_r, parent_w):
Reported by Pylint.
Line: 68
Column: 13
for fd in (parent_r, parent_w):
if fd is not None:
fds_to_close.append(fd)
self.finalizer = util.Finalize(self, util.close_fds, fds_to_close)
for fd in (child_r, child_w):
if fd is not None:
os.close(fd)
Reported by Pylint.
Line: 1
Column: 1
import io
import os
from .context import reduction, set_spawning_popen
from . import popen_fork
from . import spawn
from . import util
__all__ = ['Popen']
Reported by Pylint.
Lib/test/support/script_helper.py
23 issues
Line: 39
Column: 5
situation. PYTHONPATH or PYTHONUSERSITE are other common environment
variables that might impact whether or not the interpreter can start.
"""
global __cached_interp_requires_environment
if __cached_interp_requires_environment is None:
# If PYTHONHOME is set, assume that we need it
if 'PYTHONHOME' in os.environ:
__cached_interp_requires_environment = True
return True
Reported by Pylint.
Line: 137
Column: 13
out, err = proc.communicate()
finally:
proc.kill()
subprocess._cleanup()
rc = proc.returncode
return _PythonRunResult(rc, out, err), cmd_line
def _assert_python(expected_success, /, *args, **env_vars):
Reported by Pylint.
Line: 205
Column: 5
# try to cleanup the child so we don't appear to leak when running
# with regrtest -R.
p.wait()
subprocess._cleanup()
return data
def make_script(script_dir, script_basename, source, omit_suffix=False):
script_filename = script_basename
Reported by Pylint.
Line: 288
Column: 16
# In verbose mode, the child process inherit stdout and stdout,
# to see output in realtime and reduce the risk of losing output.
args = [sys.executable, "-E", "-X", "faulthandler", "-u", script, "-v"]
proc = subprocess.run(args)
print(title(f"{name} completed: exit code {proc.returncode}"),
flush=True)
if proc.returncode:
raise AssertionError(f"{name} failed")
else:
Reported by Pylint.
Line: 1
Column: 1
# Common utility functions used by various script execution tests
# e.g. test_cmd_line, test_cmd_line_script and test_runpy
import collections
import importlib
import sys
import os
import os.path
import subprocess
Reported by Pylint.
Line: 9
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess
import sys
import os
import os.path
import subprocess
import py_compile
import zipfile
from importlib.util import source_from_cache
from test import support
Reported by Bandit.
Line: 19
Column: 1
# Cached result of the expensive test performed in the function below.
__cached_interp_requires_environment = None
def interpreter_requires_environment():
"""
Returns True if our sys.executable interpreter requires environment
Reported by Pylint.
Line: 39
Column: 5
situation. PYTHONPATH or PYTHONUSERSITE are other common environment
variables that might impact whether or not the interpreter can start.
"""
global __cached_interp_requires_environment
if __cached_interp_requires_environment is None:
# If PYTHONHOME is set, assume that we need it
if 'PYTHONHOME' in os.environ:
__cached_interp_requires_environment = True
return True
Reported by Pylint.
Line: 48
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html
# Try running an interpreter with -E to see if it works or not.
try:
subprocess.check_call([sys.executable, '-E',
'-c', 'import sys; sys.exit(0)'])
except subprocess.CalledProcessError:
__cached_interp_requires_environment = True
else:
__cached_interp_requires_environment = False
Reported by Bandit.
Line: 90
Column: 1
# Executing the interpreter in a subprocess
def run_python_until_end(*args, **env_vars):
env_required = interpreter_requires_environment()
cwd = env_vars.pop('__cwd', None)
if '__isolated' in env_vars:
isolated = env_vars.pop('__isolated')
else:
Reported by Pylint.
Tools/c-analyzer/c_parser/parser/__init__.py
23 issues
Line: 119
Column: 1
* alt impl using a state machine (& tokenizer or split on delimiters)
"""
from ..info import ParsedItem
from ._info import SourceInfo
def parse(srclines):
if isinstance(srclines, str): # a filename
Reported by Pylint.
Line: 120
Column: 1
"""
from ..info import ParsedItem
from ._info import SourceInfo
def parse(srclines):
if isinstance(srclines, str): # a filename
raise NotImplementedError
Reported by Pylint.
Line: 156
Column: 5
def _parse(srclines, anon_name):
from ._global import parse_globals
source = _iter_source(srclines)
#source = _iter_source(srclines, showtext=True)
for result in parse_globals(source, anon_name):
# XXX Handle blocks here instead of in parse_globals().
Reported by Pylint.
Line: 110
Column: 1
parse the decl params.
"""
"""
TODO:
* extract CPython-specific code
* drop include injection (or only add when needed)
* track position instead of slicing "text"
* Parser class instead of the _iter_source() mess
Reported by Pylint.
Line: 132
Column: 3
yield ParsedItem.from_raw(result)
# XXX Later: Add a separate function to deal with preprocessor directives
# parsed out of raw source.
def anonymous_names():
counter = 1
Reported by Pylint.
Line: 161
Column: 3
source = _iter_source(srclines)
#source = _iter_source(srclines, showtext=True)
for result in parse_globals(source, anon_name):
# XXX Handle blocks here instead of in parse_globals().
yield result
def _iter_source(lines, *, maxtext=20_000, maxlines=700, showtext=False):
maxtext = maxtext if maxtext and maxtext > 0 else None
Reported by Pylint.
Line: 184
Column: 9
filestack.append(filename)
allinfo[filename] = srcinfo
_logger.debug(f'-> {line}')
srcinfo._add_line(line, fileinfo.lno)
if srcinfo.too_much(maxtext, maxlines):
break
while srcinfo._used():
yield srcinfo
Reported by Pylint.
Line: 185
Column: 9
allinfo[filename] = srcinfo
_logger.debug(f'-> {line}')
srcinfo._add_line(line, fileinfo.lno)
if srcinfo.too_much(maxtext, maxlines):
break
while srcinfo._used():
yield srcinfo
if showtext:
Reported by Pylint.
Line: 188
Column: 15
srcinfo._add_line(line, fileinfo.lno)
if srcinfo.too_much(maxtext, maxlines):
break
while srcinfo._used():
yield srcinfo
if showtext:
_logger.debug(f'=> {srcinfo.text}')
else:
if not filestack:
Reported by Pylint.
Line: 191
Column: 17
while srcinfo._used():
yield srcinfo
if showtext:
_logger.debug(f'=> {srcinfo.text}')
else:
if not filestack:
srcinfo = SourceInfo('???')
else:
filename = filestack[-1]
Reported by Pylint.
Python/pystrtod.c
23 issues
Line: 761
Column: 9
CWE codes:
120
Suggestion:
Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)
detected by returning NULL */
return NULL;
}
strcpy(tmp_format, format);
tmp_format[format_len - 1] = 'g';
format = tmp_format;
}
Reported by FlawFinder.
Line: 267
Column: 9
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
}
c = copy;
memcpy(c, digits_pos, decimal_point_pos - digits_pos);
c += decimal_point_pos - digits_pos;
memcpy(c, decimal_point, decimal_point_len);
c += decimal_point_len;
memcpy(c, decimal_point_pos + 1,
end - (decimal_point_pos + 1));
Reported by FlawFinder.
Line: 269
Column: 9
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
c = copy;
memcpy(c, digits_pos, decimal_point_pos - digits_pos);
c += decimal_point_pos - digits_pos;
memcpy(c, decimal_point, decimal_point_len);
c += decimal_point_len;
memcpy(c, decimal_point_pos + 1,
end - (decimal_point_pos + 1));
c += end - (decimal_point_pos + 1);
*c = 0;
Reported by FlawFinder.
Line: 271
Column: 9
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
c += decimal_point_pos - digits_pos;
memcpy(c, decimal_point, decimal_point_len);
c += decimal_point_len;
memcpy(c, decimal_point_pos + 1,
end - (decimal_point_pos + 1));
c += end - (decimal_point_pos + 1);
*c = 0;
val = strtod(copy, &fail_pos);
Reported by FlawFinder.
Line: 662
Column: 13
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
else {
memmove(p + insert_count, p,
buffer + strlen(buffer) - p + 1);
memcpy(p, chars_to_insert, insert_count);
}
}
if (convert_to_exp) {
int written;
size_t buf_avail;
Reported by FlawFinder.
Line: 726
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
/* Issue 2264: code 'Z' requires copying the format. 'Z' is 'g', but
also with at least one character past the decimal. */
char tmp_format[FLOAT_FORMATBUFLEN];
/* The last character in the format string must be the format char */
format_char = format[format_len - 1];
if (format[0] != '%')
Reported by FlawFinder.
Line: 802
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
int flags,
int *type)
{
char format[32];
Py_ssize_t bufsize;
char *buf;
int t, exp;
int upper = 0;
Reported by FlawFinder.
Line: 903
Column: 9
CWE codes:
120
Suggestion:
Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)
/* Handle nan and inf. */
if (Py_IS_NAN(val)) {
strcpy(buf, "nan");
t = Py_DTST_NAN;
} else if (Py_IS_INFINITY(val)) {
if (copysign(1., val) == 1.)
strcpy(buf, "inf");
else
Reported by FlawFinder.
Line: 907
Column: 13
CWE codes:
120
Suggestion:
Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)
t = Py_DTST_NAN;
} else if (Py_IS_INFINITY(val)) {
if (copysign(1., val) == 1.)
strcpy(buf, "inf");
else
strcpy(buf, "-inf");
t = Py_DTST_INFINITE;
} else {
t = Py_DTST_FINITE;
Reported by FlawFinder.
Line: 909
Column: 13
CWE codes:
120
Suggestion:
Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)
if (copysign(1., val) == 1.)
strcpy(buf, "inf");
else
strcpy(buf, "-inf");
t = Py_DTST_INFINITE;
} else {
t = Py_DTST_FINITE;
if (flags & Py_DTSF_ADD_DOT_0)
format_code = 'Z';
Reported by FlawFinder.