The following issues were found
tests/basics/class_misc.py
4 issues
Line: 1
Column: 1
# converting user instance to buffer
class C:
pass
c = C()
try:
d = bytes(c)
except TypeError:
print('TypeError')
Reported by Pylint.
Line: 2
Column: 1
# converting user instance to buffer
class C:
pass
c = C()
try:
d = bytes(c)
except TypeError:
print('TypeError')
Reported by Pylint.
Line: 2
Column: 1
# converting user instance to buffer
class C:
pass
c = C()
try:
d = bytes(c)
except TypeError:
print('TypeError')
Reported by Pylint.
Line: 2
Column: 1
# converting user instance to buffer
class C:
pass
c = C()
try:
d = bytes(c)
except TypeError:
print('TypeError')
Reported by Pylint.
tests/basics/builtin_issubclass.py
4 issues
Line: 1
Column: 1
# test builtin issubclass
class A:
pass
print(issubclass(A, A))
print(issubclass(A, (A,)))
try:
Reported by Pylint.
Line: 3
Column: 1
# test builtin issubclass
class A:
pass
print(issubclass(A, A))
print(issubclass(A, (A,)))
try:
Reported by Pylint.
Line: 3
Column: 1
# test builtin issubclass
class A:
pass
print(issubclass(A, A))
print(issubclass(A, (A,)))
try:
Reported by Pylint.
Line: 3
Column: 1
# test builtin issubclass
class A:
pass
print(issubclass(A, A))
print(issubclass(A, (A,)))
try:
Reported by Pylint.
tests/basics/class_notimpl.py
4 issues
Line: 7
Column: 5
NotImplemented
except NameError:
print("SKIP")
raise SystemExit
class C:
def __init__(self, value):
self.value = value
Reported by Pylint.
Line: 1
Column: 1
# Test that returning of NotImplemented from binary op methods leads to
# TypeError.
try:
NotImplemented
except NameError:
print("SKIP")
raise SystemExit
class C:
Reported by Pylint.
Line: 9
Column: 1
print("SKIP")
raise SystemExit
class C:
def __init__(self, value):
self.value = value
def __str__(self):
return "C({})".format(self.value)
Reported by Pylint.
Line: 9
Column: 1
print("SKIP")
raise SystemExit
class C:
def __init__(self, value):
self.value = value
def __str__(self):
return "C({})".format(self.value)
Reported by Pylint.
tests/basics/class_ordereddict.py
4 issues
Line: 10
Column: 9
from collections import OrderedDict
except ImportError:
print("SKIP")
raise SystemExit
if not hasattr(int, "__dict__"):
print("SKIP")
raise SystemExit
Reported by Pylint.
Line: 1
Column: 1
# test using an OrderedDict as the locals to construct a class
try:
from ucollections import OrderedDict
except ImportError:
try:
from collections import OrderedDict
except ImportError:
print("SKIP")
Reported by Pylint.
Line: 17
Column: 1
raise SystemExit
A = type("A", (), OrderedDict(a=1, b=2, c=3, d=4, e=5))
print([k for k in A.__dict__.keys() if not k.startswith("_")])
Reported by Pylint.
Line: 18
Column: 19
A = type("A", (), OrderedDict(a=1, b=2, c=3, d=4, e=5))
print([k for k in A.__dict__.keys() if not k.startswith("_")])
Reported by Pylint.
tests/basics/builtin_help.py
4 issues
Line: 13
Column: 1
help(help) # help for a function
help(int) # help for a class
help(1) # help for an instance
import micropython
help(micropython) # help for a module
help('modules') # list available modules
print('done') # so last bit of output is predictable
Reported by Pylint.
Line: 7
Column: 5
help
except NameError:
print("SKIP")
raise SystemExit
help() # no args
help(help) # help for a function
help(int) # help for a class
help(1) # help for an instance
Reported by Pylint.
Line: 1
Column: 1
# test builtin help function
try:
help
except NameError:
print("SKIP")
raise SystemExit
help() # no args
Reported by Pylint.
Line: 13
Column: 1
help(help) # help for a function
help(int) # help for a class
help(1) # help for an instance
import micropython
help(micropython) # help for a module
help('modules') # list available modules
print('done') # so last bit of output is predictable
Reported by Pylint.
tests/basics/dict1.py
4 issues
Line: 62
Column: 5
# unsupported unary op
try:
+{}
except TypeError:
print('TypeError')
# unsupported binary op
try:
Reported by Pylint.
Line: 1
Column: 1
# basic dictionary
d = {}
print(d)
d[2] = 123
print(d)
d = {1:2}
d[3] = 3
print(len(d), d[1], d[3])
Reported by Pylint.
Line: 14
Column: 1
print(len(d), d[1], d[3])
print(str(d) == '{1: 0, 3: 3}' or str(d) == '{3: 3, 1: 0}')
x = 1
while x < 100:
d[x] = x
x += 1
print(d[50])
Reported by Pylint.
Line: 57
Column: 1
# value not found
try:
{}[0]
except KeyError as er:
print('KeyError', er, er.args)
# unsupported unary op
try:
+{}
Reported by Pylint.
tests/basics/builtin_hash_intbig.py
4 issues
Line: 1
Column: 1
# test builtin hash function
print({1 << 66:1}) # hash big int
print({-(1 << 66):2}) # hash negative big int
# __hash__ returning a large number should be truncated
class F:
def __hash__(self):
return 1 << 70 | 1
Reported by Pylint.
Line: 7
Column: 1
print({-(1 << 66):2}) # hash negative big int
# __hash__ returning a large number should be truncated
class F:
def __hash__(self):
return 1 << 70 | 1
print(hash(F()) != 0)
# this had a particular error with internal integer arithmetic of hash function
Reported by Pylint.
Line: 7
Column: 1
print({-(1 << 66):2}) # hash negative big int
# __hash__ returning a large number should be truncated
class F:
def __hash__(self):
return 1 << 70 | 1
print(hash(F()) != 0)
# this had a particular error with internal integer arithmetic of hash function
Reported by Pylint.
Line: 7
Column: 1
print({-(1 << 66):2}) # hash negative big int
# __hash__ returning a large number should be truncated
class F:
def __hash__(self):
return 1 << 70 | 1
print(hash(F()) != 0)
# this had a particular error with internal integer arithmetic of hash function
Reported by Pylint.
tests/basics/fun_globals.py
4 issues
Line: 16
Column: 7
print(foo.__globals__ is globals())
foo.__globals__["bar"] = 123
print(bar)
try:
foo.__globals__ = None
except AttributeError:
print("AttributeError")
Reported by Pylint.
Line: 1
Column: 1
# test the __globals__ attribute of a function
def foo():
pass
if not hasattr(foo, "__globals__"):
print("SKIP")
Reported by Pylint.
Line: 4
Column: 1
# test the __globals__ attribute of a function
def foo():
pass
if not hasattr(foo, "__globals__"):
print("SKIP")
Reported by Pylint.
Line: 4
Column: 1
# test the __globals__ attribute of a function
def foo():
pass
if not hasattr(foo, "__globals__"):
print("SKIP")
Reported by Pylint.
tests/basics/builtin_eval_error.py
4 issues
Line: 7
Column: 5
eval
except NameError:
print("SKIP")
raise SystemExit
try:
print(eval("[1,,]"))
except SyntaxError:
print("SyntaxError")
Reported by Pylint.
Line: 10
Column: 11
raise SystemExit
try:
print(eval("[1,,]"))
except SyntaxError:
print("SyntaxError")
Reported by Pylint.
Line: 10
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval
raise SystemExit
try:
print(eval("[1,,]"))
except SyntaxError:
print("SyntaxError")
Reported by Bandit.
Line: 1
Column: 1
# test if eval raises SyntaxError
try:
eval
except NameError:
print("SKIP")
raise SystemExit
try:
Reported by Pylint.
tests/basics/gen_yield_from_exc.py
4 issues
Line: 12
Column: 1
except ValueError:
print("caught ValueError from downstream")
g = gen2()
print(list(g))
Reported by Pylint.
Line: 1
Column: 1
def gen():
yield 1
yield 2
raise ValueError
def gen2():
try:
print((yield from gen()))
except ValueError:
Reported by Pylint.
Line: 1
Column: 1
def gen():
yield 1
yield 2
raise ValueError
def gen2():
try:
print((yield from gen()))
except ValueError:
Reported by Pylint.
Line: 6
Column: 1
yield 2
raise ValueError
def gen2():
try:
print((yield from gen()))
except ValueError:
print("caught ValueError from downstream")
Reported by Pylint.