The following issues were found
Lib/distutils/command/register.py
37 issues
Line: 14
Column: 1
from warnings import warn
from distutils.core import PyPIRCCommand
from distutils.errors import *
from distutils import log
class register(PyPIRCCommand):
description = ("register the distribution with the Python package index")
Reported by Pylint.
Line: 14
Column: 1
from warnings import warn
from distutils.core import PyPIRCCommand
from distutils.errors import *
from distutils import log
class register(PyPIRCCommand):
description = ("register the distribution with the Python package index")
Reported by Pylint.
Line: 14
Column: 1
from warnings import warn
from distutils.core import PyPIRCCommand
from distutils.errors import *
from distutils import log
class register(PyPIRCCommand):
description = ("register the distribution with the Python package index")
Reported by Pylint.
Line: 14
Column: 1
from warnings import warn
from distutils.core import PyPIRCCommand
from distutils.errors import *
from distutils import log
class register(PyPIRCCommand):
description = ("register the distribution with the Python package index")
Reported by Pylint.
Line: 14
Column: 1
from warnings import warn
from distutils.core import PyPIRCCommand
from distutils.errors import *
from distutils import log
class register(PyPIRCCommand):
description = ("register the distribution with the Python package index")
Reported by Pylint.
Line: 14
Column: 1
from warnings import warn
from distutils.core import PyPIRCCommand
from distutils.errors import *
from distutils import log
class register(PyPIRCCommand):
description = ("register the distribution with the Python package index")
Reported by Pylint.
Line: 14
Column: 1
from warnings import warn
from distutils.core import PyPIRCCommand
from distutils.errors import *
from distutils import log
class register(PyPIRCCommand):
description = ("register the distribution with the Python package index")
Reported by Pylint.
Line: 14
Column: 1
from warnings import warn
from distutils.core import PyPIRCCommand
from distutils.errors import *
from distutils import log
class register(PyPIRCCommand):
description = ("register the distribution with the Python package index")
Reported by Pylint.
Line: 14
Column: 1
from warnings import warn
from distutils.core import PyPIRCCommand
from distutils.errors import *
from distutils import log
class register(PyPIRCCommand):
description = ("register the distribution with the Python package index")
Reported by Pylint.
Line: 14
Column: 1
from warnings import warn
from distutils.core import PyPIRCCommand
from distutils.errors import *
from distutils import log
class register(PyPIRCCommand):
description = ("register the distribution with the Python package index")
Reported by Pylint.
Lib/ctypes/wintypes.py
37 issues
Line: 20
Column: 20
BOOLEAN = BYTE
BOOL = ctypes.c_long
class VARIANT_BOOL(ctypes._SimpleCData):
_type_ = "v"
def __repr__(self):
return "%s(%r)" % (self.__class__.__name__, self.value)
ULONG = ctypes.c_ulong
Reported by Pylint.
Line: 1
Column: 1
# The most useful windows datatypes
import ctypes
BYTE = ctypes.c_byte
WORD = ctypes.c_ushort
DWORD = ctypes.c_ulong
#UCHAR = ctypes.c_uchar
CHAR = ctypes.c_char
Reported by Pylint.
Line: 20
Column: 1
BOOLEAN = BYTE
BOOL = ctypes.c_long
class VARIANT_BOOL(ctypes._SimpleCData):
_type_ = "v"
def __repr__(self):
return "%s(%r)" % (self.__class__.__name__, self.value)
ULONG = ctypes.c_ulong
Reported by Pylint.
Line: 20
Column: 1
BOOLEAN = BYTE
BOOL = ctypes.c_long
class VARIANT_BOOL(ctypes._SimpleCData):
_type_ = "v"
def __repr__(self):
return "%s(%r)" % (self.__class__.__name__, self.value)
ULONG = ctypes.c_ulong
Reported by Pylint.
Line: 20
Column: 1
BOOLEAN = BYTE
BOOL = ctypes.c_long
class VARIANT_BOOL(ctypes._SimpleCData):
_type_ = "v"
def __repr__(self):
return "%s(%r)" % (self.__class__.__name__, self.value)
ULONG = ctypes.c_ulong
Reported by Pylint.
Line: 32
Column: 18
SHORT = ctypes.c_short
# in the windows header files, these are structures.
_LARGE_INTEGER = LARGE_INTEGER = ctypes.c_longlong
_ULARGE_INTEGER = ULARGE_INTEGER = ctypes.c_ulonglong
LPCOLESTR = LPOLESTR = OLESTR = ctypes.c_wchar_p
LPCWSTR = LPWSTR = ctypes.c_wchar_p
LPCSTR = LPSTR = ctypes.c_char_p
Reported by Pylint.
Line: 32
Column: 1
SHORT = ctypes.c_short
# in the windows header files, these are structures.
_LARGE_INTEGER = LARGE_INTEGER = ctypes.c_longlong
_ULARGE_INTEGER = ULARGE_INTEGER = ctypes.c_ulonglong
LPCOLESTR = LPOLESTR = OLESTR = ctypes.c_wchar_p
LPCWSTR = LPWSTR = ctypes.c_wchar_p
LPCSTR = LPSTR = ctypes.c_char_p
Reported by Pylint.
Line: 33
Column: 19
# in the windows header files, these are structures.
_LARGE_INTEGER = LARGE_INTEGER = ctypes.c_longlong
_ULARGE_INTEGER = ULARGE_INTEGER = ctypes.c_ulonglong
LPCOLESTR = LPOLESTR = OLESTR = ctypes.c_wchar_p
LPCWSTR = LPWSTR = ctypes.c_wchar_p
LPCSTR = LPSTR = ctypes.c_char_p
LPCVOID = LPVOID = ctypes.c_void_p
Reported by Pylint.
Line: 33
Column: 1
# in the windows header files, these are structures.
_LARGE_INTEGER = LARGE_INTEGER = ctypes.c_longlong
_ULARGE_INTEGER = ULARGE_INTEGER = ctypes.c_ulonglong
LPCOLESTR = LPOLESTR = OLESTR = ctypes.c_wchar_p
LPCWSTR = LPWSTR = ctypes.c_wchar_p
LPCSTR = LPSTR = ctypes.c_char_p
LPCVOID = LPVOID = ctypes.c_void_p
Reported by Pylint.
Line: 91
Column: 1
HTASK = HANDLE
HWINSTA = HANDLE
HWND = HANDLE
SC_HANDLE = HANDLE
SERVICE_STATUS_HANDLE = HANDLE
################################################################
# Some important structure definitions
Reported by Pylint.
Lib/distutils/cmd.py
37 issues
Line: 71
Column: 3
# false and true (duh). Note that this means figuring out the real
# value of each flag is a touch complicated -- hence "self._dry_run"
# will be handled by __getattr__, below.
# XXX This needs to be fixed.
self._dry_run = None
# verbose is largely ignored, but needs to be set for
# backwards compatibility (I think)?
self.verbose = dist.verbose
Reported by Pylint.
Line: 94
Column: 3
# always calls 'finalize_options()', to respect/update it.
self.finalized = 0
# XXX A more explicit way to customize dry_run would be better.
def __getattr__(self, attr):
if attr == 'dry_run':
myval = getattr(self, "_" + attr)
if myval is None:
return getattr(self.distribution, attr)
Reported by Pylint.
Line: 302
Column: 3
cmd_obj.ensure_finalized()
return cmd_obj
# XXX rename to 'get_reinitialized_command()'? (should do the
# same in dist.py, if so)
def reinitialize_command(self, command, reinit_subcommands=0):
return self.distribution.reinitialize_command(command,
reinit_subcommands)
Reported by Pylint.
Line: 334
Column: 45
def warn(self, msg):
log.warn("warning: %s: %s\n", self.get_command_name(), msg)
def execute(self, func, args, msg=None, level=1):
util.execute(func, args, msg, dry_run=self.dry_run)
def mkpath(self, name, mode=0o777):
dir_util.mkpath(name, mode, dry_run=self.dry_run)
Reported by Pylint.
Line: 341
Column: 30
dir_util.mkpath(name, mode, dry_run=self.dry_run)
def copy_file(self, infile, outfile, preserve_mode=1, preserve_times=1,
link=None, level=1):
"""Copy a file respecting verbose, dry-run and force flags. (The
former two default to whatever is in the Distribution object, and
the latter defaults to false for commands that don't define it.)"""
return file_util.copy_file(infile, outfile, preserve_mode,
preserve_times, not self.force, link,
Reported by Pylint.
Line: 350
Column: 41
dry_run=self.dry_run)
def copy_tree(self, infile, outfile, preserve_mode=1, preserve_times=1,
preserve_symlinks=0, level=1):
"""Copy an entire directory tree respecting verbose, dry-run,
and force flags.
"""
return dir_util.copy_tree(infile, outfile, preserve_mode,
preserve_times, preserve_symlinks,
Reported by Pylint.
Line: 358
Column: 36
preserve_times, preserve_symlinks,
not self.force, dry_run=self.dry_run)
def move_file (self, src, dst, level=1):
"""Move a file respecting dry-run flag."""
return file_util.move_file(src, dst, dry_run=self.dry_run)
def spawn(self, cmd, search_path=1, level=1):
"""Spawn an external command respecting dry-run flag."""
Reported by Pylint.
Line: 362
Column: 41
"""Move a file respecting dry-run flag."""
return file_util.move_file(src, dst, dry_run=self.dry_run)
def spawn(self, cmd, search_path=1, level=1):
"""Spawn an external command respecting dry-run flag."""
from distutils.spawn import spawn
spawn(cmd, search_path, dry_run=self.dry_run)
def make_archive(self, base_name, format, root_dir=None, base_dir=None,
Reported by Pylint.
Line: 367
Column: 39
from distutils.spawn import spawn
spawn(cmd, search_path, dry_run=self.dry_run)
def make_archive(self, base_name, format, root_dir=None, base_dir=None,
owner=None, group=None):
return archive_util.make_archive(base_name, format, root_dir, base_dir,
dry_run=self.dry_run,
owner=owner, group=group)
Reported by Pylint.
Line: 7
Column: 1
in the distutils.command package.
"""
import sys, os, re
from distutils.errors import DistutilsOptionError
from distutils import util, dir_util, file_util, archive_util, dep_util
from distutils import log
class Command:
Reported by Pylint.
Tools/scripts/generate_token.py
37 issues
Line: 272
Column: 5
if __name__ == '__main__':
import sys
main(*sys.argv[1:])
Reported by Pylint.
Line: 32
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval
ERRORTOKEN = value
string = fields[1] if len(fields) > 1 else None
if string:
string = eval(string)
string_to_tok[string] = value
tok_names.append(name)
return tok_names, ERRORTOKEN, string_to_tok
Reported by Bandit.
Line: 32
Column: 26
ERRORTOKEN = value
string = fields[1] if len(fields) > 1 else None
if string:
string = eval(string)
string_to_tok[string] = value
tok_names.append(name)
return tok_names, ERRORTOKEN, string_to_tok
Reported by Pylint.
Line: 91
Column: 28
"""
def make_h(infile, outfile='Include/token.h'):
tok_names, ERRORTOKEN, string_to_tok = load_tokens(infile)
defines = []
for value, name in enumerate(tok_names[:ERRORTOKEN + 1]):
defines.append("#define %-15s %d\n" % (name, value))
Reported by Pylint.
Line: 265
Column: 1
print("%s regenerated from %s" % (outfile, infile))
def main(op, infile='Grammar/Tokens', *args):
make = globals()['make_' + op]
make(infile, *args)
if __name__ == '__main__':
Reported by Pylint.
Line: 1
Column: 1
#! /usr/bin/env python3
# This script generates token related files from Grammar/Tokens:
#
# Doc/library/token-list.inc
# Include/token.h
# Parser/token.c
# Lib/token.py
Reported by Pylint.
Line: 12
Column: 1
NT_OFFSET = 256
def load_tokens(path):
tok_names = []
string_to_tok = {}
ERRORTOKEN = None
with open(path) as fp:
for line in fp:
Reported by Pylint.
Line: 15
Column: 5
def load_tokens(path):
tok_names = []
string_to_tok = {}
ERRORTOKEN = None
with open(path) as fp:
for line in fp:
line = line.strip()
# strip comments
i = line.find('#')
Reported by Pylint.
Line: 16
Column: 24
tok_names = []
string_to_tok = {}
ERRORTOKEN = None
with open(path) as fp:
for line in fp:
line = line.strip()
# strip comments
i = line.find('#')
if i >= 0:
Reported by Pylint.
Line: 29
Column: 17
name = fields[0]
value = len(tok_names)
if name == 'ERRORTOKEN':
ERRORTOKEN = value
string = fields[1] if len(fields) > 1 else None
if string:
string = eval(string)
string_to_tok[string] = value
tok_names.append(name)
Reported by Pylint.
Tools/unicode/genmap_schinese.py
37 issues
Line: 10
Column: 1
import os
import re
from genmap_support import *
GB2312_C1 = (0x21, 0x7e)
GB2312_C2 = (0x21, 0x7e)
GBKL1_C1 = (0x81, 0xa8)
Reported by Pylint.
Line: 43
Column: 15
if i < 0xd800 or i > 0xdfff: # exclude unicode surrogate area
gbuni[i] = None
for uni, native in re_gb18030ass.findall(fo.read()):
uni = eval('0x'+uni)
native = [eval('0x'+u) for u in native.split()]
if len(native) <= 2:
del gbuni[uni]
if len(native) == 2: # we can decode algorithmically for 1 or 4 bytes
m.setdefault(native[0], {})
Reported by Pylint.
Line: 43
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval
if i < 0xd800 or i > 0xdfff: # exclude unicode surrogate area
gbuni[i] = None
for uni, native in re_gb18030ass.findall(fo.read()):
uni = eval('0x'+uni)
native = [eval('0x'+u) for u in native.split()]
if len(native) <= 2:
del gbuni[uni]
if len(native) == 2: # we can decode algorithmically for 1 or 4 bytes
m.setdefault(native[0], {})
Reported by Bandit.
Line: 44
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval
gbuni[i] = None
for uni, native in re_gb18030ass.findall(fo.read()):
uni = eval('0x'+uni)
native = [eval('0x'+u) for u in native.split()]
if len(native) <= 2:
del gbuni[uni]
if len(native) == 2: # we can decode algorithmically for 1 or 4 bytes
m.setdefault(native[0], {})
m[native[0]][native[1]] = uni
Reported by Bandit.
Line: 44
Column: 19
gbuni[i] = None
for uni, native in re_gb18030ass.findall(fo.read()):
uni = eval('0x'+uni)
native = [eval('0x'+u) for u in native.split()]
if len(native) <= 2:
del gbuni[uni]
if len(native) == 2: # we can decode algorithmically for 1 or 4 bytes
m.setdefault(native[0], {})
m[native[0]][native[1]] = uni
Reported by Pylint.
Line: 63
Column: 5
gb18030decmap, gb18030unilinear = parse_gb18030map(gb18030map)
gbkdecmap = loadmap(cp936map)
gb2312decmap = loadmap(gb2312map)
difmap = {}
for c1, m in gbkdecmap.items():
for c2, code in m.items():
del gb18030decmap[c1][c2]
if not gb18030decmap[c1]:
del gb18030decmap[c1]
Reported by Pylint.
Line: 112
Column: 68
print("Generating GB18030 extension decode map...")
writer = DecodeMapWriter(fp, "gb18030ext", gb18030decmap)
for i in range(1, 6):
writer.update_decode_map(eval("GB18030EXTP%d_C1" % i), eval("GB18030EXTP%d_C2" % i))
writer.generate()
print("Generating GB18030 extension encode map...")
writer = EncodeMapWriter(fp, "gb18030ext", gb18030encmap)
Reported by Pylint.
Line: 112
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval
print("Generating GB18030 extension decode map...")
writer = DecodeMapWriter(fp, "gb18030ext", gb18030decmap)
for i in range(1, 6):
writer.update_decode_map(eval("GB18030EXTP%d_C1" % i), eval("GB18030EXTP%d_C2" % i))
writer.generate()
print("Generating GB18030 extension encode map...")
writer = EncodeMapWriter(fp, "gb18030ext", gb18030encmap)
Reported by Bandit.
Line: 112
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval
print("Generating GB18030 extension decode map...")
writer = DecodeMapWriter(fp, "gb18030ext", gb18030decmap)
for i in range(1, 6):
writer.update_decode_map(eval("GB18030EXTP%d_C1" % i), eval("GB18030EXTP%d_C2" % i))
writer.generate()
print("Generating GB18030 extension encode map...")
writer = EncodeMapWriter(fp, "gb18030ext", gb18030encmap)
Reported by Bandit.
Line: 112
Column: 38
print("Generating GB18030 extension decode map...")
writer = DecodeMapWriter(fp, "gb18030ext", gb18030decmap)
for i in range(1, 6):
writer.update_decode_map(eval("GB18030EXTP%d_C1" % i), eval("GB18030EXTP%d_C2" % i))
writer.generate()
print("Generating GB18030 extension encode map...")
writer = EncodeMapWriter(fp, "gb18030ext", gb18030encmap)
Reported by Pylint.
Tools/pynche/ChipViewer.py
36 issues
Line: 16
Column: 1
selected and nearest ChipWidgets.
"""
from tkinter import *
import ColorDB
class ChipWidget:
_WIDTH = 150
Reported by Pylint.
Line: 17
Column: 1
"""
from tkinter import *
import ColorDB
class ChipWidget:
_WIDTH = 150
_HEIGHT = 80
Reported by Pylint.
Line: 33
Column: 24
presscmd = None,
releasecmd = None):
# create the text label
self.__label = Label(master, text=text)
self.__label.grid(row=0, column=0)
# create the color chip, implemented as a frame
self.__chip = Frame(master, relief=RAISED, borderwidth=2,
width=width,
height=height,
Reported by Pylint.
Line: 36
Column: 23
self.__label = Label(master, text=text)
self.__label.grid(row=0, column=0)
# create the color chip, implemented as a frame
self.__chip = Frame(master, relief=RAISED, borderwidth=2,
width=width,
height=height,
background=initialcolor)
self.__chip.grid(row=1, column=0)
# create the color name
Reported by Pylint.
Line: 36
Column: 44
self.__label = Label(master, text=text)
self.__label.grid(row=0, column=0)
# create the color chip, implemented as a frame
self.__chip = Frame(master, relief=RAISED, borderwidth=2,
width=width,
height=height,
background=initialcolor)
self.__chip.grid(row=1, column=0)
# create the color name
Reported by Pylint.
Line: 42
Column: 26
background=initialcolor)
self.__chip.grid(row=1, column=0)
# create the color name
self.__namevar = StringVar()
self.__namevar.set(initialcolor)
self.__name = Entry(master, textvariable=self.__namevar,
relief=FLAT, justify=CENTER, state=DISABLED,
font=self.__label['font'])
self.__name.grid(row=2, column=0)
Reported by Pylint.
Line: 44
Column: 23
# create the color name
self.__namevar = StringVar()
self.__namevar.set(initialcolor)
self.__name = Entry(master, textvariable=self.__namevar,
relief=FLAT, justify=CENTER, state=DISABLED,
font=self.__label['font'])
self.__name.grid(row=2, column=0)
# create the message area
self.__msgvar = StringVar()
Reported by Pylint.
Line: 45
Column: 50
self.__namevar = StringVar()
self.__namevar.set(initialcolor)
self.__name = Entry(master, textvariable=self.__namevar,
relief=FLAT, justify=CENTER, state=DISABLED,
font=self.__label['font'])
self.__name.grid(row=2, column=0)
# create the message area
self.__msgvar = StringVar()
self.__name = Entry(master, textvariable=self.__msgvar,
Reported by Pylint.
Line: 45
Column: 64
self.__namevar = StringVar()
self.__namevar.set(initialcolor)
self.__name = Entry(master, textvariable=self.__namevar,
relief=FLAT, justify=CENTER, state=DISABLED,
font=self.__label['font'])
self.__name.grid(row=2, column=0)
# create the message area
self.__msgvar = StringVar()
self.__name = Entry(master, textvariable=self.__msgvar,
Reported by Pylint.
Line: 45
Column: 36
self.__namevar = StringVar()
self.__namevar.set(initialcolor)
self.__name = Entry(master, textvariable=self.__namevar,
relief=FLAT, justify=CENTER, state=DISABLED,
font=self.__label['font'])
self.__name.grid(row=2, column=0)
# create the message area
self.__msgvar = StringVar()
self.__name = Entry(master, textvariable=self.__msgvar,
Reported by Pylint.
Lib/turtledemo/forest.py
36 issues
Line: 14
Column: 1
a Logo program written by Erich Neuwirth. See
http://homepage.univie.ac.at/erich.neuwirth/
"""
from turtle import Turtle, colormode, tracer, mainloop
from random import randrange
from time import perf_counter as clock
def symRandom(n):
return randrange(-n,n+1)
Reported by Pylint.
Line: 14
Column: 1
a Logo program written by Erich Neuwirth. See
http://homepage.univie.ac.at/erich.neuwirth/
"""
from turtle import Turtle, colormode, tracer, mainloop
from random import randrange
from time import perf_counter as clock
def symRandom(n):
return randrange(-n,n+1)
Reported by Pylint.
Line: 14
Column: 1
a Logo program written by Erich Neuwirth. See
http://homepage.univie.ac.at/erich.neuwirth/
"""
from turtle import Turtle, colormode, tracer, mainloop
from random import randrange
from time import perf_counter as clock
def symRandom(n):
return randrange(-n,n+1)
Reported by Pylint.
Line: 27
Column: 9
for angle, sizefactor in branchlist ]
def randomfd( t, distance, parts, angledist ):
for i in range(parts):
t.left(symRandom(angledist))
t.forward( (1.0 * distance)/parts )
def tree(tlist, size, level, widthfactor, branchlists, angledist=10, sizedist=5):
# benutzt Liste von turtles und Liste von Zweiglisten,
Reported by Pylint.
Line: 50
Column: 33
lst.append(t.clone())
brs.append(randomize(branchlist, angledist, sizedist))
t.right(angle)
for x in tree(lst, size*sizefactor, level-1, widthfactor, brs,
angledist, sizedist):
yield None
def start(t,x,y):
Reported by Pylint.
Line: 50
Column: 13
lst.append(t.clone())
brs.append(randomize(branchlist, angledist, sizedist))
t.right(angle)
for x in tree(lst, size*sizefactor, level-1, widthfactor, brs,
angledist, sizedist):
yield None
def start(t,x,y):
Reported by Pylint.
Line: 97
Column: 13
for b in u,s,t:
try:
b.__next__()
except:
done += 1
if done == 3:
break
tracer(1,10)
Reported by Pylint.
Line: 18
Column: 1
from random import randrange
from time import perf_counter as clock
def symRandom(n):
return randrange(-n,n+1)
def randomize( branchlist, angledist, sizedist ):
return [ (angle+symRandom(angledist),
sizefactor*1.01**symRandom(sizedist))
Reported by Pylint.
Line: 18
Column: 1
from random import randrange
from time import perf_counter as clock
def symRandom(n):
return randrange(-n,n+1)
def randomize( branchlist, angledist, sizedist ):
return [ (angle+symRandom(angledist),
sizefactor*1.01**symRandom(sizedist))
Reported by Pylint.
Line: 18
Column: 1
from random import randrange
from time import perf_counter as clock
def symRandom(n):
return randrange(-n,n+1)
def randomize( branchlist, angledist, sizedist ):
return [ (angle+symRandom(angledist),
sizefactor*1.01**symRandom(sizedist))
Reported by Pylint.
Lib/test/test_pow.py
36 issues
Line: 6
Column: 23
class PowTest(unittest.TestCase):
def powtest(self, type):
if type != float:
for i in range(-1000, 1000):
self.assertEqual(pow(type(i), 0), 1)
self.assertEqual(pow(type(i), 1), type(i))
self.assertEqual(pow(type(0), 1), type(0))
Reported by Pylint.
Line: 100
Column: 9
class TestRpow:
def __rpow__(self, other):
return None
None ** TestRpow() # Won't fail when __rpow__ invoked. SF bug #643260.
def test_bug705231(self):
# -1.0 raised to an integer should never blow up. It did if the
# platform pow() was buggy, and Python didn't worm around it.
eq = self.assertEqual
Reported by Pylint.
Line: 1
Column: 1
import math
import unittest
class PowTest(unittest.TestCase):
def powtest(self, type):
if type != float:
for i in range(-1000, 1000):
self.assertEqual(pow(type(i), 0), 1)
Reported by Pylint.
Line: 4
Column: 1
import math
import unittest
class PowTest(unittest.TestCase):
def powtest(self, type):
if type != float:
for i in range(-1000, 1000):
self.assertEqual(pow(type(i), 0), 1)
Reported by Pylint.
Line: 6
Column: 5
class PowTest(unittest.TestCase):
def powtest(self, type):
if type != float:
for i in range(-1000, 1000):
self.assertEqual(pow(type(i), 0), 1)
self.assertEqual(pow(type(i), 1), type(i))
self.assertEqual(pow(type(0), 1), type(0))
Reported by Pylint.
Line: 6
Column: 5
class PowTest(unittest.TestCase):
def powtest(self, type):
if type != float:
for i in range(-1000, 1000):
self.assertEqual(pow(type(i), 0), 1)
self.assertEqual(pow(type(i), 1), type(i))
self.assertEqual(pow(type(0), 1), type(0))
Reported by Pylint.
Line: 6
Column: 5
class PowTest(unittest.TestCase):
def powtest(self, type):
if type != float:
for i in range(-1000, 1000):
self.assertEqual(pow(type(i), 0), 1)
self.assertEqual(pow(type(i), 1), type(i))
self.assertEqual(pow(type(0), 1), type(0))
Reported by Pylint.
Line: 20
Column: 30
pow2 = 1
for i in range(0, 31):
self.assertEqual(pow(2, i), pow2)
if i != 30 : pow2 = pow2*2
for othertype in (int,):
for i in list(range(-10, 0)) + list(range(1, 10)):
ii = type(i)
for j in range(1, 11):
Reported by Pylint.
Line: 24
Column: 21
for othertype in (int,):
for i in list(range(-10, 0)) + list(range(1, 10)):
ii = type(i)
for j in range(1, 11):
jj = -othertype(j)
pow(ii, jj)
for othertype in int, float:
Reported by Pylint.
Line: 26
Column: 25
for i in list(range(-10, 0)) + list(range(1, 10)):
ii = type(i)
for j in range(1, 11):
jj = -othertype(j)
pow(ii, jj)
for othertype in int, float:
for i in range(1, 100):
zero = type(0)
Reported by Pylint.
Lib/test/test_importlib/builtin/test_loader.py
36 issues
Line: 1
Column: 1
from .. import abc
from .. import util
machinery = util.import_importlib('importlib.machinery')
import sys
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')
import sys
import types
import unittest
import warnings
Reported by Pylint.
Line: 83
Column: 18
def test_get_code(self):
# There is no code object.
result = self.machinery.BuiltinImporter.get_code(util.BUILTINS.good_name)
self.assertIsNone(result)
def test_get_source(self):
# There is no source.
result = self.machinery.BuiltinImporter.get_source(util.BUILTINS.good_name)
Reported by Pylint.
Line: 84
Column: 9
def test_get_code(self):
# There is no code object.
result = self.machinery.BuiltinImporter.get_code(util.BUILTINS.good_name)
self.assertIsNone(result)
def test_get_source(self):
# There is no source.
result = self.machinery.BuiltinImporter.get_source(util.BUILTINS.good_name)
self.assertIsNone(result)
Reported by Pylint.
Line: 88
Column: 18
def test_get_source(self):
# There is no source.
result = self.machinery.BuiltinImporter.get_source(util.BUILTINS.good_name)
self.assertIsNone(result)
def test_is_package(self):
# Cannot be a package.
result = self.machinery.BuiltinImporter.is_package(util.BUILTINS.good_name)
Reported by Pylint.
Line: 89
Column: 9
def test_get_source(self):
# There is no source.
result = self.machinery.BuiltinImporter.get_source(util.BUILTINS.good_name)
self.assertIsNone(result)
def test_is_package(self):
# Cannot be a package.
result = self.machinery.BuiltinImporter.is_package(util.BUILTINS.good_name)
self.assertFalse(result)
Reported by Pylint.
Line: 93
Column: 18
def test_is_package(self):
# Cannot be a package.
result = self.machinery.BuiltinImporter.is_package(util.BUILTINS.good_name)
self.assertFalse(result)
@unittest.skipIf(util.BUILTINS.bad_name is None, 'all modules are built in')
def test_not_builtin(self):
# Modules not built-in should raise ImportError.
Reported by Pylint.
Line: 94
Column: 9
def test_is_package(self):
# Cannot be a package.
result = self.machinery.BuiltinImporter.is_package(util.BUILTINS.good_name)
self.assertFalse(result)
@unittest.skipIf(util.BUILTINS.bad_name is None, 'all modules are built in')
def test_not_builtin(self):
# Modules not built-in should raise ImportError.
for meth_name in ('get_code', 'get_source', 'is_package'):
Reported by Pylint.
Line: 100
Column: 30
def test_not_builtin(self):
# Modules not built-in should raise ImportError.
for meth_name in ('get_code', 'get_source', 'is_package'):
method = getattr(self.machinery.BuiltinImporter, meth_name)
with self.assertRaises(ImportError) as cm:
method(util.BUILTINS.bad_name)
(Frozen_InspectLoaderTests,
Reported by Pylint.
Line: 101
Column: 14
# Modules not built-in should raise ImportError.
for meth_name in ('get_code', 'get_source', 'is_package'):
method = getattr(self.machinery.BuiltinImporter, meth_name)
with self.assertRaises(ImportError) as cm:
method(util.BUILTINS.bad_name)
(Frozen_InspectLoaderTests,
Source_InspectLoaderTests
Reported by Pylint.
Lib/test/test_dynamic.py
36 issues
Line: 26
Column: 9
Returns:
Nothing. Work will be performed on func in-place.
"""
pass
def test_globals_shadow_builtins(self):
# Modify globals() to shadow an entry in builtins.
def foo():
return len([1, 2, 3])
Reported by Pylint.
Line: 87
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval
builtins_dict = {"len": lambda x: 7}
globals_dict = {"foo": foo, "__builtins__": builtins_dict,
"len": lambda x: 8}
self.assertEqual(eval("foo()", globals_dict), 3)
self.assertEqual(eval("foo()", {"foo": foo}), 3)
def test_cannot_change_globals_or_builtins_with_exec(self):
def foo():
Reported by Bandit.
Line: 87
Column: 26
builtins_dict = {"len": lambda x: 7}
globals_dict = {"foo": foo, "__builtins__": builtins_dict,
"len": lambda x: 8}
self.assertEqual(eval("foo()", globals_dict), 3)
self.assertEqual(eval("foo()", {"foo": foo}), 3)
def test_cannot_change_globals_or_builtins_with_exec(self):
def foo():
Reported by Pylint.
Line: 89
Column: 26
"len": lambda x: 8}
self.assertEqual(eval("foo()", globals_dict), 3)
self.assertEqual(eval("foo()", {"foo": foo}), 3)
def test_cannot_change_globals_or_builtins_with_exec(self):
def foo():
return len([1, 2, 3])
self.configure_func(foo)
Reported by Pylint.
Line: 89
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval
"len": lambda x: 8}
self.assertEqual(eval("foo()", globals_dict), 3)
self.assertEqual(eval("foo()", {"foo": foo}), 3)
def test_cannot_change_globals_or_builtins_with_exec(self):
def foo():
return len([1, 2, 3])
self.configure_func(foo)
Reported by Bandit.
Line: 97
Column: 9
self.configure_func(foo)
globals_dict = {"foo": foo}
exec("x = foo()", globals_dict)
self.assertEqual(globals_dict["x"], 3)
# Note that this *doesn't* change the definition of len() seen by foo().
builtins_dict = {"len": lambda x: 7}
globals_dict = {"foo": foo, "__builtins__": builtins_dict,
Reported by Pylint.
Line: 97
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html
self.configure_func(foo)
globals_dict = {"foo": foo}
exec("x = foo()", globals_dict)
self.assertEqual(globals_dict["x"], 3)
# Note that this *doesn't* change the definition of len() seen by foo().
builtins_dict = {"len": lambda x: 7}
globals_dict = {"foo": foo, "__builtins__": builtins_dict,
Reported by Bandit.
Line: 105
Column: 9
globals_dict = {"foo": foo, "__builtins__": builtins_dict,
"len": lambda x: 8}
exec("x = foo()", globals_dict)
self.assertEqual(globals_dict["x"], 3)
def test_cannot_replace_builtins_dict_while_active(self):
def foo():
x = range(3)
Reported by Pylint.
Line: 105
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html
globals_dict = {"foo": foo, "__builtins__": builtins_dict,
"len": lambda x: 8}
exec("x = foo()", globals_dict)
self.assertEqual(globals_dict["x"], 3)
def test_cannot_replace_builtins_dict_while_active(self):
def foo():
x = range(3)
Reported by Bandit.
Line: 131
Column: 15
def test_eval_gives_lambda_custom_globals(self):
globals_dict = {"len": lambda x: 7}
foo = eval("lambda: len([])", globals_dict)
self.configure_func(foo)
self.assertEqual(foo(), 7)
Reported by Pylint.