The following issues were found
Lib/lib2to3/tests/data/infinite_recursion.py
1397 issues
Line: 3
Column: 1
# This file is used to verify that 2to3 falls back to a slower, iterative pattern matching
# scheme in the event that the faster recursive system fails due to infinite recursion.
from ctypes import *
STRING = c_char_p
OSUnknownByteOrder = 0
UIT_PROMPT = 1
P_PGID = 2
Reported by Pylint.
Line: 3
Column: 1
# This file is used to verify that 2to3 falls back to a slower, iterative pattern matching
# scheme in the event that the faster recursive system fails due to infinite recursion.
from ctypes import *
STRING = c_char_p
OSUnknownByteOrder = 0
UIT_PROMPT = 1
P_PGID = 2
Reported by Pylint.
Line: 3
Column: 1
# This file is used to verify that 2to3 falls back to a slower, iterative pattern matching
# scheme in the event that the faster recursive system fails due to infinite recursion.
from ctypes import *
STRING = c_char_p
OSUnknownByteOrder = 0
UIT_PROMPT = 1
P_PGID = 2
Reported by Pylint.
Line: 3
Column: 1
# This file is used to verify that 2to3 falls back to a slower, iterative pattern matching
# scheme in the event that the faster recursive system fails due to infinite recursion.
from ctypes import *
STRING = c_char_p
OSUnknownByteOrder = 0
UIT_PROMPT = 1
P_PGID = 2
Reported by Pylint.
Line: 3
Column: 1
# This file is used to verify that 2to3 falls back to a slower, iterative pattern matching
# scheme in the event that the faster recursive system fails due to infinite recursion.
from ctypes import *
STRING = c_char_p
OSUnknownByteOrder = 0
UIT_PROMPT = 1
P_PGID = 2
Reported by Pylint.
Line: 3
Column: 1
# This file is used to verify that 2to3 falls back to a slower, iterative pattern matching
# scheme in the event that the faster recursive system fails due to infinite recursion.
from ctypes import *
STRING = c_char_p
OSUnknownByteOrder = 0
UIT_PROMPT = 1
P_PGID = 2
Reported by Pylint.
Line: 3
Column: 1
# This file is used to verify that 2to3 falls back to a slower, iterative pattern matching
# scheme in the event that the faster recursive system fails due to infinite recursion.
from ctypes import *
STRING = c_char_p
OSUnknownByteOrder = 0
UIT_PROMPT = 1
P_PGID = 2
Reported by Pylint.
Line: 3
Column: 1
# This file is used to verify that 2to3 falls back to a slower, iterative pattern matching
# scheme in the event that the faster recursive system fails due to infinite recursion.
from ctypes import *
STRING = c_char_p
OSUnknownByteOrder = 0
UIT_PROMPT = 1
P_PGID = 2
Reported by Pylint.
Line: 3
Column: 1
# This file is used to verify that 2to3 falls back to a slower, iterative pattern matching
# scheme in the event that the faster recursive system fails due to infinite recursion.
from ctypes import *
STRING = c_char_p
OSUnknownByteOrder = 0
UIT_PROMPT = 1
P_PGID = 2
Reported by Pylint.
Line: 3
Column: 1
# This file is used to verify that 2to3 falls back to a slower, iterative pattern matching
# scheme in the event that the faster recursive system fails due to infinite recursion.
from ctypes import *
STRING = c_char_p
OSUnknownByteOrder = 0
UIT_PROMPT = 1
P_PGID = 2
Reported by Pylint.
Lib/test/datetimetester.py
1251 issues
Line: 440
Column: 14
# legit constructor.
def test_harmless_mixed_comparison(self):
me = self.theclass(1, 1, 1)
self.assertFalse(me == ())
self.assertTrue(me != ())
self.assertFalse(() == me)
self.assertTrue(() != me)
Reported by Pylint.
Line: 442
Column: 9
def test_harmless_mixed_comparison(self):
me = self.theclass(1, 1, 1)
self.assertFalse(me == ())
self.assertTrue(me != ())
self.assertFalse(() == me)
self.assertTrue(() != me)
self.assertIn(me, [1, 20, [], me])
Reported by Pylint.
Line: 443
Column: 9
me = self.theclass(1, 1, 1)
self.assertFalse(me == ())
self.assertTrue(me != ())
self.assertFalse(() == me)
self.assertTrue(() != me)
self.assertIn(me, [1, 20, [], me])
self.assertIn([], [me, 1, 20, []])
Reported by Pylint.
Line: 444
Column: 9
self.assertFalse(me == ())
self.assertTrue(me != ())
self.assertFalse(() == me)
self.assertTrue(() != me)
self.assertIn(me, [1, 20, [], me])
self.assertIn([], [me, 1, 20, []])
Reported by Pylint.
Line: 445
Column: 9
self.assertFalse(me == ())
self.assertTrue(me != ())
self.assertFalse(() == me)
self.assertTrue(() != me)
self.assertIn(me, [1, 20, [], me])
self.assertIn([], [me, 1, 20, []])
# Comparison to objects of unsupported types should return
Reported by Pylint.
Line: 447
Column: 9
self.assertFalse(() == me)
self.assertTrue(() != me)
self.assertIn(me, [1, 20, [], me])
self.assertIn([], [me, 1, 20, []])
# Comparison to objects of unsupported types should return
# NotImplemented which falls back to the right hand side's __eq__
# method. In this case, ALWAYS_EQ.__eq__ always returns True.
Reported by Pylint.
Line: 448
Column: 9
self.assertTrue(() != me)
self.assertIn(me, [1, 20, [], me])
self.assertIn([], [me, 1, 20, []])
# Comparison to objects of unsupported types should return
# NotImplemented which falls back to the right hand side's __eq__
# method. In this case, ALWAYS_EQ.__eq__ always returns True.
# ALWAYS_EQ.__ne__ always returns False.
Reported by Pylint.
Line: 454
Column: 9
# NotImplemented which falls back to the right hand side's __eq__
# method. In this case, ALWAYS_EQ.__eq__ always returns True.
# ALWAYS_EQ.__ne__ always returns False.
self.assertTrue(me == ALWAYS_EQ)
self.assertFalse(me != ALWAYS_EQ)
# If the other class explicitly defines ordering
# relative to our class, it is allowed to do so
self.assertTrue(me < LARGEST)
Reported by Pylint.
Line: 455
Column: 9
# method. In this case, ALWAYS_EQ.__eq__ always returns True.
# ALWAYS_EQ.__ne__ always returns False.
self.assertTrue(me == ALWAYS_EQ)
self.assertFalse(me != ALWAYS_EQ)
# If the other class explicitly defines ordering
# relative to our class, it is allowed to do so
self.assertTrue(me < LARGEST)
self.assertFalse(me > LARGEST)
Reported by Pylint.
Line: 459
Column: 9
# If the other class explicitly defines ordering
# relative to our class, it is allowed to do so
self.assertTrue(me < LARGEST)
self.assertFalse(me > LARGEST)
self.assertTrue(me <= LARGEST)
self.assertFalse(me >= LARGEST)
self.assertFalse(me < SMALLEST)
self.assertTrue(me > SMALLEST)
Reported by Pylint.
Lib/test/test_pathlib.py
1250 issues
Line: 1398
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b103_set_bad_file_permissions.html
def setUp(self):
def cleanup():
os.chmod(join('dirE'), 0o777)
os_helper.rmtree(BASE)
self.addCleanup(cleanup)
os.mkdir(BASE)
os.mkdir(join('dirA'))
os.mkdir(join('dirB'))
Reported by Bandit.
Line: 27
Column: 13
class _BaseFlavourTest(object):
def _check_parse_parts(self, arg, expected):
f = self.flavour.parse_parts
sep = self.flavour.sep
altsep = self.flavour.altsep
actual = f([x.replace('/', sep) for x in arg])
self.assertEqual(actual, expected)
if altsep:
Reported by Pylint.
Line: 28
Column: 15
def _check_parse_parts(self, arg, expected):
f = self.flavour.parse_parts
sep = self.flavour.sep
altsep = self.flavour.altsep
actual = f([x.replace('/', sep) for x in arg])
self.assertEqual(actual, expected)
if altsep:
actual = f([x.replace('/', altsep) for x in arg])
Reported by Pylint.
Line: 29
Column: 18
def _check_parse_parts(self, arg, expected):
f = self.flavour.parse_parts
sep = self.flavour.sep
altsep = self.flavour.altsep
actual = f([x.replace('/', sep) for x in arg])
self.assertEqual(actual, expected)
if altsep:
actual = f([x.replace('/', altsep) for x in arg])
self.assertEqual(actual, expected)
Reported by Pylint.
Line: 31
Column: 9
sep = self.flavour.sep
altsep = self.flavour.altsep
actual = f([x.replace('/', sep) for x in arg])
self.assertEqual(actual, expected)
if altsep:
actual = f([x.replace('/', altsep) for x in arg])
self.assertEqual(actual, expected)
def test_parse_parts_common(self):
Reported by Pylint.
Line: 34
Column: 13
self.assertEqual(actual, expected)
if altsep:
actual = f([x.replace('/', altsep) for x in arg])
self.assertEqual(actual, expected)
def test_parse_parts_common(self):
check = self._check_parse_parts
sep = self.flavour.sep
# Unanchored parts.
Reported by Pylint.
Line: 38
Column: 15
def test_parse_parts_common(self):
check = self._check_parse_parts
sep = self.flavour.sep
# Unanchored parts.
check([], ('', '', []))
check(['a'], ('', '', ['a']))
check(['a/'], ('', '', ['a']))
check(['a', 'b'], ('', '', ['a', 'b']))
Reported by Pylint.
Line: 187
Column: 13
}
def setUp(self):
p = self.cls('a')
self.flavour = p._flavour
self.sep = self.flavour.sep
self.altsep = self.flavour.altsep
def test_constructor_common(self):
Reported by Pylint.
Line: 193
Column: 13
self.altsep = self.flavour.altsep
def test_constructor_common(self):
P = self.cls
p = P('a')
self.assertIsInstance(p, P)
P('a', 'b', 'c')
P('/a', 'b', 'c')
P('a/b/c')
Reported by Pylint.
Line: 195
Column: 9
def test_constructor_common(self):
P = self.cls
p = P('a')
self.assertIsInstance(p, P)
P('a', 'b', 'c')
P('/a', 'b', 'c')
P('a/b/c')
P('/a/b/c')
P(FakePath("a/b/c"))
Reported by Pylint.
Lib/test/test_bytes.py
1201 issues
Line: 50
Column: 13
class BaseBytesTest:
def test_basics(self):
b = self.type2test()
self.assertEqual(type(b), self.type2test)
self.assertEqual(b.__class__, self.type2test)
def test_copy(self):
a = self.type2test(b"abcd")
Reported by Pylint.
Line: 51
Column: 9
def test_basics(self):
b = self.type2test()
self.assertEqual(type(b), self.type2test)
self.assertEqual(b.__class__, self.type2test)
def test_copy(self):
a = self.type2test(b"abcd")
for copy_method in (copy.copy, copy.deepcopy):
Reported by Pylint.
Line: 51
Column: 35
def test_basics(self):
b = self.type2test()
self.assertEqual(type(b), self.type2test)
self.assertEqual(b.__class__, self.type2test)
def test_copy(self):
a = self.type2test(b"abcd")
for copy_method in (copy.copy, copy.deepcopy):
Reported by Pylint.
Line: 52
Column: 9
def test_basics(self):
b = self.type2test()
self.assertEqual(type(b), self.type2test)
self.assertEqual(b.__class__, self.type2test)
def test_copy(self):
a = self.type2test(b"abcd")
for copy_method in (copy.copy, copy.deepcopy):
b = copy_method(a)
Reported by Pylint.
Line: 52
Column: 39
def test_basics(self):
b = self.type2test()
self.assertEqual(type(b), self.type2test)
self.assertEqual(b.__class__, self.type2test)
def test_copy(self):
a = self.type2test(b"abcd")
for copy_method in (copy.copy, copy.deepcopy):
b = copy_method(a)
Reported by Pylint.
Line: 55
Column: 13
self.assertEqual(b.__class__, self.type2test)
def test_copy(self):
a = self.type2test(b"abcd")
for copy_method in (copy.copy, copy.deepcopy):
b = copy_method(a)
self.assertEqual(a, b)
self.assertEqual(type(a), type(b))
Reported by Pylint.
Line: 58
Column: 13
a = self.type2test(b"abcd")
for copy_method in (copy.copy, copy.deepcopy):
b = copy_method(a)
self.assertEqual(a, b)
self.assertEqual(type(a), type(b))
def test_empty_sequence(self):
b = self.type2test()
self.assertEqual(len(b), 0)
Reported by Pylint.
Line: 59
Column: 13
for copy_method in (copy.copy, copy.deepcopy):
b = copy_method(a)
self.assertEqual(a, b)
self.assertEqual(type(a), type(b))
def test_empty_sequence(self):
b = self.type2test()
self.assertEqual(len(b), 0)
self.assertRaises(IndexError, lambda: b[0])
Reported by Pylint.
Line: 62
Column: 13
self.assertEqual(type(a), type(b))
def test_empty_sequence(self):
b = self.type2test()
self.assertEqual(len(b), 0)
self.assertRaises(IndexError, lambda: b[0])
self.assertRaises(IndexError, lambda: b[1])
self.assertRaises(IndexError, lambda: b[sys.maxsize])
self.assertRaises(IndexError, lambda: b[sys.maxsize+1])
Reported by Pylint.
Line: 63
Column: 9
def test_empty_sequence(self):
b = self.type2test()
self.assertEqual(len(b), 0)
self.assertRaises(IndexError, lambda: b[0])
self.assertRaises(IndexError, lambda: b[1])
self.assertRaises(IndexError, lambda: b[sys.maxsize])
self.assertRaises(IndexError, lambda: b[sys.maxsize+1])
self.assertRaises(IndexError, lambda: b[10**100])
Reported by Pylint.
Lib/test/pickletester.py
1192 issues
Line: 274
Column: 20
@property
def readonly(self):
return self.array.readonly
@property
def c_contiguous(self):
return self.array.c_contiguous
Reported by Pylint.
Line: 278
Column: 20
@property
def c_contiguous(self):
return self.array.c_contiguous
@property
def f_contiguous(self):
return self.array.f_contiguous
Reported by Pylint.
Line: 282
Column: 20
@property
def f_contiguous(self):
return self.array.f_contiguous
def __eq__(self, other):
if not isinstance(other, PicklableNDArray):
return NotImplemented
return (other.array.format == self.array.format and
Reported by Pylint.
Line: 287
Column: 43
def __eq__(self, other):
if not isinstance(other, PicklableNDArray):
return NotImplemented
return (other.array.format == self.array.format and
other.array.shape == self.array.shape and
other.array.strides == self.array.strides and
other.array.readonly == self.array.readonly and
other.array.tobytes() == self.array.tobytes())
Reported by Pylint.
Line: 290
Column: 45
return (other.array.format == self.array.format and
other.array.shape == self.array.shape and
other.array.strides == self.array.strides and
other.array.readonly == self.array.readonly and
other.array.tobytes() == self.array.tobytes())
def __ne__(self, other):
if not isinstance(other, PicklableNDArray):
return NotImplemented
Reported by Pylint.
Line: 304
Column: 20
f"bytes={self.array.tobytes()})")
def __reduce_ex__(self, protocol):
if not self.array.contiguous:
raise NotImplementedError("Reconstructing a non-contiguous "
"ndarray does not seem possible")
ndarray_kwargs = {"shape": self.array.shape,
"strides": self.array.strides,
"format": self.array.format,
Reported by Pylint.
Line: 309
Column: 41
"ndarray does not seem possible")
ndarray_kwargs = {"shape": self.array.shape,
"strides": self.array.strides,
"format": self.array.format,
"flags": (0 if self.readonly
else _testbuffer.ND_WRITABLE)}
pb = pickle.PickleBuffer(self.array)
if protocol >= 5:
return (type(self)._reconstruct,
Reported by Pylint.
Line: 858
Column: 17
with self.subTest(data=data), \
self.assertRaises(errors):
try:
self.loads(data)
except BaseException as exc:
if support.verbose > 1:
print('%-32r - %s: %s' %
(data, exc.__class__.__name__, exc))
raise
Reported by Pylint.
Line: 866
Column: 45
raise
def test_load_from_data0(self):
self.assert_is_copy(self._testdata, self.loads(DATA0))
def test_load_from_data1(self):
self.assert_is_copy(self._testdata, self.loads(DATA1))
def test_load_from_data2(self):
Reported by Pylint.
Line: 869
Column: 45
self.assert_is_copy(self._testdata, self.loads(DATA0))
def test_load_from_data1(self):
self.assert_is_copy(self._testdata, self.loads(DATA1))
def test_load_from_data2(self):
self.assert_is_copy(self._testdata, self.loads(DATA2))
def test_load_from_data3(self):
Reported by Pylint.
Lib/test/test_functools.py
1164 issues
Line: 66
Column: 13
class TestPartial:
def test_basic_examples(self):
p = self.partial(capture, 1, 2, a=10, b=20)
self.assertTrue(callable(p))
self.assertEqual(p(3, 4, b=30, c=40),
((1, 2, 3, 4), dict(a=10, b=30, c=40)))
p = self.partial(map, lambda x: x*10)
self.assertEqual(list(p([1,2,3,4])), [10, 20, 30, 40])
Reported by Pylint.
Line: 67
Column: 9
def test_basic_examples(self):
p = self.partial(capture, 1, 2, a=10, b=20)
self.assertTrue(callable(p))
self.assertEqual(p(3, 4, b=30, c=40),
((1, 2, 3, 4), dict(a=10, b=30, c=40)))
p = self.partial(map, lambda x: x*10)
self.assertEqual(list(p([1,2,3,4])), [10, 20, 30, 40])
Reported by Pylint.
Line: 68
Column: 9
def test_basic_examples(self):
p = self.partial(capture, 1, 2, a=10, b=20)
self.assertTrue(callable(p))
self.assertEqual(p(3, 4, b=30, c=40),
((1, 2, 3, 4), dict(a=10, b=30, c=40)))
p = self.partial(map, lambda x: x*10)
self.assertEqual(list(p([1,2,3,4])), [10, 20, 30, 40])
def test_attributes(self):
Reported by Pylint.
Line: 70
Column: 13
self.assertTrue(callable(p))
self.assertEqual(p(3, 4, b=30, c=40),
((1, 2, 3, 4), dict(a=10, b=30, c=40)))
p = self.partial(map, lambda x: x*10)
self.assertEqual(list(p([1,2,3,4])), [10, 20, 30, 40])
def test_attributes(self):
p = self.partial(capture, 1, 2, a=10, b=20)
# attributes should be readable
Reported by Pylint.
Line: 71
Column: 9
self.assertEqual(p(3, 4, b=30, c=40),
((1, 2, 3, 4), dict(a=10, b=30, c=40)))
p = self.partial(map, lambda x: x*10)
self.assertEqual(list(p([1,2,3,4])), [10, 20, 30, 40])
def test_attributes(self):
p = self.partial(capture, 1, 2, a=10, b=20)
# attributes should be readable
self.assertEqual(p.func, capture)
Reported by Pylint.
Line: 74
Column: 13
self.assertEqual(list(p([1,2,3,4])), [10, 20, 30, 40])
def test_attributes(self):
p = self.partial(capture, 1, 2, a=10, b=20)
# attributes should be readable
self.assertEqual(p.func, capture)
self.assertEqual(p.args, (1, 2))
self.assertEqual(p.keywords, dict(a=10, b=20))
Reported by Pylint.
Line: 76
Column: 9
def test_attributes(self):
p = self.partial(capture, 1, 2, a=10, b=20)
# attributes should be readable
self.assertEqual(p.func, capture)
self.assertEqual(p.args, (1, 2))
self.assertEqual(p.keywords, dict(a=10, b=20))
def test_argument_checking(self):
self.assertRaises(TypeError, self.partial) # need at least a func arg
Reported by Pylint.
Line: 77
Column: 9
p = self.partial(capture, 1, 2, a=10, b=20)
# attributes should be readable
self.assertEqual(p.func, capture)
self.assertEqual(p.args, (1, 2))
self.assertEqual(p.keywords, dict(a=10, b=20))
def test_argument_checking(self):
self.assertRaises(TypeError, self.partial) # need at least a func arg
try:
Reported by Pylint.
Line: 78
Column: 9
# attributes should be readable
self.assertEqual(p.func, capture)
self.assertEqual(p.args, (1, 2))
self.assertEqual(p.keywords, dict(a=10, b=20))
def test_argument_checking(self):
self.assertRaises(TypeError, self.partial) # need at least a func arg
try:
self.partial(2)()
Reported by Pylint.
Line: 81
Column: 9
self.assertEqual(p.keywords, dict(a=10, b=20))
def test_argument_checking(self):
self.assertRaises(TypeError, self.partial) # need at least a func arg
try:
self.partial(2)()
except TypeError:
pass
else:
Reported by Pylint.
Lib/test/test_array.py
1106 issues
Line: 205
Column: 9
# minitemsize: the minimum guaranteed itemsize
def assertEntryEqual(self, entry1, entry2):
self.assertEqual(entry1, entry2)
def badtypecode(self):
# Return a typecode that is different from our own
return typecodes[(typecodes.index(self.typecode)+1) % len(typecodes)]
Reported by Pylint.
Line: 209
Column: 43
def badtypecode(self):
# Return a typecode that is different from our own
return typecodes[(typecodes.index(self.typecode)+1) % len(typecodes)]
def test_constructor(self):
a = array.array(self.typecode)
self.assertEqual(a.typecode, self.typecode)
self.assertGreaterEqual(a.itemsize, self.minitemsize)
Reported by Pylint.
Line: 212
Column: 25
return typecodes[(typecodes.index(self.typecode)+1) % len(typecodes)]
def test_constructor(self):
a = array.array(self.typecode)
self.assertEqual(a.typecode, self.typecode)
self.assertGreaterEqual(a.itemsize, self.minitemsize)
self.assertRaises(TypeError, array.array, self.typecode, None)
def test_len(self):
Reported by Pylint.
Line: 213
Column: 38
def test_constructor(self):
a = array.array(self.typecode)
self.assertEqual(a.typecode, self.typecode)
self.assertGreaterEqual(a.itemsize, self.minitemsize)
self.assertRaises(TypeError, array.array, self.typecode, None)
def test_len(self):
a = array.array(self.typecode)
Reported by Pylint.
Line: 213
Column: 9
def test_constructor(self):
a = array.array(self.typecode)
self.assertEqual(a.typecode, self.typecode)
self.assertGreaterEqual(a.itemsize, self.minitemsize)
self.assertRaises(TypeError, array.array, self.typecode, None)
def test_len(self):
a = array.array(self.typecode)
Reported by Pylint.
Line: 214
Column: 9
def test_constructor(self):
a = array.array(self.typecode)
self.assertEqual(a.typecode, self.typecode)
self.assertGreaterEqual(a.itemsize, self.minitemsize)
self.assertRaises(TypeError, array.array, self.typecode, None)
def test_len(self):
a = array.array(self.typecode)
a.append(self.example[0])
Reported by Pylint.
Line: 214
Column: 45
def test_constructor(self):
a = array.array(self.typecode)
self.assertEqual(a.typecode, self.typecode)
self.assertGreaterEqual(a.itemsize, self.minitemsize)
self.assertRaises(TypeError, array.array, self.typecode, None)
def test_len(self):
a = array.array(self.typecode)
a.append(self.example[0])
Reported by Pylint.
Line: 215
Column: 9
a = array.array(self.typecode)
self.assertEqual(a.typecode, self.typecode)
self.assertGreaterEqual(a.itemsize, self.minitemsize)
self.assertRaises(TypeError, array.array, self.typecode, None)
def test_len(self):
a = array.array(self.typecode)
a.append(self.example[0])
self.assertEqual(len(a), 1)
Reported by Pylint.
Line: 215
Column: 51
a = array.array(self.typecode)
self.assertEqual(a.typecode, self.typecode)
self.assertGreaterEqual(a.itemsize, self.minitemsize)
self.assertRaises(TypeError, array.array, self.typecode, None)
def test_len(self):
a = array.array(self.typecode)
a.append(self.example[0])
self.assertEqual(len(a), 1)
Reported by Pylint.
Line: 218
Column: 25
self.assertRaises(TypeError, array.array, self.typecode, None)
def test_len(self):
a = array.array(self.typecode)
a.append(self.example[0])
self.assertEqual(len(a), 1)
a = array.array(self.typecode, self.example)
self.assertEqual(len(a), len(self.example))
Reported by Pylint.
Lib/test/test_email/test_email.py
1080 issues
Line: 4223
Column: 49
def _msgobj(self, filename):
with openfile(filename, 'rb') as fp:
data = fp.read()
data = self.normalize_linesep_regex.sub(self.blinesep, data)
msg = email.message_from_bytes(data)
return msg, data
def _idempotent(self, msg, data, unixfrom=False):
b = BytesIO()
Reported by Pylint.
Line: 4223
Column: 16
def _msgobj(self, filename):
with openfile(filename, 'rb') as fp:
data = fp.read()
data = self.normalize_linesep_regex.sub(self.blinesep, data)
msg = email.message_from_bytes(data)
return msg, data
def _idempotent(self, msg, data, unixfrom=False):
b = BytesIO()
Reported by Pylint.
Line: 4230
Column: 51
def _idempotent(self, msg, data, unixfrom=False):
b = BytesIO()
g = email.generator.BytesGenerator(b, maxheaderlen=0)
g.flatten(msg, unixfrom=unixfrom, linesep=self.linesep)
self.assertEqual(data, b.getvalue())
class TestBytesGeneratorIdempotentNL(BaseTestBytesGeneratorIdempotent,
TestIdempotent):
Reported by Pylint.
Line: 4231
Column: 9
b = BytesIO()
g = email.generator.BytesGenerator(b, maxheaderlen=0)
g.flatten(msg, unixfrom=unixfrom, linesep=self.linesep)
self.assertEqual(data, b.getvalue())
class TestBytesGeneratorIdempotentNL(BaseTestBytesGeneratorIdempotent,
TestIdempotent):
linesep = '\n'
Reported by Pylint.
Line: 46
Column: 1
# These imports are documented to work, but we are testing them using a
# different path, so we import them here just to make sure they are importable.
from email.parser import FeedParser, BytesFeedParser
NL = '\n'
EMPTYSTRING = ''
SPACE = ' '
Reported by Pylint.
Line: 212
Column: 3
msg.as_string()
self.assertEqual(msg.items()[0][1][:33],
'multipart/form-data; boundary="==')
# XXX: there ought to be tests of the uniqueness of the boundary, too.
def test_message_rfc822_only(self):
# Issue 7970: message/rfc822 not in multipart parsed by
# HeaderParser caused an exception when flattened.
with openfile('msg_46.txt', encoding="utf-8") as fp:
Reported by Pylint.
Line: 421
Column: 3
eq(msg.get_param('foo', header='x-header'), '')
eq(msg.get_param('bar', header='x-header'), 'one')
eq(msg.get_param('baz', header='x-header'), 'two')
# XXX: We are not RFC-2045 compliant! We cannot parse:
# msg["Content-Type"] = 'text/plain; weird="hey; dolly? [you] @ <\\"home\\">?"'
# msg.get_param("weird")
# yet.
# test_headerregistry.TestContentTypeHeader.spaces_around_semis
Reported by Pylint.
Line: 670
Column: 9
msg = Message()
msg['content-type'] = 'text/plain; charset="utf-8"'
msg['content-transfer-encoding'] = '8bit'
msg._payload = x
self.assertEqual(msg.get_payload(decode=True), x)
# Issue 1078919
def test_ascii_add_header(self):
msg = Message()
Reported by Pylint.
Line: 1180
Column: 3
sfp = StringIO()
g = Generator(sfp)
g.flatten(msg)
# XXX the space after the header should not be there.
eq(sfp.getvalue(), """\
From: test@dom.ain
References:\x20
thisverylongheaderhas;semicolons;and,commas,butthey;arenotlegal;fold,points
Reported by Pylint.
Line: 1354
Column: 3
msg['Received-1'] = Header(h, header_name='Received-1',
continuation_ws='\t')
msg['Received-2'] = h
# XXX The space after the ':' should not be there.
self.ndiffAssertEqual(msg.as_string(maxheaderlen=78), """\
Received-1:\x20
<15975.17901.207240.414604@sgigritzmann1.mathematik.tu-muenchen.de> (David
Bremner's message of \"Thu, 6 Mar 2003 13:58:21 +0100\")
Received-2:\x20
Reported by Pylint.
Lib/test/test_asyncio/test_tasks.py
1079 issues
Line: 13
Column: 1
import re
import sys
import textwrap
import traceback
import types
import unittest
import weakref
from unittest import mock
Reported by Pylint.
Line: 100
Column: 16
Future = None
def new_task(self, loop, coro, name='TestTask'):
return self.__class__.Task(coro, loop=loop, name=name)
def new_future(self, loop):
return self.__class__.Future(loop=loop)
def setUp(self):
Reported by Pylint.
Line: 103
Column: 16
return self.__class__.Task(coro, loop=loop, name=name)
def new_future(self, loop):
return self.__class__.Future(loop=loop)
def setUp(self):
super().setUp()
self.loop = self.new_test_loop()
self.loop.set_task_factory(self.new_task)
Reported by Pylint.
Line: 106
Column: 9
return self.__class__.Future(loop=loop)
def setUp(self):
super().setUp()
self.loop = self.new_test_loop()
self.loop.set_task_factory(self.new_task)
self.loop.create_future = lambda: self.new_future(self.loop)
def test_task_cancel_message_getter(self):
Reported by Pylint.
Line: 107
Column: 21
def setUp(self):
super().setUp()
self.loop = self.new_test_loop()
self.loop.set_task_factory(self.new_task)
self.loop.create_future = lambda: self.new_future(self.loop)
def test_task_cancel_message_getter(self):
async def coro():
Reported by Pylint.
Line: 115
Column: 9
async def coro():
pass
t = self.new_task(self.loop, coro())
self.assertTrue(hasattr(t, '_cancel_message'))
self.assertEqual(t._cancel_message, None)
t.cancel('my message')
self.assertEqual(t._cancel_message, 'my message')
Reported by Pylint.
Line: 116
Column: 9
pass
t = self.new_task(self.loop, coro())
self.assertTrue(hasattr(t, '_cancel_message'))
self.assertEqual(t._cancel_message, None)
t.cancel('my message')
self.assertEqual(t._cancel_message, 'my message')
with self.assertRaises(asyncio.CancelledError):
Reported by Pylint.
Line: 119
Column: 9
self.assertEqual(t._cancel_message, None)
t.cancel('my message')
self.assertEqual(t._cancel_message, 'my message')
with self.assertRaises(asyncio.CancelledError):
self.loop.run_until_complete(t)
def test_task_cancel_message_setter(self):
Reported by Pylint.
Line: 121
Column: 14
t.cancel('my message')
self.assertEqual(t._cancel_message, 'my message')
with self.assertRaises(asyncio.CancelledError):
self.loop.run_until_complete(t)
def test_task_cancel_message_setter(self):
async def coro():
pass
Reported by Pylint.
Line: 130
Column: 9
t = self.new_task(self.loop, coro())
t.cancel('my message')
t._cancel_message = 'my new message'
self.assertEqual(t._cancel_message, 'my new message')
with self.assertRaises(asyncio.CancelledError):
self.loop.run_until_complete(t)
def test_task_del_collect(self):
Reported by Pylint.
Lib/test/test_buffer.py
979 issues
Line: 1443
Column: 13
x = nd[()]; self.assertEqual(x, 1)
x = nd[...]; self.assertEqual(x.tolist(), nd.tolist())
x = mv[()]; self.assertEqual(x, 1)
x = mv[...]; self.assertEqual(x.tolist(), nd.tolist())
self.assertRaises(TypeError, nd.__getitem__, 0)
self.assertRaises(TypeError, mv.__getitem__, 0)
self.assertRaises(TypeError, nd.__setitem__, 0, 8)
Reported by Pylint.
Line: 1444
Column: 13
x = nd[...]; self.assertEqual(x.tolist(), nd.tolist())
x = mv[()]; self.assertEqual(x, 1)
x = mv[...]; self.assertEqual(x.tolist(), nd.tolist())
self.assertRaises(TypeError, nd.__getitem__, 0)
self.assertRaises(TypeError, mv.__getitem__, 0)
self.assertRaises(TypeError, nd.__setitem__, 0, 8)
self.assertRaises(TypeError, mv.__setitem__, 0, 8)
Reported by Pylint.
Line: 1455
Column: 9
self.assertEqual(mv.tolist(), 1)
nd[()] = 9; self.assertEqual(nd.tolist(), 9)
mv[()] = 9; self.assertEqual(mv.tolist(), 9)
nd[...] = 5; self.assertEqual(nd.tolist(), 5)
mv[...] = 5; self.assertEqual(mv.tolist(), 5)
def test_ndarray_index_null_strides(self):
Reported by Pylint.
Line: 1458
Column: 9
mv[()] = 9; self.assertEqual(mv.tolist(), 9)
nd[...] = 5; self.assertEqual(nd.tolist(), 5)
mv[...] = 5; self.assertEqual(mv.tolist(), 5)
def test_ndarray_index_null_strides(self):
ex = ndarray(list(range(2*4)), shape=[2, 4], flags=ND_WRITABLE)
nd = ndarray(ex, getbuf=PyBUF_CONTIG)
Reported by Pylint.
Line: 2902
Column: 26
# ndim = 0
ex = ndarray(12.5, shape=[], format='d')
m = memoryview(ex)
self.assertEqual(m[()], 12.5)
self.assertEqual(m[...], m)
self.assertEqual(m[...], ex)
self.assertRaises(TypeError, m.__getitem__, 0)
ex = ndarray((1,2,3), shape=[], format='iii')
Reported by Pylint.
Line: 2903
Column: 26
ex = ndarray(12.5, shape=[], format='d')
m = memoryview(ex)
self.assertEqual(m[()], 12.5)
self.assertEqual(m[...], m)
self.assertEqual(m[...], ex)
self.assertRaises(TypeError, m.__getitem__, 0)
ex = ndarray((1,2,3), shape=[], format='iii')
m = memoryview(ex)
Reported by Pylint.
Line: 2904
Column: 26
m = memoryview(ex)
self.assertEqual(m[()], 12.5)
self.assertEqual(m[...], m)
self.assertEqual(m[...], ex)
self.assertRaises(TypeError, m.__getitem__, 0)
ex = ndarray((1,2,3), shape=[], format='iii')
m = memoryview(ex)
self.assertRaises(NotImplementedError, m.__getitem__, ())
Reported by Pylint.
Line: 2927
Column: 26
ex = ndarray(list(range(12)), shape=[3,4], flags=ND_WRITABLE)
m = memoryview(ex)
self.assertEqual(m[0, 0], 0)
self.assertEqual(m[2, 0], 8)
self.assertEqual(m[2, 3], 11)
self.assertEqual(m[-1, -1], 11)
self.assertEqual(m[-3, -4], 0)
Reported by Pylint.
Line: 2928
Column: 26
m = memoryview(ex)
self.assertEqual(m[0, 0], 0)
self.assertEqual(m[2, 0], 8)
self.assertEqual(m[2, 3], 11)
self.assertEqual(m[-1, -1], 11)
self.assertEqual(m[-3, -4], 0)
# out of bounds
Reported by Pylint.
Line: 2929
Column: 26
self.assertEqual(m[0, 0], 0)
self.assertEqual(m[2, 0], 8)
self.assertEqual(m[2, 3], 11)
self.assertEqual(m[-1, -1], 11)
self.assertEqual(m[-3, -4], 0)
# out of bounds
for index in (3, -4):
Reported by Pylint.