The following issues were found
Lib/test/test_asyncio/test_sock_lowlevel.py
51 issues
Line: 319
Column: 45
def test_huge_content(self):
with test_utils.run_test_server() as httpd:
self.loop.run_until_complete(
self._basetest_huge_content(httpd.address))
async def _basetest_huge_content_recvinto(self, address):
sock = socket.socket()
sock.setblocking(False)
DATA_SIZE = 10_000_00
Reported by Pylint.
Line: 374
Column: 54
def test_huge_content_recvinto(self):
with test_utils.run_test_server() as httpd:
self.loop.run_until_complete(
self._basetest_huge_content_recvinto(httpd.address))
@socket_helper.skip_unless_bind_unix_socket
def test_unix_sock_client_ops(self):
with test_utils.run_test_unix_server() as httpd:
sock = socket.socket(socket.AF_UNIX)
Reported by Pylint.
Line: 442
Column: 22
sock = None
infos = self.loop.run_until_complete(
self.loop.getaddrinfo(
*httpd.address, type=socket.SOCK_STREAM))
for family, type, proto, cname, address in infos:
try:
sock = socket.socket(family=family, type=type, proto=proto)
sock.setblocking(False)
self.loop.run_until_complete(
Reported by Pylint.
Line: 2
Column: 1
import socket
import time
import asyncio
import sys
import unittest
from asyncio import proactor_events
from itertools import cycle, islice
from test.test_asyncio import utils as test_utils
Reported by Pylint.
Line: 5
Column: 1
import time
import asyncio
import sys
import unittest
from asyncio import proactor_events
from itertools import cycle, islice
from test.test_asyncio import utils as test_utils
from test import support
Reported by Pylint.
Line: 231
Column: 13
listener.listen(1)
skip_reason = "Max retries reached"
for i in range(128):
try:
await self.loop.sock_connect(sock, addr)
except ConnectionRefusedError as e:
skip_reason = e
except OSError as e:
Reported by Pylint.
Line: 443
Column: 38
infos = self.loop.run_until_complete(
self.loop.getaddrinfo(
*httpd.address, type=socket.SOCK_STREAM))
for family, type, proto, cname, address in infos:
try:
sock = socket.socket(family=family, type=type, proto=proto)
sock.setblocking(False)
self.loop.run_until_complete(
self.loop.sock_connect(sock, address))
Reported by Pylint.
Line: 443
Column: 25
infos = self.loop.run_until_complete(
self.loop.getaddrinfo(
*httpd.address, type=socket.SOCK_STREAM))
for family, type, proto, cname, address in infos:
try:
sock = socket.socket(family=family, type=type, proto=proto)
sock.setblocking(False)
self.loop.run_until_complete(
self.loop.sock_connect(sock, address))
Reported by Pylint.
Line: 449
Column: 24
sock.setblocking(False)
self.loop.run_until_complete(
self.loop.sock_connect(sock, address))
except BaseException:
pass
else:
break
else:
assert False, 'Can not create socket.'
Reported by Pylint.
Line: 1
Column: 1
import socket
import time
import asyncio
import sys
import unittest
from asyncio import proactor_events
from itertools import cycle, islice
from test.test_asyncio import utils as test_utils
Reported by Pylint.
Lib/test/test_importlib/frozen/test_loader.py
51 issues
Line: 1
Column: 1
from .. import abc
from .. import util
machinery = util.import_importlib('importlib.machinery')
from test.support import captured_stdout
import types
import unittest
import warnings
Reported by Pylint.
Line: 2
Column: 1
from .. import abc
from .. import util
machinery = util.import_importlib('importlib.machinery')
from test.support import captured_stdout
import types
import unittest
import warnings
Reported by Pylint.
Line: 23
Column: 29
module.__spec__ = spec
assert not hasattr(module, 'initialized')
self.machinery.FrozenImporter.exec_module(module)
self.assertTrue(module.initialized)
self.assertTrue(hasattr(module, '__spec__'))
self.assertEqual(module.__spec__.origin, 'frozen')
return module, stdout.getvalue()
def test_module(self):
Reported by Pylint.
Line: 188
Column: 20
# Make sure that the code object is good.
name = '__hello__'
with captured_stdout() as stdout:
code = self.machinery.FrozenImporter.get_code(name)
mod = types.ModuleType(name)
exec(code, mod.__dict__)
self.assertTrue(hasattr(mod, 'initialized'))
self.assertEqual(stdout.getvalue(), 'Hello world!\n')
Reported by Pylint.
Line: 191
Column: 13
code = self.machinery.FrozenImporter.get_code(name)
mod = types.ModuleType(name)
exec(code, mod.__dict__)
self.assertTrue(hasattr(mod, 'initialized'))
self.assertEqual(stdout.getvalue(), 'Hello world!\n')
def test_get_source(self):
# Should always return None.
result = self.machinery.FrozenImporter.get_source('__hello__')
Reported by Pylint.
Line: 192
Column: 13
mod = types.ModuleType(name)
exec(code, mod.__dict__)
self.assertTrue(hasattr(mod, 'initialized'))
self.assertEqual(stdout.getvalue(), 'Hello world!\n')
def test_get_source(self):
# Should always return None.
result = self.machinery.FrozenImporter.get_source('__hello__')
self.assertIsNone(result)
Reported by Pylint.
Line: 196
Column: 18
def test_get_source(self):
# Should always return None.
result = self.machinery.FrozenImporter.get_source('__hello__')
self.assertIsNone(result)
def test_is_package(self):
# Should be able to tell what is a package.
test_for = (('__hello__', False), ('__phello__', True),
Reported by Pylint.
Line: 197
Column: 9
def test_get_source(self):
# Should always return None.
result = self.machinery.FrozenImporter.get_source('__hello__')
self.assertIsNone(result)
def test_is_package(self):
# Should be able to tell what is a package.
test_for = (('__hello__', False), ('__phello__', True),
('__phello__.spam', False))
Reported by Pylint.
Line: 204
Column: 22
test_for = (('__hello__', False), ('__phello__', True),
('__phello__.spam', False))
for name, is_package in test_for:
result = self.machinery.FrozenImporter.is_package(name)
self.assertEqual(bool(result), is_package)
def test_failure(self):
# Raise ImportError for modules that are not frozen.
for meth_name in ('get_code', 'get_source', 'is_package'):
Reported by Pylint.
Line: 205
Column: 13
('__phello__.spam', False))
for name, is_package in test_for:
result = self.machinery.FrozenImporter.is_package(name)
self.assertEqual(bool(result), is_package)
def test_failure(self):
# Raise ImportError for modules that are not frozen.
for meth_name in ('get_code', 'get_source', 'is_package'):
method = getattr(self.machinery.FrozenImporter, meth_name)
Reported by Pylint.
Tools/scripts/cleanfuture.py
51 issues
Line: 59
Column: 5
def main():
import getopt
global verbose, recurse, dryrun
try:
opts, args = getopt.getopt(sys.argv[1:], "drv")
except getopt.error as msg:
errprint(msg)
return
Reported by Pylint.
Line: 65
Column: 12
except getopt.error as msg:
errprint(msg)
return
for o, a in opts:
if o == '-d':
dryrun += 1
elif o == '-r':
recurse += 1
elif o == '-v':
Reported by Pylint.
Line: 165
Column: 9
changed = self.changed
get = tokenize.generate_tokens(self.getline).__next__
type, token, (srow, scol), (erow, ecol), line = get()
# Chew up initial comments and blank lines (if any).
while type in (COMMENT, NL, NEWLINE):
type, token, (srow, scol), (erow, ecol), line = get()
Reported by Pylint.
Line: 165
Column: 29
changed = self.changed
get = tokenize.generate_tokens(self.getline).__next__
type, token, (srow, scol), (erow, ecol), line = get()
# Chew up initial comments and blank lines (if any).
while type in (COMMENT, NL, NEWLINE):
type, token, (srow, scol), (erow, ecol), line = get()
Reported by Pylint.
Line: 165
Column: 43
changed = self.changed
get = tokenize.generate_tokens(self.getline).__next__
type, token, (srow, scol), (erow, ecol), line = get()
# Chew up initial comments and blank lines (if any).
while type in (COMMENT, NL, NEWLINE):
type, token, (srow, scol), (erow, ecol), line = get()
Reported by Pylint.
Line: 165
Column: 37
changed = self.changed
get = tokenize.generate_tokens(self.getline).__next__
type, token, (srow, scol), (erow, ecol), line = get()
# Chew up initial comments and blank lines (if any).
while type in (COMMENT, NL, NEWLINE):
type, token, (srow, scol), (erow, ecol), line = get()
Reported by Pylint.
Line: 220
Column: 17
# Check for obsolete features.
okfeatures = []
for f in features:
object = getattr(__future__, f, None)
if object is None:
# A feature we don't know about yet -- leave it in.
# They'll get a compile-time error when they compile
# this program, but that's not our job to sort out.
okfeatures.append(f)
Reported by Pylint.
Line: 252
Column: 13
def gettherest(self):
if self.ateof:
self.therest = ''
else:
self.therest = self.f.read()
def write(self, f):
changed = self.changed
Reported by Pylint.
Line: 254
Column: 13
if self.ateof:
self.therest = ''
else:
self.therest = self.f.read()
def write(self, f):
changed = self.changed
assert changed
# Prevent calling this again.
Reported by Pylint.
Line: 46
Column: 1
import os
import sys
dryrun = 0
recurse = 0
verbose = 0
def errprint(*args):
strings = map(str, args)
Reported by Pylint.
Lib/tkinter/filedialog.py
50 issues
Line: 118
Column: 3
self.cancel_button.pack(side=RIGHT)
self.top.protocol('WM_DELETE_WINDOW', self.cancel_command)
# XXX Are the following okay for a general audience?
self.top.bind('<Alt-w>', self.cancel_command)
self.top.bind('<Alt-W>', self.cancel_command)
def go(self, dir_or_file=os.curdir, pattern="*", default="", key=None):
if key and key in dialogstates:
Reported by Pylint.
Line: 137
Column: 9
self.selection.focus_set()
self.top.wait_visibility() # window needs to be visible for the grab
self.top.grab_set()
self.how = None
self.master.mainloop() # Exited by self.quit(how)
if key:
directory, pattern = self.get_filter()
if self.how:
directory = os.path.dirname(self.how)
Reported by Pylint.
Line: 148
Column: 9
return self.how
def quit(self, how=None):
self.how = how
self.master.quit() # Exit mainloop()
def dirs_double_event(self, event):
self.filter_command()
Reported by Pylint.
Line: 151
Column: 33
self.how = how
self.master.quit() # Exit mainloop()
def dirs_double_event(self, event):
self.filter_command()
def dirs_select_event(self, event):
dir, pat = self.get_filter()
subdir = self.dirs.get('active')
Reported by Pylint.
Line: 154
Column: 33
def dirs_double_event(self, event):
self.filter_command()
def dirs_select_event(self, event):
dir, pat = self.get_filter()
subdir = self.dirs.get('active')
dir = os.path.normpath(os.path.join(self.directory, subdir))
self.set_filter(dir, pat)
Reported by Pylint.
Line: 155
Column: 9
self.filter_command()
def dirs_select_event(self, event):
dir, pat = self.get_filter()
subdir = self.dirs.get('active')
dir = os.path.normpath(os.path.join(self.directory, subdir))
self.set_filter(dir, pat)
def files_double_event(self, event):
Reported by Pylint.
Line: 160
Column: 34
dir = os.path.normpath(os.path.join(self.directory, subdir))
self.set_filter(dir, pat)
def files_double_event(self, event):
self.ok_command()
def files_select_event(self, event):
file = self.files.get('active')
self.set_selection(file)
Reported by Pylint.
Line: 163
Column: 34
def files_double_event(self, event):
self.ok_command()
def files_select_event(self, event):
file = self.files.get('active')
self.set_selection(file)
def ok_event(self, event):
self.ok_command()
Reported by Pylint.
Line: 167
Column: 24
file = self.files.get('active')
self.set_selection(file)
def ok_event(self, event):
self.ok_command()
def ok_command(self):
self.quit(self.get_selection())
Reported by Pylint.
Line: 173
Column: 30
def ok_command(self):
self.quit(self.get_selection())
def filter_command(self, event=None):
dir, pat = self.get_filter()
try:
names = os.listdir(dir)
except OSError:
self.master.bell()
Reported by Pylint.
Lib/html/parser.py
50 issues
Line: 5
Column: 3
# This file is based on sgmllib.py, but the API is slightly different.
# XXX There should be a way to distinguish between PCDATA (parsed
# character data -- the normal case), RCDATA (replaceable character
# data -- only char and entity references and end tags are special)
# and CDATA (character data -- only end tags are special).
Reported by Pylint.
Line: 86
Column: 5
CDATA_CONTENT_ELEMENTS = ("script", "style")
def __init__(self, *, convert_charrefs=True):
"""Initialize and reset this instance.
If convert_charrefs is True (the default), all character references
are automatically converted to the corresponding Unicode characters.
"""
Reported by Pylint.
Line: 109
Column: 9
Call this as often as you want, with as little or as much text
as you want (may include '\n').
"""
self.rawdata = self.rawdata + data
self.goahead(0)
def close(self):
"""Handle any buffered data."""
self.goahead(1)
Reported by Pylint.
Line: 123
Column: 9
return self.__starttag_text
def set_cdata_mode(self, elem):
self.cdata_elem = elem.lower()
self.interesting = re.compile(r'</\s*%s\s*>' % self.cdata_elem, re.I)
def clear_cdata_mode(self):
self.interesting = interesting_normal
self.cdata_elem = None
Reported by Pylint.
Line: 124
Column: 9
def set_cdata_mode(self, elem):
self.cdata_elem = elem.lower()
self.interesting = re.compile(r'</\s*%s\s*>' % self.cdata_elem, re.I)
def clear_cdata_mode(self):
self.interesting = interesting_normal
self.cdata_elem = None
Reported by Pylint.
Line: 127
Column: 9
self.interesting = re.compile(r'</\s*%s\s*>' % self.cdata_elem, re.I)
def clear_cdata_mode(self):
self.interesting = interesting_normal
self.cdata_elem = None
# Internal -- handle data as far as reasonable. May leave state
# and data to be processed by a subsequent call. If 'end' is
# true, force handling all data as if followed by EOF marker.
Reported by Pylint.
Line: 128
Column: 9
def clear_cdata_mode(self):
self.interesting = interesting_normal
self.cdata_elem = None
# Internal -- handle data as far as reasonable. May leave state
# and data to be processed by a subsequent call. If 'end' is
# true, force handling all data as if followed by EOF marker.
def goahead(self, end):
Reported by Pylint.
Line: 250
Column: 9
else:
self.handle_data(rawdata[i:n])
i = self.updatepos(i, n)
self.rawdata = rawdata[i:]
# Internal -- parse html declarations, return length or -1 if not terminated
# See w3.org/TR/html5/tokenization.html#markup-declaration-open-state
# See also parse_declaration in _markupbase
def parse_html_declaration(self, i):
Reported by Pylint.
Line: 313
Column: 9
match = tagfind_tolerant.match(rawdata, i+1)
assert match, 'unexpected call to parse_starttag()'
k = match.end()
self.lasttag = tag = match.group(1).lower()
while k < endpos:
m = attrfind_tolerant.match(rawdata, k)
if not m:
break
attrname, rest, attrvalue = m.group(1, 2, 3)
Reported by Pylint.
Line: 356
Column: 13
m = locatestarttagend_tolerant.match(rawdata, i)
if m:
j = m.end()
next = rawdata[j:j+1]
if next == ">":
return j + 1
if next == "/":
if rawdata.startswith("/>", j):
return j + 2
Reported by Pylint.
Lib/dis.py
50 issues
Line: 8
Column: 1
import collections
import io
from opcode import *
from opcode import __all__ as _opcodes_all
__all__ = ["code_info", "dis", "disassemble", "distb", "disco",
"findlinestarts", "findlabels", "show_code",
"get_instructions", "Instruction", "Bytecode"] + _opcodes_all
Reported by Pylint.
Line: 8
Column: 1
import collections
import io
from opcode import *
from opcode import __all__ as _opcodes_all
__all__ = ["code_info", "dis", "disassemble", "distb", "disco",
"findlinestarts", "findlabels", "show_code",
"get_instructions", "Instruction", "Bytecode"] + _opcodes_all
Reported by Pylint.
Line: 8
Column: 1
import collections
import io
from opcode import *
from opcode import __all__ as _opcodes_all
__all__ = ["code_info", "dis", "disassemble", "distb", "disco",
"findlinestarts", "findlabels", "show_code",
"get_instructions", "Instruction", "Bytecode"] + _opcodes_all
Reported by Pylint.
Line: 8
Column: 1
import collections
import io
from opcode import *
from opcode import __all__ as _opcodes_all
__all__ = ["code_info", "dis", "disassemble", "distb", "disco",
"findlinestarts", "findlabels", "show_code",
"get_instructions", "Instruction", "Bytecode"] + _opcodes_all
Reported by Pylint.
Line: 8
Column: 1
import collections
import io
from opcode import *
from opcode import __all__ as _opcodes_all
__all__ = ["code_info", "dis", "disassemble", "distb", "disco",
"findlinestarts", "findlabels", "show_code",
"get_instructions", "Instruction", "Bytecode"] + _opcodes_all
Reported by Pylint.
Line: 8
Column: 1
import collections
import io
from opcode import *
from opcode import __all__ as _opcodes_all
__all__ = ["code_info", "dis", "disassemble", "distb", "disco",
"findlinestarts", "findlabels", "show_code",
"get_instructions", "Instruction", "Bytecode"] + _opcodes_all
Reported by Pylint.
Line: 309
Column: 36
else:
line_offset = 0
return _get_instructions_bytes(co.co_code,
co._varname_from_oparg,
co.co_names, co.co_consts,
linestarts, line_offset, co_positions=co.co_positions())
def _get_const_info(const_index, const_list):
"""Helper to get optional details about const references
Reported by Pylint.
Line: 382
Column: 13
get_name = None if names is None else names.__getitem__
labels = set(findlabels(code))
for start, end, target, _, _ in exception_entries:
for i in range(start, end):
labels.add(target)
starts_line = None
for offset, op, arg in _unpack_opargs(code):
if linestarts is not None:
starts_line = linestarts.get(offset, None)
Reported by Pylint.
Line: 437
Column: 24
linestarts = dict(findlinestarts(co))
exception_entries = parse_exception_table(co)
_disassemble_bytes(co.co_code, lasti,
co._varname_from_oparg,
co.co_names, co.co_consts, linestarts, file=file,
exception_entries=exception_entries, co_positions=co.co_positions())
def _disassemble_recursive(co, *, file=None, depth=None):
disassemble(co, file=file)
Reported by Pylint.
Line: 481
Column: 15
if new_source_line:
print(file=file)
is_current_instr = instr.offset == lasti
print(instr._disassemble(lineno_width, is_current_instr, offset_width),
file=file)
if exception_entries:
print("ExceptionTable:", file=file)
for entry in exception_entries:
lasti = " lasti" if entry.lasti else ""
Reported by Pylint.
Lib/test/test_asyncio/test_windows_events.py
50 issues
Line: 13
Column: 1
if sys.platform != 'win32':
raise unittest.SkipTest('Windows only')
import _overlapped
import _winapi
import asyncio
from asyncio import windows_events
from test.test_asyncio import utils as test_utils
Reported by Pylint.
Line: 14
Column: 1
raise unittest.SkipTest('Windows only')
import _overlapped
import _winapi
import asyncio
from asyncio import windows_events
from test.test_asyncio import utils as test_utils
Reported by Pylint.
Line: 29
Column: 5
def __init__(self):
self.buf = []
def connection_made(self, trans):
self.trans = trans
def data_received(self, data):
self.buf.append(data)
if b'\n' in data:
Reported by Pylint.
Line: 30
Column: 9
self.buf = []
def connection_made(self, trans):
self.trans = trans
def data_received(self, data):
self.buf.append(data)
if b'\n' in data:
self.trans.write(b''.join(self.buf).upper())
Reported by Pylint.
Line: 91
Column: 17
def test_close(self):
a, b = socket.socketpair()
trans = self.loop._make_socket_transport(a, asyncio.Protocol())
f = asyncio.ensure_future(self.loop.sock_recv(b, 100), loop=self.loop)
trans.close()
self.loop.run_until_complete(f)
self.assertEqual(f.result(), b'')
b.close()
Reported by Pylint.
Line: 126
Column: 25
protocol = asyncio.StreamReaderProtocol(stream_reader,
loop=self.loop)
trans, proto = await self.loop.create_pipe_connection(
lambda: protocol, ADDRESS)
self.assertIsInstance(trans, asyncio.Transport)
self.assertEqual(protocol, proto)
clients.append((stream_reader, trans))
for i, (r, w) in enumerate(clients):
Reported by Pylint.
Line: 151
Column: 52
exc = OSError()
exc.winerror = _overlapped.ERROR_PIPE_BUSY
with mock.patch.object(_overlapped, 'ConnectPipe',
side_effect=exc) as connect:
coro = self.loop._proactor.connect_pipe('pipe_address')
task = self.loop.create_task(coro)
# check that it's possible to cancel connect_pipe()
task.cancel()
Reported by Pylint.
Line: 152
Column: 20
exc.winerror = _overlapped.ERROR_PIPE_BUSY
with mock.patch.object(_overlapped, 'ConnectPipe',
side_effect=exc) as connect:
coro = self.loop._proactor.connect_pipe('pipe_address')
task = self.loop.create_task(coro)
# check that it's possible to cancel connect_pipe()
task.cancel()
with self.assertRaises(asyncio.CancelledError):
Reported by Pylint.
Line: 166
Column: 15
# Wait for unset event with 0.5s timeout;
# result should be False at timeout
fut = self.loop._proactor.wait_for_handle(event, 0.5)
start = self.loop.time()
done = self.loop.run_until_complete(fut)
elapsed = self.loop.time() - start
self.assertEqual(done, False)
Reported by Pylint.
Line: 181
Column: 15
# Wait for set event;
# result should be True immediately
fut = self.loop._proactor.wait_for_handle(event, 10)
start = self.loop.time()
done = self.loop.run_until_complete(fut)
elapsed = self.loop.time() - start
self.assertEqual(done, True)
Reported by Pylint.
Lib/test/test_type_comments.py
50 issues
Line: 4
Column: 1
import ast
import sys
import unittest
from test import support
funcdef = """\
def foo():
# type: () -> int
Reported by Pylint.
Line: 238
Column: 21
try:
yield self.parse(source, feature_version)
except SyntaxError as err:
raise SyntaxError(str(err) + f" feature_version={feature_version}")
else:
with self.assertRaisesRegex(SyntaxError, expected_regex,
msg=f"feature_version={feature_version}"):
self.parse(source, feature_version)
Reported by Pylint.
Line: 264
Column: 13
self.assertEqual(tree.body[1].type_comment, None)
def test_asyncvar(self):
for tree in self.parse_all(asyncvar, maxver=6):
pass
def test_asynccomp(self):
for tree in self.parse_all(asynccomp, minver=6):
pass
Reported by Pylint.
Line: 268
Column: 13
pass
def test_asynccomp(self):
for tree in self.parse_all(asynccomp, minver=6):
pass
def test_matmul(self):
for tree in self.parse_all(matmul, minver=5):
pass
Reported by Pylint.
Line: 272
Column: 13
pass
def test_matmul(self):
for tree in self.parse_all(matmul, minver=5):
pass
def test_fstring(self):
for tree in self.parse_all(fstring, minver=6):
pass
Reported by Pylint.
Line: 276
Column: 13
pass
def test_fstring(self):
for tree in self.parse_all(fstring, minver=6):
pass
def test_underscorednumber(self):
for tree in self.parse_all(underscorednumber, minver=6):
pass
Reported by Pylint.
Line: 280
Column: 13
pass
def test_underscorednumber(self):
for tree in self.parse_all(underscorednumber, minver=6):
pass
def test_redundantdef(self):
for tree in self.parse_all(redundantdef, maxver=0,
expected_regex="^Cannot have two type comments on def"):
Reported by Pylint.
Line: 284
Column: 13
pass
def test_redundantdef(self):
for tree in self.parse_all(redundantdef, maxver=0,
expected_regex="^Cannot have two type comments on def"):
pass
def test_nonasciidef(self):
for tree in self.parse_all(nonasciidef):
Reported by Pylint.
Line: 366
Column: 17
def check_both_ways(source):
ast.parse(source, type_comments=False)
for tree in self.parse_all(source, maxver=0):
pass
check_both_ways("pass # type: int\n")
check_both_ways("foo() # type: int\n")
check_both_ways("x += 1 # type: int\n")
Reported by Pylint.
Line: 1
Column: 1
import ast
import sys
import unittest
from test import support
funcdef = """\
def foo():
# type: () -> int
Reported by Pylint.
Lib/test/test_print.py
50 issues
Line: 110
Column: 29
self.written = ''
self.flushed = 0
def write(self, str):
self.written += str
def flush(self):
self.flushed += 1
Reported by Pylint.
Line: 125
Column: 29
# ensure exceptions from flush are passed through
class noflush:
def write(self, str):
pass
def flush(self):
raise RuntimeError
self.assertRaises(RuntimeError, print, 1, file=noflush(), flush=True)
Reported by Pylint.
Line: 141
Column: 13
def test_normal_string(self):
python2_print_str = 'print "Hello World"'
with self.assertRaises(SyntaxError) as context:
exec(python2_print_str)
self.assertIn("Missing parentheses in call to 'print'. Did you mean print(...)",
str(context.exception))
def test_string_with_soft_space(self):
Reported by Pylint.
Line: 141
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html
def test_normal_string(self):
python2_print_str = 'print "Hello World"'
with self.assertRaises(SyntaxError) as context:
exec(python2_print_str)
self.assertIn("Missing parentheses in call to 'print'. Did you mean print(...)",
str(context.exception))
def test_string_with_soft_space(self):
Reported by Bandit.
Line: 149
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html
def test_string_with_soft_space(self):
python2_print_str = 'print "Hello World",'
with self.assertRaises(SyntaxError) as context:
exec(python2_print_str)
self.assertIn("Missing parentheses in call to 'print'. Did you mean print(...)",
str(context.exception))
def test_string_with_excessive_whitespace(self):
Reported by Bandit.
Line: 149
Column: 13
def test_string_with_soft_space(self):
python2_print_str = 'print "Hello World",'
with self.assertRaises(SyntaxError) as context:
exec(python2_print_str)
self.assertIn("Missing parentheses in call to 'print'. Did you mean print(...)",
str(context.exception))
def test_string_with_excessive_whitespace(self):
Reported by Pylint.
Line: 157
Column: 13
def test_string_with_excessive_whitespace(self):
python2_print_str = 'print "Hello World", '
with self.assertRaises(SyntaxError) as context:
exec(python2_print_str)
self.assertIn("Missing parentheses in call to 'print'. Did you mean print(...)",
str(context.exception))
def test_string_with_leading_whitespace(self):
Reported by Pylint.
Line: 157
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html
def test_string_with_excessive_whitespace(self):
python2_print_str = 'print "Hello World", '
with self.assertRaises(SyntaxError) as context:
exec(python2_print_str)
self.assertIn("Missing parentheses in call to 'print'. Did you mean print(...)",
str(context.exception))
def test_string_with_leading_whitespace(self):
Reported by Bandit.
Line: 167
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html
print "Hello World"
'''
with self.assertRaises(SyntaxError) as context:
exec(python2_print_str)
self.assertIn("Missing parentheses in call to 'print'. Did you mean print(...)",
str(context.exception))
# bpo-32685: Suggestions for print statement should be proper when
Reported by Bandit.
Line: 167
Column: 13
print "Hello World"
'''
with self.assertRaises(SyntaxError) as context:
exec(python2_print_str)
self.assertIn("Missing parentheses in call to 'print'. Did you mean print(...)",
str(context.exception))
# bpo-32685: Suggestions for print statement should be proper when
Reported by Pylint.
Lib/mailcap.py
49 issues
Line: 173
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b605_start_process_with_a_shell.html
for e in entries:
if 'test' in e:
test = subst(e['test'], filename, plist)
if test and os.system(test) != 0:
continue
command = subst(e[key], MIMEtype, filename, plist)
return command, e
return None, None
Reported by Bandit.
Line: 253
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b605_start_process_with_a_shell.html
print("No viewer found for", type)
else:
print("Executing:", command)
sts = os.system(command)
sts = os.waitstatus_to_exitcode(sts)
if sts:
print("Exit status:", sts)
def show(caps):
Reported by Bandit.
Line: 254
Column: 19
else:
print("Executing:", command)
sts = os.system(command)
sts = os.waitstatus_to_exitcode(sts)
if sts:
print("Exit status:", sts)
def show(caps):
print("Mailcap files:")
Reported by Pylint.
Line: 159
Column: 1
# Part 3: using the database.
def findmatch(caps, MIMEtype, key='view', filename="/dev/null", plist=[]):
"""Find a match for a mailcap entry.
Return a tuple containing the command line, and the mailcap entry
used; (None, None) if no match is found. This may invoke the
'test' command of several matching entries before deciding which
Reported by Pylint.
Line: 169
Column: 3
"""
entries = lookup(caps, MIMEtype, key)
# XXX This code should somehow check for the needsterminal flag.
for e in entries:
if 'test' in e:
test = subst(e['test'], filename, plist)
if test and os.system(test) != 0:
continue
Reported by Pylint.
Line: 172
Column: 13
# XXX This code should somehow check for the needsterminal flag.
for e in entries:
if 'test' in e:
test = subst(e['test'], filename, plist)
if test and os.system(test) != 0:
continue
command = subst(e[key], MIMEtype, filename, plist)
return command, e
return None, None
Reported by Pylint.
Line: 192
Column: 1
entries = sorted(entries, key=lineno_sort_key)
return entries
def subst(field, MIMEtype, filename, plist=[]):
# XXX Actually, this is Unix-specific
res = ''
i, n = 0, len(field)
while i < n:
c = field[i]; i = i+1
Reported by Pylint.
Line: 193
Column: 3
return entries
def subst(field, MIMEtype, filename, plist=[]):
# XXX Actually, this is Unix-specific
res = ''
i, n = 0, len(field)
while i < n:
c = field[i]; i = i+1
if c != '%':
Reported by Pylint.
Line: 217
Column: 3
name = field[start:i]
i = i+1
res = res + findparam(name, plist)
# XXX To do:
# %n == number of parts if type is multipart/*
# %F == list of alternating type and filename for parts
else:
res = res + '%' + c
return res
Reported by Pylint.
Line: 248
Column: 18
return
MIMEtype = args[0]
file = args[1]
command, e = findmatch(caps, MIMEtype, 'view', file)
if not command:
print("No viewer found for", type)
else:
print("Executing:", command)
sts = os.system(command)
Reported by Pylint.