The following issues were found
Lib/xml/sax/xmlreader.py
70 issues
Line: 4
Column: 1
"""An XML Reader is the SAX 2 name for an XML parser. XML Parsers
should be based on this code. """
from . import handler
from ._exceptions import SAXNotSupportedException, SAXNotRecognizedException
# ===== XMLREADER =====
Reported by Pylint.
Line: 6
Column: 1
from . import handler
from ._exceptions import SAXNotSupportedException, SAXNotRecognizedException
# ===== XMLREADER =====
class XMLReader:
Reported by Pylint.
Line: 116
Column: 9
XMLReader.__init__(self)
def parse(self, source):
from . import saxutils
source = saxutils.prepare_input_source(source)
self.prepareParser(source)
file = source.getCharacterStream()
if file is None:
Reported by Pylint.
Line: 38
Column: 33
"Returns the current ContentHandler."
return self._cont_handler
def setContentHandler(self, handler):
"Registers a new object to receive document content events."
self._cont_handler = handler
def getDTDHandler(self):
"Returns the current DTD handler."
Reported by Pylint.
Line: 46
Column: 29
"Returns the current DTD handler."
return self._dtd_handler
def setDTDHandler(self, handler):
"Register an object to receive basic DTD-related events."
self._dtd_handler = handler
def getEntityResolver(self):
"Returns the current EntityResolver."
Reported by Pylint.
Line: 62
Column: 31
"Returns the current ErrorHandler."
return self._err_handler
def setErrorHandler(self, handler):
"Register an object to receive error-message events."
self._err_handler = handler
def setLocale(self, locale):
"""Allow an application to set the locale for errors and warnings.
Reported by Pylint.
Line: 289
Column: 23
def getLength(self):
return len(self._attrs)
def getType(self, name):
return "CDATA"
def getValue(self, name):
return self._attrs[name]
Reported by Pylint.
Line: 342
Column: 5
class AttributesNSImpl(AttributesImpl):
def __init__(self, attrs, qnames):
"""NS-aware implementation.
attrs should be of the form {(ns_uri, lname): value, ...}.
qnames of the form {(ns_uri, lname): qname, ...}."""
self._attrs = attrs
Reported by Pylint.
Line: 34
Column: 5
"Parse an XML document from a system identifier or an InputSource."
raise NotImplementedError("This method must be implemented!")
def getContentHandler(self):
"Returns the current ContentHandler."
return self._cont_handler
def setContentHandler(self, handler):
"Registers a new object to receive document content events."
Reported by Pylint.
Line: 38
Column: 5
"Returns the current ContentHandler."
return self._cont_handler
def setContentHandler(self, handler):
"Registers a new object to receive document content events."
self._cont_handler = handler
def getDTDHandler(self):
"Returns the current DTD handler."
Reported by Pylint.
Lib/functools.py
69 issues
Line: 89
Column: 30
# infinite recursion that could occur when the operator dispatch logic
# detects a NotImplemented result and then calls a reflected method.
def _gt_from_lt(self, other, NotImplemented=NotImplemented):
'Return a > b. Computed by @total_ordering from (not a < b) and (a != b).'
op_result = type(self).__lt__(self, other)
if op_result is NotImplemented:
return op_result
return not op_result and self != other
Reported by Pylint.
Line: 96
Column: 30
return op_result
return not op_result and self != other
def _le_from_lt(self, other, NotImplemented=NotImplemented):
'Return a <= b. Computed by @total_ordering from (a < b) or (a == b).'
op_result = type(self).__lt__(self, other)
if op_result is NotImplemented:
return op_result
return op_result or self == other
Reported by Pylint.
Line: 103
Column: 30
return op_result
return op_result or self == other
def _ge_from_lt(self, other, NotImplemented=NotImplemented):
'Return a >= b. Computed by @total_ordering from (not a < b).'
op_result = type(self).__lt__(self, other)
if op_result is NotImplemented:
return op_result
return not op_result
Reported by Pylint.
Line: 110
Column: 30
return op_result
return not op_result
def _ge_from_le(self, other, NotImplemented=NotImplemented):
'Return a >= b. Computed by @total_ordering from (not a <= b) or (a == b).'
op_result = type(self).__le__(self, other)
if op_result is NotImplemented:
return op_result
return not op_result or self == other
Reported by Pylint.
Line: 117
Column: 30
return op_result
return not op_result or self == other
def _lt_from_le(self, other, NotImplemented=NotImplemented):
'Return a < b. Computed by @total_ordering from (a <= b) and (a != b).'
op_result = type(self).__le__(self, other)
if op_result is NotImplemented:
return op_result
return op_result and self != other
Reported by Pylint.
Line: 124
Column: 30
return op_result
return op_result and self != other
def _gt_from_le(self, other, NotImplemented=NotImplemented):
'Return a > b. Computed by @total_ordering from (not a <= b).'
op_result = type(self).__le__(self, other)
if op_result is NotImplemented:
return op_result
return not op_result
Reported by Pylint.
Line: 131
Column: 30
return op_result
return not op_result
def _lt_from_gt(self, other, NotImplemented=NotImplemented):
'Return a < b. Computed by @total_ordering from (not a > b) and (a != b).'
op_result = type(self).__gt__(self, other)
if op_result is NotImplemented:
return op_result
return not op_result and self != other
Reported by Pylint.
Line: 138
Column: 30
return op_result
return not op_result and self != other
def _ge_from_gt(self, other, NotImplemented=NotImplemented):
'Return a >= b. Computed by @total_ordering from (a > b) or (a == b).'
op_result = type(self).__gt__(self, other)
if op_result is NotImplemented:
return op_result
return op_result or self == other
Reported by Pylint.
Line: 145
Column: 30
return op_result
return op_result or self == other
def _le_from_gt(self, other, NotImplemented=NotImplemented):
'Return a <= b. Computed by @total_ordering from (not a > b).'
op_result = type(self).__gt__(self, other)
if op_result is NotImplemented:
return op_result
return not op_result
Reported by Pylint.
Line: 152
Column: 30
return op_result
return not op_result
def _le_from_ge(self, other, NotImplemented=NotImplemented):
'Return a <= b. Computed by @total_ordering from (not a >= b) or (a == b).'
op_result = type(self).__ge__(self, other)
if op_result is NotImplemented:
return op_result
return not op_result or self == other
Reported by Pylint.
Lib/distutils/command/build_ext.py
69 issues
Line: 213
Column: 26
suffix = 'win32'
else:
# win-amd64
suffix = self.plat_name[4:]
new_lib = os.path.join(sys.exec_prefix, 'PCbuild')
if suffix:
new_lib = os.path.join(new_lib, suffix)
self.library_dirs.append(new_lib)
Reported by Pylint.
Line: 12
Column: 1
import re
import sys
from distutils.core import Command
from distutils.errors import *
from distutils.sysconfig import customize_compiler, get_python_version
from distutils.sysconfig import get_config_h_filename
from distutils.dep_util import newer_group
from distutils.extension import Extension
from distutils.util import get_platform
Reported by Pylint.
Line: 12
Column: 1
import re
import sys
from distutils.core import Command
from distutils.errors import *
from distutils.sysconfig import customize_compiler, get_python_version
from distutils.sysconfig import get_config_h_filename
from distutils.dep_util import newer_group
from distutils.extension import Extension
from distutils.util import get_platform
Reported by Pylint.
Line: 12
Column: 1
import re
import sys
from distutils.core import Command
from distutils.errors import *
from distutils.sysconfig import customize_compiler, get_python_version
from distutils.sysconfig import get_config_h_filename
from distutils.dep_util import newer_group
from distutils.extension import Extension
from distutils.util import get_platform
Reported by Pylint.
Line: 12
Column: 1
import re
import sys
from distutils.core import Command
from distutils.errors import *
from distutils.sysconfig import customize_compiler, get_python_version
from distutils.sysconfig import get_config_h_filename
from distutils.dep_util import newer_group
from distutils.extension import Extension
from distutils.util import get_platform
Reported by Pylint.
Line: 12
Column: 1
import re
import sys
from distutils.core import Command
from distutils.errors import *
from distutils.sysconfig import customize_compiler, get_python_version
from distutils.sysconfig import get_config_h_filename
from distutils.dep_util import newer_group
from distutils.extension import Extension
from distutils.util import get_platform
Reported by Pylint.
Line: 12
Column: 1
import re
import sys
from distutils.core import Command
from distutils.errors import *
from distutils.sysconfig import customize_compiler, get_python_version
from distutils.sysconfig import get_config_h_filename
from distutils.dep_util import newer_group
from distutils.extension import Extension
from distutils.util import get_platform
Reported by Pylint.
Line: 12
Column: 1
import re
import sys
from distutils.core import Command
from distutils.errors import *
from distutils.sysconfig import customize_compiler, get_python_version
from distutils.sysconfig import get_config_h_filename
from distutils.dep_util import newer_group
from distutils.extension import Extension
from distutils.util import get_platform
Reported by Pylint.
Line: 12
Column: 1
import re
import sys
from distutils.core import Command
from distutils.errors import *
from distutils.sysconfig import customize_compiler, get_python_version
from distutils.sysconfig import get_config_h_filename
from distutils.dep_util import newer_group
from distutils.extension import Extension
from distutils.util import get_platform
Reported by Pylint.
Line: 12
Column: 1
import re
import sys
from distutils.core import Command
from distutils.errors import *
from distutils.sysconfig import customize_compiler, get_python_version
from distutils.sysconfig import get_config_h_filename
from distutils.dep_util import newer_group
from distutils.extension import Extension
from distutils.util import get_platform
Reported by Pylint.
Lib/test/test_pyclbr.py
69 issues
Line: 66
Column: 9
# ('<silly>' is to work around an API silliness in __import__)
module = __import__(moduleName, globals(), {}, ['<silly>'])
dict = pyclbr.readmodule_ex(moduleName)
def ismethod(oclass, obj, name):
classdict = oclass.__dict__
if isinstance(obj, MethodType):
# could be a classmethod
Reported by Pylint.
Line: 146
Column: 3
def test_easy(self):
self.checkModule('pyclbr')
# XXX: Metaclasses are not supported
# self.checkModule('ast')
self.checkModule('doctest', ignore=("TestResults", "_SpoofOut",
"DocTestCase", '_DocTestSuite'))
self.checkModule('difflib', ignore=("Match",))
Reported by Pylint.
Line: 176
Column: 18
def F3(): return 1+1
""")
actual = mb._create_tree(m, p, f, source, t, i)
# Create descriptors, linked together, and expected dict.
f0 = mb.Function(m, 'f0', f, 1, end_lineno=5)
f1 = mb._nest_function(f0, 'f1', 2, 4)
f2 = mb._nest_function(f1, 'f2', 3, 3)
Reported by Pylint.
Line: 180
Column: 14
# Create descriptors, linked together, and expected dict.
f0 = mb.Function(m, 'f0', f, 1, end_lineno=5)
f1 = mb._nest_function(f0, 'f1', 2, 4)
f2 = mb._nest_function(f1, 'f2', 3, 3)
c1 = mb._nest_class(f0, 'c1', 5, 5)
C0 = mb.Class(m, 'C0', None, f, 6, end_lineno=14)
F1 = mb._nest_function(C0, 'F1', 8, 10)
C1 = mb._nest_class(C0, 'C1', 11, 14)
Reported by Pylint.
Line: 181
Column: 9
# Create descriptors, linked together, and expected dict.
f0 = mb.Function(m, 'f0', f, 1, end_lineno=5)
f1 = mb._nest_function(f0, 'f1', 2, 4)
f2 = mb._nest_function(f1, 'f2', 3, 3)
c1 = mb._nest_class(f0, 'c1', 5, 5)
C0 = mb.Class(m, 'C0', None, f, 6, end_lineno=14)
F1 = mb._nest_function(C0, 'F1', 8, 10)
C1 = mb._nest_class(C0, 'C1', 11, 14)
C2 = mb._nest_class(C1, 'C2', 12, 14)
Reported by Pylint.
Line: 181
Column: 14
# Create descriptors, linked together, and expected dict.
f0 = mb.Function(m, 'f0', f, 1, end_lineno=5)
f1 = mb._nest_function(f0, 'f1', 2, 4)
f2 = mb._nest_function(f1, 'f2', 3, 3)
c1 = mb._nest_class(f0, 'c1', 5, 5)
C0 = mb.Class(m, 'C0', None, f, 6, end_lineno=14)
F1 = mb._nest_function(C0, 'F1', 8, 10)
C1 = mb._nest_class(C0, 'C1', 11, 14)
C2 = mb._nest_class(C1, 'C2', 12, 14)
Reported by Pylint.
Line: 182
Column: 14
f0 = mb.Function(m, 'f0', f, 1, end_lineno=5)
f1 = mb._nest_function(f0, 'f1', 2, 4)
f2 = mb._nest_function(f1, 'f2', 3, 3)
c1 = mb._nest_class(f0, 'c1', 5, 5)
C0 = mb.Class(m, 'C0', None, f, 6, end_lineno=14)
F1 = mb._nest_function(C0, 'F1', 8, 10)
C1 = mb._nest_class(C0, 'C1', 11, 14)
C2 = mb._nest_class(C1, 'C2', 12, 14)
F3 = mb._nest_function(C2, 'F3', 14, 14)
Reported by Pylint.
Line: 182
Column: 9
f0 = mb.Function(m, 'f0', f, 1, end_lineno=5)
f1 = mb._nest_function(f0, 'f1', 2, 4)
f2 = mb._nest_function(f1, 'f2', 3, 3)
c1 = mb._nest_class(f0, 'c1', 5, 5)
C0 = mb.Class(m, 'C0', None, f, 6, end_lineno=14)
F1 = mb._nest_function(C0, 'F1', 8, 10)
C1 = mb._nest_class(C0, 'C1', 11, 14)
C2 = mb._nest_class(C1, 'C2', 12, 14)
F3 = mb._nest_function(C2, 'F3', 14, 14)
Reported by Pylint.
Line: 184
Column: 14
f2 = mb._nest_function(f1, 'f2', 3, 3)
c1 = mb._nest_class(f0, 'c1', 5, 5)
C0 = mb.Class(m, 'C0', None, f, 6, end_lineno=14)
F1 = mb._nest_function(C0, 'F1', 8, 10)
C1 = mb._nest_class(C0, 'C1', 11, 14)
C2 = mb._nest_class(C1, 'C2', 12, 14)
F3 = mb._nest_function(C2, 'F3', 14, 14)
expected = {'f0':f0, 'C0':C0}
Reported by Pylint.
Line: 184
Column: 9
f2 = mb._nest_function(f1, 'f2', 3, 3)
c1 = mb._nest_class(f0, 'c1', 5, 5)
C0 = mb.Class(m, 'C0', None, f, 6, end_lineno=14)
F1 = mb._nest_function(C0, 'F1', 8, 10)
C1 = mb._nest_class(C0, 'C1', 11, 14)
C2 = mb._nest_class(C1, 'C2', 12, 14)
F3 = mb._nest_function(C2, 'F3', 14, 14)
expected = {'f0':f0, 'C0':C0}
Reported by Pylint.
Lib/idlelib/pyparse.py
68 issues
Line: 133
Column: 9
def set_code(self, s):
assert len(s) == 0 or s[-1] == '\n'
self.code = s
self.study_level = 0
def find_good_parse_start(self, is_char_in_string):
"""
Return index of a good place to begin parsing, as close to the
Reported by Pylint.
Line: 134
Column: 9
def set_code(self, s):
assert len(s) == 0 or s[-1] == '\n'
self.code = s
self.study_level = 0
def find_good_parse_start(self, is_char_in_string):
"""
Return index of a good place to begin parsing, as close to the
end of the string as possible. This will be the start of some
Reported by Pylint.
Line: 155
Column: 13
# but don't try too often; pos will be left None, or
# bumped to a legitimate synch point.
limit = len(code)
for tries in range(5):
i = code.rfind(":\n", 0, limit)
if i < 0:
break
i = code.rfind('\n', 0, i) + 1 # start of colon line (-1+1=0)
m = _synchre(code, i, limit)
Reported by Pylint.
Line: 199
Column: 13
"""
assert lo == 0 or self.code[lo-1] == '\n'
if lo > 0:
self.code = self.code[lo:]
def _study1(self):
"""Find the line numbers of non-continuation lines.
As quickly as humanly possible <wink>, find the line numbers (0-
Reported by Pylint.
Line: 210
Column: 9
"""
if self.study_level >= 1:
return
self.study_level = 1
# Map all uninteresting characters to "x", all open brackets
# to "(", all close brackets to ")", then collapse runs of
# uninteresting characters. This can cut the number of chars
# by a factor of 10-40, and so greatly speed the following loop.
Reported by Pylint.
Line: 231
Column: 9
# whether & why the last stmt is a continuation.
continuation = C_NONE
level = lno = 0 # level is nesting level; lno is line number
self.goodlines = goodlines = [0]
push_good = goodlines.append
i, n = 0, len(code)
while i < n:
ch = code[i]
i = i+1
Reported by Pylint.
Line: 327
Column: 9
if (continuation != C_STRING_FIRST_LINE
and continuation != C_STRING_NEXT_LINES and level > 0):
continuation = C_BRACKET
self.continuation = continuation
# Push the final line number as a sentinel value, regardless of
# whether it's continued.
assert (continuation == C_NONE) == (goodlines[-1] == lno)
if goodlines[-1] != lno:
Reported by Pylint.
Line: 361
Column: 9
if self.study_level >= 2:
return
self._study1()
self.study_level = 2
# Set p and q to slice indices of last interesting stmt.
code, goodlines = self.code, self.goodlines
i = len(goodlines) - 1 # Index of newest line.
p = len(code) # End of goodlines[i]
Reported by Pylint.
Line: 372
Column: 17
# Make p be the index of the stmt at line number goodlines[i].
# Move p back to the stmt at line number goodlines[i-1].
q = p
for nothing in range(goodlines[i-1], goodlines[i]):
# tricky: sets p to 0 if no preceding newline
p = code.rfind('\n', 0, p-1) + 1
# The stmt code[p:q] isn't a continuation, but may be blank
# or a non-indenting comment line.
if _junkre(code, p):
Reported by Pylint.
Line: 385
Column: 26
# nothing but junk!
assert p == 0
q = p
self.stmt_start, self.stmt_end = p, q
# Analyze this stmt, to find the last open bracket (if any)
# and last interesting character (if any).
lastch = ""
stack = [] # stack of open bracket indices
Reported by Pylint.
Lib/tkinter/ttk.py
68 issues
Line: 47
Column: 9
'lappend auto_path {%s}' % tilelib)
master.tk.eval('package require tile') # TclError may be raised here
master._tile_loaded = True
def _format_optvalue(value, script=False):
"""Internal function."""
if script:
# if caller passes a Tcl script to tk.call, all the values need to
Reported by Pylint.
Line: 113
Column: 1
return _flatten(opts)
def _format_elemcreate(etype, script=False, *args, **kw):
"""Formats args and kw according to the given element factory etype."""
spec = None
opts = ()
if etype in ("image", "vsapi"):
if etype == "image": # define an element based on an image
Reported by Pylint.
Line: 131
Column: 13
# Microsoft Visual Styles API which is responsible for the
# themed styles on Windows XP and Vista.
# Availability: Tk 8.6, Windows XP and Vista.
class_name, part_id = args[:2]
statemap = _join(_mapdict_values(args[2:]))
spec = "%s %s %s" % (class_name, part_id, statemap)
opts = _format_optdict(kw, script)
Reported by Pylint.
Line: 352
Column: 18
If it is not allowed to use the default root and master is None,
RuntimeError is raised."""
if master is None:
master = tkinter._get_default_root()
return master
class Style(object):
"""Manipulate style database."""
Reported by Pylint.
Line: 563
Column: 5
return self.tk.call(self._w, "identify", x, y)
def instate(self, statespec, callback=None, *args, **kw):
"""Test the widget's state.
If callback is not specified, returns True if the widget state
matches statespec and False otherwise. If callback is specified,
then it will be invoked with *args, **kw if the widget state
Reported by Pylint.
Line: 648
Column: 5
"""Ttk Entry widget displays a one-line text string and allows that
string to be edited by the user."""
def __init__(self, master=None, widget=None, **kw):
"""Constructs a Ttk Entry widget with the parent master.
STANDARD OPTIONS
class, cursor, style, takefocus, xscrollcommand
Reported by Pylint.
Line: 934
Column: 5
"""Ttk Panedwindow widget displays a number of subwindows, stacked
either vertically or horizontally."""
def __init__(self, master=None, **kw):
"""Construct a Ttk Panedwindow with parent master.
STANDARD OPTIONS
class, cursor, style, takefocus
Reported by Pylint.
Line: 1063
Column: 5
"""Ttk Scale widget is typically used to control the numeric value of
a linked variable that varies uniformly over some range."""
def __init__(self, master=None, **kw):
"""Construct a Ttk Scale with parent master.
STANDARD OPTIONS
class, cursor, style, takefocus
Reported by Pylint.
Line: 1090
Column: 5
return retval
def get(self, x=None, y=None):
"""Get the current value of the value option, or the value
corresponding to the coordinates x, y if they are specified.
x and y are pixel coordinates relative to the scale widget
origin."""
Reported by Pylint.
Line: 1102
Column: 5
class Scrollbar(Widget, tkinter.Scrollbar):
"""Ttk Scrollbar controls the viewport of a scrollable widget."""
def __init__(self, master=None, **kw):
"""Construct a Ttk Scrollbar with parent master.
STANDARD OPTIONS
class, cursor, style, takefocus
Reported by Pylint.
Lib/test/test_imp.py
68 issues
Line: 42
Column: 13
lock_held_at_start = imp.lock_held()
self.verify_lock_state(lock_held_at_start)
for i in range(LOOPS):
imp.acquire_lock()
self.verify_lock_state(True)
for i in range(LOOPS):
imp.release_lock()
Reported by Pylint.
Line: 68
Column: 22
self.test_path = mod.__path__
def test_import_encoded_module(self):
for modname, encoding, teststr in self.test_strings:
mod = importlib.import_module('test.encoded_modules.'
'module_' + modname)
self.assertEqual(teststr, mod.test)
def test_find_module_encoding(self):
Reported by Pylint.
Line: 84
Column: 27
def test_issue1267(self):
for mod, encoding, _ in self.test_strings:
fp, filename, info = imp.find_module('module_' + mod,
self.test_path)
with fp:
self.assertNotEqual(fp, None)
self.assertEqual(fp.encoding, encoding)
self.assertEqual(fp.tell(), 0)
Reported by Pylint.
Line: 84
Column: 17
def test_issue1267(self):
for mod, encoding, _ in self.test_strings:
fp, filename, info = imp.find_module('module_' + mod,
self.test_path)
with fp:
self.assertNotEqual(fp, None)
self.assertEqual(fp.encoding, encoding)
self.assertEqual(fp.tell(), 0)
Reported by Pylint.
Line: 107
Column: 29
try:
with open(temp_mod_name + '.py', 'w', encoding="latin-1") as file:
file.write("# coding: cp1252\nu = 'test.test_imp'\n")
file, filename, info = imp.find_module(temp_mod_name)
file.close()
self.assertEqual(file.encoding, 'cp1252')
finally:
del sys.path[0]
os_helper.unlink(temp_mod_name + '.py')
Reported by Pylint.
Line: 107
Column: 19
try:
with open(temp_mod_name + '.py', 'w', encoding="latin-1") as file:
file.write("# coding: cp1252\nu = 'test.test_imp'\n")
file, filename, info = imp.find_module(temp_mod_name)
file.close()
self.assertEqual(file.encoding, 'cp1252')
finally:
del sys.path[0]
os_helper.unlink(temp_mod_name + '.py')
Reported by Pylint.
Line: 209
Column: 3
def test_load_from_source(self):
# Verify that the imp module can correctly load and find .py files
# XXX (ncoghlan): It would be nice to use import_helper.CleanImport
# here, but that breaks because the os module registers some
# handlers in copy_reg on import. Since CleanImport doesn't
# revert that registration, the module is left in a broken
# state after reversion. Reinitialising the module contents
# and just reverting os.environ to its previous state is an OK
Reported by Pylint.
Line: 242
Column: 28
def test_issue16421_multiple_modules_in_one_dll(self):
# Issue 16421: loading several modules from the same compiled file fails
m = '_testimportmultiple'
fileobj, pathname, description = imp.find_module(m)
fileobj.close()
mod0 = imp.load_dynamic(m, pathname)
mod1 = imp.load_dynamic('_testimportmultiple_foo', pathname)
mod2 = imp.load_dynamic('_testimportmultiple_bar', pathname)
self.assertEqual(mod0.__name__, m)
Reported by Pylint.
Line: 312
Column: 18
def test_multiple_calls_to_get_data(self):
# Issue #18755: make sure multiple calls to get_data() can succeed.
loader = imp._LoadSourceCompatibility('imp', imp.__file__,
open(imp.__file__, encoding="utf-8"))
loader.get_data(imp.__file__) # File should be closed
loader.get_data(imp.__file__) # Will need to create a newly opened file
def test_load_source(self):
Reported by Pylint.
Line: 388
Column: 3
reload()."""
def test_source(self):
# XXX (ncoghlan): It would be nice to use test.import_helper.CleanImport
# here, but that breaks because the os module registers some
# handlers in copy_reg on import. Since CleanImport doesn't
# revert that registration, the module is left in a broken
# state after reversion. Reinitialising the module contents
# and just reverting os.environ to its previous state is an OK
Reported by Pylint.
Lib/multiprocessing/synchronize.py
68 issues
Line: 20
Column: 1
import _multiprocessing
import time
from . import context
from . import process
from . import util
# Try to import the mp.synchronize module cleanly, if it fails
# raise ImportError for platforms lacking a working sem_open implementation.
Reported by Pylint.
Line: 21
Column: 1
import time
from . import context
from . import process
from . import util
# Try to import the mp.synchronize module cleanly, if it fails
# raise ImportError for platforms lacking a working sem_open implementation.
# See issue 3770
Reported by Pylint.
Line: 22
Column: 1
from . import context
from . import process
from . import util
# Try to import the mp.synchronize module cleanly, if it fails
# raise ImportError for platforms lacking a working sem_open implementation.
# See issue 3770
try:
Reported by Pylint.
Line: 46
Column: 1
# Base class for semaphores and mutexes; wraps `_multiprocessing.SemLock`
#
class SemLock(object):
_rand = tempfile._RandomNameSequence()
def __init__(self, kind, value, maxvalue, *, ctx):
if ctx is None:
Reported by Pylint.
Line: 79
Column: 13
# We only get here if we are on Unix with forking
# disabled. When the object is garbage collected or the
# process shuts down we unlink the semaphore name
from .resource_tracker import register
register(self._semlock.name, "semaphore")
util.Finalize(self, SemLock._cleanup, (self._semlock.name,),
exitpriority=0)
@staticmethod
Reported by Pylint.
Line: 86
Column: 9
@staticmethod
def _cleanup(name):
from .resource_tracker import unregister
sem_unlink(name)
unregister(name, "semaphore")
def _make_methods(self):
self.acquire = self._semlock.acquire
Reported by Pylint.
Line: 364
Column: 9
def __init__(self, parties, action=None, timeout=None, *, ctx):
import struct
from .heap import BufferWrapper
wrapper = BufferWrapper(struct.calcsize('i') * 2)
cond = ctx.Condition()
self.__setstate__((parties, action, timeout, cond, wrapper))
self._state = 0
self._count = 0
Reported by Pylint.
Line: 30
Column: 5
try:
from _multiprocessing import SemLock, sem_unlink
except (ImportError):
raise ImportError("This platform lacks a functioning sem_open" +
" implementation, therefore, the required" +
" synchronization primitives needed will not" +
" function, see issue 3770.")
#
Reported by Pylint.
Line: 48
Column: 13
class SemLock(object):
_rand = tempfile._RandomNameSequence()
def __init__(self, kind, value, maxvalue, *, ctx):
if ctx is None:
ctx = context._default_context.get_context()
name = ctx.get_start_method()
Reported by Pylint.
Line: 55
Column: 13
ctx = context._default_context.get_context()
name = ctx.get_start_method()
unlink_now = sys.platform == 'win32' or name == 'fork'
for i in range(100):
try:
sl = self._semlock = _multiprocessing.SemLock(
kind, value, maxvalue, self._make_name(),
unlink_now)
except FileExistsError:
Reported by Pylint.
Lib/test/test_ensurepip.py
68 issues
Line: 24
Column: 13
with tempfile.TemporaryDirectory() as tmpdir:
self.touch(tmpdir, "pip-1.2.3b1-py2.py3-none-any.whl")
self.touch(tmpdir, "setuptools-49.1.3-py3-none-any.whl")
with (unittest.mock.patch.object(ensurepip, '_PACKAGES', None),
unittest.mock.patch.object(ensurepip, '_WHEEL_PKG_DIR', tmpdir)):
self.assertEqual(ensurepip.version(), '1.2.3b1')
def test_get_packages_no_dir(self):
# Test _get_packages() without a wheel package directory
Reported by Pylint.
Line: 30
Column: 9
def test_get_packages_no_dir(self):
# Test _get_packages() without a wheel package directory
with (unittest.mock.patch.object(ensurepip, '_PACKAGES', None),
unittest.mock.patch.object(ensurepip, '_WHEEL_PKG_DIR', None)):
packages = ensurepip._get_packages()
# when bundled wheel packages are used, we get _PIP_VERSION
self.assertEqual(ensurepip._PIP_VERSION, ensurepip.version())
Reported by Pylint.
Line: 52
Column: 13
# not used, make sure that it's ignored
self.touch(tmpdir, "wheel-0.34.2-py2.py3-none-any.whl")
with (unittest.mock.patch.object(ensurepip, '_PACKAGES', None),
unittest.mock.patch.object(ensurepip, '_WHEEL_PKG_DIR', tmpdir)):
packages = ensurepip._get_packages()
self.assertEqual(packages['setuptools'].version, '49.1.3')
self.assertEqual(packages['setuptools'].wheel_path,
Reported by Pylint.
Line: 32
Column: 24
# Test _get_packages() without a wheel package directory
with (unittest.mock.patch.object(ensurepip, '_PACKAGES', None),
unittest.mock.patch.object(ensurepip, '_WHEEL_PKG_DIR', None)):
packages = ensurepip._get_packages()
# when bundled wheel packages are used, we get _PIP_VERSION
self.assertEqual(ensurepip._PIP_VERSION, ensurepip.version())
# use bundled wheel packages
Reported by Pylint.
Line: 35
Column: 30
packages = ensurepip._get_packages()
# when bundled wheel packages are used, we get _PIP_VERSION
self.assertEqual(ensurepip._PIP_VERSION, ensurepip.version())
# use bundled wheel packages
self.assertIsNotNone(packages['pip'].wheel_name)
self.assertIsNotNone(packages['setuptools'].wheel_name)
Reported by Pylint.
Line: 54
Column: 28
with (unittest.mock.patch.object(ensurepip, '_PACKAGES', None),
unittest.mock.patch.object(ensurepip, '_WHEEL_PKG_DIR', tmpdir)):
packages = ensurepip._get_packages()
self.assertEqual(packages['setuptools'].version, '49.1.3')
self.assertEqual(packages['setuptools'].wheel_path,
os.path.join(tmpdir, setuptools_filename))
self.assertEqual(packages['pip'].version, '20.2.2')
Reported by Pylint.
Line: 223
Column: 13
def test_uninstall_skipped_when_not_installed(self):
with fake_pip(None):
ensurepip._uninstall_helper()
self.assertFalse(self.run_pip.called)
def test_uninstall_skipped_with_warning_for_wrong_version(self):
with fake_pip("not a valid version"):
with test.support.captured_stderr() as stderr:
Reported by Pylint.
Line: 229
Column: 17
def test_uninstall_skipped_with_warning_for_wrong_version(self):
with fake_pip("not a valid version"):
with test.support.captured_stderr() as stderr:
ensurepip._uninstall_helper()
warning = stderr.getvalue().strip()
self.assertIn("only uninstall a matching version", warning)
self.assertFalse(self.run_pip.called)
Reported by Pylint.
Line: 237
Column: 13
def test_uninstall(self):
with fake_pip():
ensurepip._uninstall_helper()
self.run_pip.assert_called_once_with(
[
"uninstall", "-y", "--disable-pip-version-check", "pip",
"setuptools",
Reported by Pylint.
Line: 248
Column: 13
def test_uninstall_with_verbosity_1(self):
with fake_pip():
ensurepip._uninstall_helper(verbosity=1)
self.run_pip.assert_called_once_with(
[
"uninstall", "-y", "--disable-pip-version-check", "-v", "pip",
"setuptools",
Reported by Pylint.
Tools/demo/hanoi.py
68 issues
Line: 15
Column: 1
bitmap.
"""
from tkinter import Tk, Canvas
# Basic Towers-of-Hanoi algorithm: move n pieces from a to b, using c
# as temporary. For each move, call report()
def hanoi(n, a, b, c, report):
if n <= 0: return
Reported by Pylint.
Line: 96
Column: 9
c = self.canvas
# Lift the piece above peg a
ax1, ay1, ax2, ay2 = c.bbox(self.pegs[a])
while True:
x1, y1, x2, y2 = c.bbox(p)
if y2 < ay1: break
c.move(p, 0, -1)
self.tk.update()
Reported by Pylint.
Line: 96
Column: 24
c = self.canvas
# Lift the piece above peg a
ax1, ay1, ax2, ay2 = c.bbox(self.pegs[a])
while True:
x1, y1, x2, y2 = c.bbox(p)
if y2 < ay1: break
c.move(p, 0, -1)
self.tk.update()
Reported by Pylint.
Line: 96
Column: 19
c = self.canvas
# Lift the piece above peg a
ax1, ay1, ax2, ay2 = c.bbox(self.pegs[a])
while True:
x1, y1, x2, y2 = c.bbox(p)
if y2 < ay1: break
c.move(p, 0, -1)
self.tk.update()
Reported by Pylint.
Line: 104
Column: 14
self.tk.update()
# Move it towards peg b
bx1, by1, bx2, by2 = c.bbox(self.pegs[b])
newcenter = (bx1+bx2)//2
while True:
x1, y1, x2, y2 = c.bbox(p)
center = (x1+x2)//2
if center == newcenter: break
Reported by Pylint.
Line: 19
Column: 1
# Basic Towers-of-Hanoi algorithm: move n pieces from a to b, using c
# as temporary. For each move, call report()
def hanoi(n, a, b, c, report):
if n <= 0: return
hanoi(n-1, a, c, b, report)
report(n, a, b)
hanoi(n-1, c, b, a, report)
Reported by Pylint.
Line: 19
Column: 1
# Basic Towers-of-Hanoi algorithm: move n pieces from a to b, using c
# as temporary. For each move, call report()
def hanoi(n, a, b, c, report):
if n <= 0: return
hanoi(n-1, a, c, b, report)
report(n, a, b)
hanoi(n-1, c, b, a, report)
Reported by Pylint.
Line: 19
Column: 1
# Basic Towers-of-Hanoi algorithm: move n pieces from a to b, using c
# as temporary. For each move, call report()
def hanoi(n, a, b, c, report):
if n <= 0: return
hanoi(n-1, a, c, b, report)
report(n, a, b)
hanoi(n-1, c, b, a, report)
Reported by Pylint.
Line: 19
Column: 1
# Basic Towers-of-Hanoi algorithm: move n pieces from a to b, using c
# as temporary. For each move, call report()
def hanoi(n, a, b, c, report):
if n <= 0: return
hanoi(n-1, a, c, b, report)
report(n, a, b)
hanoi(n-1, c, b, a, report)
Reported by Pylint.
Line: 19
Column: 1
# Basic Towers-of-Hanoi algorithm: move n pieces from a to b, using c
# as temporary. For each move, call report()
def hanoi(n, a, b, c, report):
if n <= 0: return
hanoi(n-1, a, c, b, report)
report(n, a, b)
hanoi(n-1, c, b, a, report)
Reported by Pylint.