The following issues were found
Lib/test/future_test2.py
8 issues
Line: 3
Column: 39
"""This is a test"""
from __future__ import nested_scopes; import site
def f(x):
def g(y):
return x + y
return g
Reported by Pylint.
Line: 3
Column: 39
"""This is a test"""
from __future__ import nested_scopes; import site
def f(x):
def g(y):
return x + y
return g
Reported by Pylint.
Line: 5
Column: 1
from __future__ import nested_scopes; import site
def f(x):
def g(y):
return x + y
return g
result = f(2)(4)
Reported by Pylint.
Line: 5
Column: 1
from __future__ import nested_scopes; import site
def f(x):
def g(y):
return x + y
return g
result = f(2)(4)
Reported by Pylint.
Line: 5
Column: 1
from __future__ import nested_scopes; import site
def f(x):
def g(y):
return x + y
return g
result = f(2)(4)
Reported by Pylint.
Line: 6
Column: 5
from __future__ import nested_scopes; import site
def f(x):
def g(y):
return x + y
return g
result = f(2)(4)
Reported by Pylint.
Line: 6
Column: 5
from __future__ import nested_scopes; import site
def f(x):
def g(y):
return x + y
return g
result = f(2)(4)
Reported by Pylint.
Line: 10
Column: 1
return x + y
return g
result = f(2)(4)
Reported by Pylint.
Lib/lib2to3/pygram.py
8 issues
Line: 10
Column: 1
import os
# Local imports
from .pgen2 import token
from .pgen2 import driver
from . import pytree
# The grammar file
_GRAMMAR_FILE = os.path.join(os.path.dirname(__file__), "Grammar.txt")
Reported by Pylint.
Line: 11
Column: 1
# Local imports
from .pgen2 import token
from .pgen2 import driver
from . import pytree
# The grammar file
_GRAMMAR_FILE = os.path.join(os.path.dirname(__file__), "Grammar.txt")
_PATTERN_GRAMMAR_FILE = os.path.join(os.path.dirname(__file__),
Reported by Pylint.
Line: 12
Column: 1
# Local imports
from .pgen2 import token
from .pgen2 import driver
from . import pytree
# The grammar file
_GRAMMAR_FILE = os.path.join(os.path.dirname(__file__), "Grammar.txt")
_PATTERN_GRAMMAR_FILE = os.path.join(os.path.dirname(__file__),
"PatternGrammar.txt")
Reported by Pylint.
Line: 10
Column: 1
import os
# Local imports
from .pgen2 import token
from .pgen2 import driver
from . import pytree
# The grammar file
_GRAMMAR_FILE = os.path.join(os.path.dirname(__file__), "Grammar.txt")
Reported by Pylint.
Line: 12
Column: 1
# Local imports
from .pgen2 import token
from .pgen2 import driver
from . import pytree
# The grammar file
_GRAMMAR_FILE = os.path.join(os.path.dirname(__file__), "Grammar.txt")
_PATTERN_GRAMMAR_FILE = os.path.join(os.path.dirname(__file__),
"PatternGrammar.txt")
Reported by Pylint.
Line: 20
Column: 1
"PatternGrammar.txt")
class Symbols(object):
def __init__(self, grammar):
"""Initializer.
Creates an attribute for each grammar symbol (nonterminal),
Reported by Pylint.
Line: 20
Column: 1
"PatternGrammar.txt")
class Symbols(object):
def __init__(self, grammar):
"""Initializer.
Creates an attribute for each grammar symbol (nonterminal),
Reported by Pylint.
Line: 20
Column: 1
"PatternGrammar.txt")
class Symbols(object):
def __init__(self, grammar):
"""Initializer.
Creates an attribute for each grammar symbol (nonterminal),
Reported by Pylint.
Lib/test/leakers/test_ctypes.py
8 issues
Line: 10
Column: 5
def leak_inner():
class POINT(Structure):
_fields_ = [("x", c_int)]
class RECT(Structure):
_fields_ = [("a", POINTER(POINT))]
def leak():
leak_inner()
gc.collect()
Reported by Pylint.
Line: 1
Column: 1
# Taken from Lib/ctypes/test/test_keeprefs.py, PointerToStructure.test().
from ctypes import Structure, c_int, POINTER
import gc
def leak_inner():
class POINT(Structure):
_fields_ = [("x", c_int)]
Reported by Pylint.
Line: 7
Column: 1
from ctypes import Structure, c_int, POINTER
import gc
def leak_inner():
class POINT(Structure):
_fields_ = [("x", c_int)]
class RECT(Structure):
_fields_ = [("a", POINTER(POINT))]
Reported by Pylint.
Line: 8
Column: 5
import gc
def leak_inner():
class POINT(Structure):
_fields_ = [("x", c_int)]
class RECT(Structure):
_fields_ = [("a", POINTER(POINT))]
def leak():
Reported by Pylint.
Line: 8
Column: 5
import gc
def leak_inner():
class POINT(Structure):
_fields_ = [("x", c_int)]
class RECT(Structure):
_fields_ = [("a", POINTER(POINT))]
def leak():
Reported by Pylint.
Line: 10
Column: 5
def leak_inner():
class POINT(Structure):
_fields_ = [("x", c_int)]
class RECT(Structure):
_fields_ = [("a", POINTER(POINT))]
def leak():
leak_inner()
gc.collect()
Reported by Pylint.
Line: 10
Column: 5
def leak_inner():
class POINT(Structure):
_fields_ = [("x", c_int)]
class RECT(Structure):
_fields_ = [("a", POINTER(POINT))]
def leak():
leak_inner()
gc.collect()
Reported by Pylint.
Line: 13
Column: 1
class RECT(Structure):
_fields_ = [("a", POINTER(POINT))]
def leak():
leak_inner()
gc.collect()
Reported by Pylint.
Lib/test/test_json/__init__.py
8 issues
Line: 1
Column: 1
import os
import json
import doctest
import unittest
from test import support
from test.support import import_helper
Reported by Pylint.
Line: 17
Column: 1
cjson.JSONDecodeError = cjson.decoder.JSONDecodeError = json.JSONDecodeError
# create two base classes that will be used by the other tests
class PyTest(unittest.TestCase):
json = pyjson
loads = staticmethod(pyjson.loads)
dumps = staticmethod(pyjson.dumps)
JSONDecodeError = staticmethod(pyjson.JSONDecodeError)
Reported by Pylint.
Line: 24
Column: 1
JSONDecodeError = staticmethod(pyjson.JSONDecodeError)
@unittest.skipUnless(cjson, 'requires _json')
class CTest(unittest.TestCase):
if cjson is not None:
json = cjson
loads = staticmethod(cjson.loads)
dumps = staticmethod(cjson.dumps)
JSONDecodeError = staticmethod(cjson.JSONDecodeError)
Reported by Pylint.
Line: 32
Column: 1
JSONDecodeError = staticmethod(cjson.JSONDecodeError)
# test PyTest and CTest checking if the functions come from the right module
class TestPyTest(PyTest):
def test_pyjson(self):
self.assertEqual(self.json.scanner.make_scanner.__module__,
'json.scanner')
self.assertEqual(self.json.decoder.scanstring.__module__,
'json.decoder')
Reported by Pylint.
Line: 33
Column: 5
# test PyTest and CTest checking if the functions come from the right module
class TestPyTest(PyTest):
def test_pyjson(self):
self.assertEqual(self.json.scanner.make_scanner.__module__,
'json.scanner')
self.assertEqual(self.json.decoder.scanstring.__module__,
'json.decoder')
self.assertEqual(self.json.encoder.encode_basestring_ascii.__module__,
Reported by Pylint.
Line: 41
Column: 1
self.assertEqual(self.json.encoder.encode_basestring_ascii.__module__,
'json.encoder')
class TestCTest(CTest):
def test_cjson(self):
self.assertEqual(self.json.scanner.make_scanner.__module__, '_json')
self.assertEqual(self.json.decoder.scanstring.__module__, '_json')
self.assertEqual(self.json.encoder.c_make_encoder.__module__, '_json')
self.assertEqual(self.json.encoder.encode_basestring_ascii.__module__,
Reported by Pylint.
Line: 42
Column: 5
'json.encoder')
class TestCTest(CTest):
def test_cjson(self):
self.assertEqual(self.json.scanner.make_scanner.__module__, '_json')
self.assertEqual(self.json.decoder.scanstring.__module__, '_json')
self.assertEqual(self.json.encoder.c_make_encoder.__module__, '_json')
self.assertEqual(self.json.encoder.encode_basestring_ascii.__module__,
'_json')
Reported by Pylint.
Line: 50
Column: 1
'_json')
def load_tests(loader, _, pattern):
suite = unittest.TestSuite()
for mod in (json, json.encoder, json.decoder):
suite.addTest(doctest.DocTestSuite(mod))
suite.addTest(TestPyTest('test_pyjson'))
suite.addTest(TestCTest('test_cjson'))
Reported by Pylint.
Lib/test/test_abstract_numbers.py
7 issues
Line: 34
Column: 3
self.assertTrue(issubclass(complex, Complex))
c1, c2 = complex(3, 2), complex(4,1)
# XXX: This is not ideal, but see the comment in math_trunc().
self.assertRaises(TypeError, math.trunc, c1)
self.assertRaises(TypeError, operator.mod, c1, c2)
self.assertRaises(TypeError, divmod, c1, c2)
self.assertRaises(TypeError, operator.floordiv, c1, c2)
self.assertRaises(TypeError, float, c1)
Reported by Pylint.
Line: 8
Column: 1
import unittest
from numbers import Complex, Real, Rational, Integral
class TestNumbers(unittest.TestCase):
def test_int(self):
self.assertTrue(issubclass(int, Integral))
self.assertTrue(issubclass(int, Complex))
self.assertEqual(7, int(7).real)
Reported by Pylint.
Line: 9
Column: 5
from numbers import Complex, Real, Rational, Integral
class TestNumbers(unittest.TestCase):
def test_int(self):
self.assertTrue(issubclass(int, Integral))
self.assertTrue(issubclass(int, Complex))
self.assertEqual(7, int(7).real)
self.assertEqual(0, int(7).imag)
Reported by Pylint.
Line: 20
Column: 5
self.assertEqual(7, int(7).numerator)
self.assertEqual(1, int(7).denominator)
def test_float(self):
self.assertFalse(issubclass(float, Rational))
self.assertTrue(issubclass(float, Real))
self.assertEqual(7.3, float(7.3).real)
self.assertEqual(0, float(7.3).imag)
Reported by Pylint.
Line: 29
Column: 5
self.assertEqual(7.3, float(7.3).conjugate())
self.assertEqual(-7.3, float(-7.3).conjugate())
def test_complex(self):
self.assertFalse(issubclass(complex, Real))
self.assertTrue(issubclass(complex, Complex))
c1, c2 = complex(3, 2), complex(4,1)
# XXX: This is not ideal, but see the comment in math_trunc().
Reported by Pylint.
Line: 33
Column: 13
self.assertFalse(issubclass(complex, Real))
self.assertTrue(issubclass(complex, Complex))
c1, c2 = complex(3, 2), complex(4,1)
# XXX: This is not ideal, but see the comment in math_trunc().
self.assertRaises(TypeError, math.trunc, c1)
self.assertRaises(TypeError, operator.mod, c1, c2)
self.assertRaises(TypeError, divmod, c1, c2)
self.assertRaises(TypeError, operator.floordiv, c1, c2)
Reported by Pylint.
Line: 33
Column: 9
self.assertFalse(issubclass(complex, Real))
self.assertTrue(issubclass(complex, Complex))
c1, c2 = complex(3, 2), complex(4,1)
# XXX: This is not ideal, but see the comment in math_trunc().
self.assertRaises(TypeError, math.trunc, c1)
self.assertRaises(TypeError, operator.mod, c1, c2)
self.assertRaises(TypeError, divmod, c1, c2)
self.assertRaises(TypeError, operator.floordiv, c1, c2)
Reported by Pylint.
Lib/linecache.py
7 issues
Line: 68
Column: 22
if len(entry) == 1:
# lazy cache entry, leave it lazy.
continue
size, mtime, lines, fullname = entry
if mtime is None:
continue # no-op for files loaded via a __loader__
try:
stat = os.stat(fullname)
except OSError:
Reported by Pylint.
Line: 63
Column: 9
else:
return
for filename in filenames:
entry = cache[filename]
if len(entry) == 1:
# lazy cache entry, leave it lazy.
continue
size, mtime, lines, fullname = entry
Reported by Pylint.
Line: 80
Column: 1
cache.pop(filename, None)
def updatecache(filename, module_globals=None):
"""Update a cache entry and return its list of lines.
If something's wrong, print a message, discard the cache entry,
and return an empty list."""
if filename in cache:
Reported by Pylint.
Line: 80
Column: 1
cache.pop(filename, None)
def updatecache(filename, module_globals=None):
"""Update a cache entry and return its list of lines.
If something's wrong, print a message, discard the cache entry,
and return an empty list."""
if filename in cache:
Reported by Pylint.
Line: 136
Column: 41
else:
return []
try:
with tokenize.open(fullname) as fp:
lines = fp.readlines()
except OSError:
return []
if lines and not lines[-1].endswith('\n'):
lines[-1] += '\n'
Reported by Pylint.
Line: 161
Column: 9
filename, and the filename must not be already cached.
"""
if filename in cache:
if len(cache[filename]) == 1:
return True
else:
return False
if not filename or (filename.startswith('<') and filename.endswith('>')):
return False
Reported by Pylint.
Line: 161
Column: 9
filename, and the filename must not be already cached.
"""
if filename in cache:
if len(cache[filename]) == 1:
return True
else:
return False
if not filename or (filename.startswith('<') and filename.endswith('>')):
return False
Reported by Pylint.
Lib/test/test_codecencodings_iso2022.py
7 issues
Line: 1
Column: 1
# Codec encoding tests for ISO 2022 encodings.
from test import multibytecodec_support
import unittest
COMMON_CODEC_TESTS = (
# invalid bytes
(b'ab\xFFcd', 'replace', 'ab\uFFFDcd'),
(b'ab\x1Bdef', 'replace', 'ab\x1Bdef'),
Reported by Pylint.
Line: 13
Column: 1
(b'ab\x1B$def', 'replace', 'ab\uFFFD'),
)
class Test_ISO2022_JP(multibytecodec_support.TestBase, unittest.TestCase):
encoding = 'iso2022_jp'
tstring = multibytecodec_support.load_teststring('iso2022_jp')
codectests = COMMON_CODEC_TESTS + (
(b'ab\x1BNdef', 'replace', 'ab\x1BNdef'),
)
Reported by Pylint.
Line: 13
Column: 1
(b'ab\x1B$def', 'replace', 'ab\uFFFD'),
)
class Test_ISO2022_JP(multibytecodec_support.TestBase, unittest.TestCase):
encoding = 'iso2022_jp'
tstring = multibytecodec_support.load_teststring('iso2022_jp')
codectests = COMMON_CODEC_TESTS + (
(b'ab\x1BNdef', 'replace', 'ab\x1BNdef'),
)
Reported by Pylint.
Line: 20
Column: 1
(b'ab\x1BNdef', 'replace', 'ab\x1BNdef'),
)
class Test_ISO2022_JP2(multibytecodec_support.TestBase, unittest.TestCase):
encoding = 'iso2022_jp_2'
tstring = multibytecodec_support.load_teststring('iso2022_jp')
codectests = COMMON_CODEC_TESTS + (
(b'ab\x1BNdef', 'replace', 'abdef'),
)
Reported by Pylint.
Line: 20
Column: 1
(b'ab\x1BNdef', 'replace', 'ab\x1BNdef'),
)
class Test_ISO2022_JP2(multibytecodec_support.TestBase, unittest.TestCase):
encoding = 'iso2022_jp_2'
tstring = multibytecodec_support.load_teststring('iso2022_jp')
codectests = COMMON_CODEC_TESTS + (
(b'ab\x1BNdef', 'replace', 'abdef'),
)
Reported by Pylint.
Line: 27
Column: 1
(b'ab\x1BNdef', 'replace', 'abdef'),
)
class Test_ISO2022_KR(multibytecodec_support.TestBase, unittest.TestCase):
encoding = 'iso2022_kr'
tstring = multibytecodec_support.load_teststring('iso2022_kr')
codectests = COMMON_CODEC_TESTS + (
(b'ab\x1BNdef', 'replace', 'ab\x1BNdef'),
)
Reported by Pylint.
Line: 27
Column: 1
(b'ab\x1BNdef', 'replace', 'abdef'),
)
class Test_ISO2022_KR(multibytecodec_support.TestBase, unittest.TestCase):
encoding = 'iso2022_kr'
tstring = multibytecodec_support.load_teststring('iso2022_kr')
codectests = COMMON_CODEC_TESTS + (
(b'ab\x1BNdef', 'replace', 'ab\x1BNdef'),
)
Reported by Pylint.
Lib/test/test_importlib/partial/pool_in_threads.py
7 issues
Line: 11
Column: 12
try:
with multiprocessing.Pool(1):
pass
except Exception:
traceback.print_exc()
os._exit(1)
def main():
Reported by Pylint.
Line: 13
Column: 9
pass
except Exception:
traceback.print_exc()
os._exit(1)
def main():
threads = []
for i in range(20):
Reported by Pylint.
Line: 18
Column: 9
def main():
threads = []
for i in range(20):
threads.append(threading.Thread(target=t))
for thread in threads:
thread.start()
for thread in threads:
thread.join()
Reported by Pylint.
Line: 1
Column: 1
import multiprocessing
import os
import threading
import traceback
def t():
try:
with multiprocessing.Pool(1):
Reported by Pylint.
Line: 7
Column: 1
import traceback
def t():
try:
with multiprocessing.Pool(1):
pass
except Exception:
traceback.print_exc()
Reported by Pylint.
Line: 7
Column: 1
import traceback
def t():
try:
with multiprocessing.Pool(1):
pass
except Exception:
traceback.print_exc()
Reported by Pylint.
Line: 16
Column: 1
os._exit(1)
def main():
threads = []
for i in range(20):
threads.append(threading.Thread(target=t))
for thread in threads:
thread.start()
Reported by Pylint.
Lib/test/test_codecencodings_kr.py
7 issues
Line: 1
Column: 1
#
# test_codecencodings_kr.py
# Codec encoding tests for ROK encodings.
#
from test import multibytecodec_support
import unittest
class Test_CP949(multibytecodec_support.TestBase, unittest.TestCase):
Reported by Pylint.
Line: 9
Column: 1
from test import multibytecodec_support
import unittest
class Test_CP949(multibytecodec_support.TestBase, unittest.TestCase):
encoding = 'cp949'
tstring = multibytecodec_support.load_teststring('cp949')
codectests = (
# invalid bytes
(b"abc\x80\x80\xc1\xc4", "strict", None),
Reported by Pylint.
Line: 9
Column: 1
from test import multibytecodec_support
import unittest
class Test_CP949(multibytecodec_support.TestBase, unittest.TestCase):
encoding = 'cp949'
tstring = multibytecodec_support.load_teststring('cp949')
codectests = (
# invalid bytes
(b"abc\x80\x80\xc1\xc4", "strict", None),
Reported by Pylint.
Line: 21
Column: 1
(b"abc\x80\x80\xc1\xc4", "ignore", "abc\uc894"),
)
class Test_EUCKR(multibytecodec_support.TestBase, unittest.TestCase):
encoding = 'euc_kr'
tstring = multibytecodec_support.load_teststring('euc_kr')
codectests = (
# invalid bytes
(b"abc\x80\x80\xc1\xc4", "strict", None),
Reported by Pylint.
Line: 21
Column: 1
(b"abc\x80\x80\xc1\xc4", "ignore", "abc\uc894"),
)
class Test_EUCKR(multibytecodec_support.TestBase, unittest.TestCase):
encoding = 'euc_kr'
tstring = multibytecodec_support.load_teststring('euc_kr')
codectests = (
# invalid bytes
(b"abc\x80\x80\xc1\xc4", "strict", None),
Reported by Pylint.
Line: 52
Column: 1
(b"\xc1\xc4", "strict", "\uc894"),
)
class Test_JOHAB(multibytecodec_support.TestBase, unittest.TestCase):
encoding = 'johab'
tstring = multibytecodec_support.load_teststring('johab')
codectests = (
# invalid bytes
(b"abc\x80\x80\xc1\xc4", "strict", None),
Reported by Pylint.
Line: 52
Column: 1
(b"\xc1\xc4", "strict", "\uc894"),
)
class Test_JOHAB(multibytecodec_support.TestBase, unittest.TestCase):
encoding = 'johab'
tstring = multibytecodec_support.load_teststring('johab')
codectests = (
# invalid bytes
(b"abc\x80\x80\xc1\xc4", "strict", None),
Reported by Pylint.
Lib/test/future_test1.py
7 issues
Line: 4
Column: 1
"""This is a test"""
# Import the name nested_scopes twice to trigger SF bug #407394 (regression).
from __future__ import nested_scopes, nested_scopes
def f(x):
def g(y):
return x + y
return g
Reported by Pylint.
Line: 6
Column: 1
# Import the name nested_scopes twice to trigger SF bug #407394 (regression).
from __future__ import nested_scopes, nested_scopes
def f(x):
def g(y):
return x + y
return g
result = f(2)(4)
Reported by Pylint.
Line: 6
Column: 1
# Import the name nested_scopes twice to trigger SF bug #407394 (regression).
from __future__ import nested_scopes, nested_scopes
def f(x):
def g(y):
return x + y
return g
result = f(2)(4)
Reported by Pylint.
Line: 6
Column: 1
# Import the name nested_scopes twice to trigger SF bug #407394 (regression).
from __future__ import nested_scopes, nested_scopes
def f(x):
def g(y):
return x + y
return g
result = f(2)(4)
Reported by Pylint.
Line: 7
Column: 5
from __future__ import nested_scopes, nested_scopes
def f(x):
def g(y):
return x + y
return g
result = f(2)(4)
Reported by Pylint.
Line: 7
Column: 5
from __future__ import nested_scopes, nested_scopes
def f(x):
def g(y):
return x + y
return g
result = f(2)(4)
Reported by Pylint.
Line: 11
Column: 1
return x + y
return g
result = f(2)(4)
Reported by Pylint.