The following issues were found
tests/basics/try_finally_continue.py
6 issues
Line: 11
Column: 25
print(x, i)
finally:
try:
1 / 0
finally:
return 42
finally:
print('continue')
continue
Reported by Pylint.
Line: 13
Column: 25
try:
1 / 0
finally:
return 42
finally:
print('continue')
continue
print(foo(4))
Reported by Pylint.
Line: 1
Column: 1
def foo(x):
for i in range(x):
try:
pass
finally:
try:
try:
print(x, i)
finally:
Reported by Pylint.
Line: 1
Column: 1
def foo(x):
for i in range(x):
try:
pass
finally:
try:
try:
print(x, i)
finally:
Reported by Pylint.
Line: 1
Column: 1
def foo(x):
for i in range(x):
try:
pass
finally:
try:
try:
print(x, i)
finally:
Reported by Pylint.
Line: 1
Column: 1
def foo(x):
for i in range(x):
try:
pass
finally:
try:
try:
print(x, i)
finally:
Reported by Pylint.
tests/basics/try_continue.py
6 issues
Line: 10
Column: 16
try:
if x == 2:
raise Exception
except Exception:
continue
print('b', x)
f()
Reported by Pylint.
Line: 1
Column: 1
# test continue within exception handler
def f():
lst = [1, 2, 3]
for x in lst:
print('a', x)
try:
if x == 2:
raise Exception
Reported by Pylint.
Line: 3
Column: 1
# test continue within exception handler
def f():
lst = [1, 2, 3]
for x in lst:
print('a', x)
try:
if x == 2:
raise Exception
Reported by Pylint.
Line: 3
Column: 1
# test continue within exception handler
def f():
lst = [1, 2, 3]
for x in lst:
print('a', x)
try:
if x == 2:
raise Exception
Reported by Pylint.
Line: 5
Column: 9
def f():
lst = [1, 2, 3]
for x in lst:
print('a', x)
try:
if x == 2:
raise Exception
except Exception:
Reported by Pylint.
Line: 10
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b112_try_except_continue.html
try:
if x == 2:
raise Exception
except Exception:
continue
print('b', x)
f()
Reported by Bandit.
tests/basics/sys_getsizeof.py
6 issues
Line: 11
Column: 5
sys.getsizeof
except AttributeError:
print('SKIP')
raise SystemExit
print(sys.getsizeof([1, 2]) >= 2)
print(sys.getsizeof({1: 2}) >= 2)
class A:
Reported by Pylint.
Line: 1
Column: 1
# test sys.getsizeof() function
try:
import usys as sys
except ImportError:
import sys
try:
sys.getsizeof
except AttributeError:
Reported by Pylint.
Line: 16
Column: 1
print(sys.getsizeof([1, 2]) >= 2)
print(sys.getsizeof({1: 2}) >= 2)
class A:
pass
print(sys.getsizeof(A()) > 0)
# Only test deque if we have it
try:
Reported by Pylint.
Line: 16
Column: 1
print(sys.getsizeof([1, 2]) >= 2)
print(sys.getsizeof({1: 2}) >= 2)
class A:
pass
print(sys.getsizeof(A()) > 0)
# Only test deque if we have it
try:
Reported by Pylint.
Line: 16
Column: 1
print(sys.getsizeof([1, 2]) >= 2)
print(sys.getsizeof({1: 2}) >= 2)
class A:
pass
print(sys.getsizeof(A()) > 0)
# Only test deque if we have it
try:
Reported by Pylint.
Line: 23
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
# Only test deque if we have it
try:
from ucollections import deque
assert sys.getsizeof(deque((), 1)) > 0
except ImportError:
pass
Reported by Bandit.
tests/extmod/uctypes_sizeof_od.py
6 issues
Line: 6
Column: 5
import uctypes
except ImportError:
print("SKIP")
raise SystemExit
desc = OrderedDict(
{
# arr is array at offset 0, of UINT8 elements, array size is 2
"arr": (uctypes.ARRAY | 0, uctypes.UINT8 | 2),
Reported by Pylint.
Line: 1
Column: 1
try:
from ucollections import OrderedDict
import uctypes
except ImportError:
print("SKIP")
raise SystemExit
desc = OrderedDict(
{
Reported by Pylint.
Line: 31
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
S = uctypes.struct(uctypes.addressof(data), desc, uctypes.LITTLE_ENDIAN)
print(uctypes.sizeof(S.arr))
assert uctypes.sizeof(S.arr) == 2
print(uctypes.sizeof(S.arr2))
assert uctypes.sizeof(S.arr2) == 2
print(uctypes.sizeof(S.arr3))
Reported by Bandit.
Line: 34
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert uctypes.sizeof(S.arr) == 2
print(uctypes.sizeof(S.arr2))
assert uctypes.sizeof(S.arr2) == 2
print(uctypes.sizeof(S.arr3))
try:
print(uctypes.sizeof(S.arr3[0]))
Reported by Bandit.
Line: 44
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
print("TypeError")
print(uctypes.sizeof(S.arr4))
assert uctypes.sizeof(S.arr4) == 6
print(uctypes.sizeof(S.sub))
assert uctypes.sizeof(S.sub) == 1
# invalid descriptor
Reported by Bandit.
Line: 47
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert uctypes.sizeof(S.arr4) == 6
print(uctypes.sizeof(S.sub))
assert uctypes.sizeof(S.sub) == 1
# invalid descriptor
try:
print(uctypes.sizeof([]))
except TypeError:
Reported by Bandit.
tests/extmod/uctypes_sizeof.py
6 issues
Line: 5
Column: 5
import uctypes
except ImportError:
print("SKIP")
raise SystemExit
desc = {
# arr is array at offset 0, of UINT8 elements, array size is 2
"arr": (uctypes.ARRAY | 0, uctypes.UINT8 | 2),
# arr2 is array at offset 0, size 2, of structures defined recursively
Reported by Pylint.
Line: 1
Column: 1
try:
import uctypes
except ImportError:
print("SKIP")
raise SystemExit
desc = {
# arr is array at offset 0, of UINT8 elements, array size is 2
"arr": (uctypes.ARRAY | 0, uctypes.UINT8 | 2),
Reported by Pylint.
Line: 28
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
S = uctypes.struct(uctypes.addressof(data), desc, uctypes.LITTLE_ENDIAN)
print(uctypes.sizeof(S.arr))
assert uctypes.sizeof(S.arr) == 2
print(uctypes.sizeof(S.arr2))
assert uctypes.sizeof(S.arr2) == 2
print(uctypes.sizeof(S.arr3))
Reported by Bandit.
Line: 31
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert uctypes.sizeof(S.arr) == 2
print(uctypes.sizeof(S.arr2))
assert uctypes.sizeof(S.arr2) == 2
print(uctypes.sizeof(S.arr3))
try:
print(uctypes.sizeof(S.arr3[0]))
Reported by Bandit.
Line: 41
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
print("TypeError")
print(uctypes.sizeof(S.arr4))
assert uctypes.sizeof(S.arr4) == 6
print(uctypes.sizeof(S.sub))
assert uctypes.sizeof(S.sub) == 1
# invalid descriptor
Reported by Bandit.
Line: 44
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert uctypes.sizeof(S.arr4) == 6
print(uctypes.sizeof(S.sub))
assert uctypes.sizeof(S.sub) == 1
# invalid descriptor
try:
print(uctypes.sizeof([]))
except TypeError:
Reported by Bandit.
tests/basics/io_buffered_writer.py
5 issues
Line: 1
Column: 1
import uio as io
try:
io.BytesIO
io.BufferedWriter
except AttributeError:
print('SKIP')
raise SystemExit
Reported by Pylint.
Line: 4
Column: 5
import uio as io
try:
io.BytesIO
io.BufferedWriter
except AttributeError:
print('SKIP')
raise SystemExit
Reported by Pylint.
Line: 5
Column: 5
try:
io.BytesIO
io.BufferedWriter
except AttributeError:
print('SKIP')
raise SystemExit
bts = io.BytesIO()
Reported by Pylint.
Line: 8
Column: 5
io.BufferedWriter
except AttributeError:
print('SKIP')
raise SystemExit
bts = io.BytesIO()
buf = io.BufferedWriter(bts, 8)
buf.write(b"foobar")
Reported by Pylint.
Line: 1
Column: 1
import uio as io
try:
io.BytesIO
io.BufferedWriter
except AttributeError:
print('SKIP')
raise SystemExit
Reported by Pylint.
tests/basics/int_big_zeroone.py
5 issues
Line: 1
Column: 1
# test [0,-0,1,-1] edge cases of bignum
long_zero = (2**64) >> 65
long_neg_zero = -long_zero
long_one = long_zero + 1
long_neg_one = -long_one
cases = [long_zero, long_neg_zero, long_one, long_neg_one]
Reported by Pylint.
Line: 3
Column: 1
# test [0,-0,1,-1] edge cases of bignum
long_zero = (2**64) >> 65
long_neg_zero = -long_zero
long_one = long_zero + 1
long_neg_one = -long_one
cases = [long_zero, long_neg_zero, long_one, long_neg_one]
Reported by Pylint.
Line: 4
Column: 1
# test [0,-0,1,-1] edge cases of bignum
long_zero = (2**64) >> 65
long_neg_zero = -long_zero
long_one = long_zero + 1
long_neg_one = -long_one
cases = [long_zero, long_neg_zero, long_one, long_neg_one]
Reported by Pylint.
Line: 5
Column: 1
long_zero = (2**64) >> 65
long_neg_zero = -long_zero
long_one = long_zero + 1
long_neg_one = -long_one
cases = [long_zero, long_neg_zero, long_one, long_neg_one]
print(cases)
Reported by Pylint.
Line: 6
Column: 1
long_zero = (2**64) >> 65
long_neg_zero = -long_zero
long_one = long_zero + 1
long_neg_one = -long_one
cases = [long_zero, long_neg_zero, long_one, long_neg_one]
print(cases)
print([-c for c in cases])
Reported by Pylint.
tests/extmod/uctypes_array_assign_native_le_intbig.py
5 issues
Line: 1
Column: 1
import usys
try:
import uctypes
except ImportError:
print("SKIP")
raise SystemExit
if usys.byteorder != "little":
Reported by Pylint.
Line: 7
Column: 5
import uctypes
except ImportError:
print("SKIP")
raise SystemExit
if usys.byteorder != "little":
print("SKIP")
raise SystemExit
Reported by Pylint.
Line: 1
Column: 1
import usys
try:
import uctypes
except ImportError:
print("SKIP")
raise SystemExit
if usys.byteorder != "little":
Reported by Pylint.
Line: 37
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
# assign int64
S.arr11[0] = 0x11223344
print(hex(S.arr11[0]))
assert hex(S.arr11[0]) == "0x11223344"
# assign uint64
S.arr12[0] = 0x11223344
print(hex(S.arr12[0]))
assert hex(S.arr12[0]) == "0x11223344"
Reported by Bandit.
Line: 42
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
# assign uint64
S.arr12[0] = 0x11223344
print(hex(S.arr12[0]))
assert hex(S.arr12[0]) == "0x11223344"
Reported by Bandit.
tests/micropython/viper_binop_comp_imm.py
5 issues
Line: 2
Column: 2
# comparisons with immediate boundary values
@micropython.viper
def f(a: int):
print(a == -1, a == -255, a == -256, a == -257)
f(-1)
f(-255)
f(-256)
Reported by Pylint.
Line: 1
Column: 1
# comparisons with immediate boundary values
@micropython.viper
def f(a: int):
print(a == -1, a == -255, a == -256, a == -257)
f(-1)
f(-255)
f(-256)
Reported by Pylint.
Line: 3
Column: 1
# comparisons with immediate boundary values
@micropython.viper
def f(a: int):
print(a == -1, a == -255, a == -256, a == -257)
f(-1)
f(-255)
f(-256)
Reported by Pylint.
Line: 3
Column: 1
# comparisons with immediate boundary values
@micropython.viper
def f(a: int):
print(a == -1, a == -255, a == -256, a == -257)
f(-1)
f(-255)
f(-256)
Reported by Pylint.
Line: 3
Column: 1
# comparisons with immediate boundary values
@micropython.viper
def f(a: int):
print(a == -1, a == -255, a == -256, a == -257)
f(-1)
f(-255)
f(-256)
Reported by Pylint.
ports/mimxrt/boards/TEENSY40/format.py
5 issues
Line: 5
Column: 1
# Re-create the file system
import os
import mimxrt
bdev = mimxrt.Flash()
os.VfsLfs2.mkfs(bdev, progsize=256)
vfs = os.VfsLfs2(bdev, progsize=256)
Reported by Pylint.
Line: 9
Column: 1
bdev = mimxrt.Flash()
os.VfsLfs2.mkfs(bdev, progsize=256)
vfs = os.VfsLfs2(bdev, progsize=256)
os.mount(vfs, "/")
Reported by Pylint.
Line: 10
Column: 7
bdev = mimxrt.Flash()
os.VfsLfs2.mkfs(bdev, progsize=256)
vfs = os.VfsLfs2(bdev, progsize=256)
os.mount(vfs, "/")
Reported by Pylint.
Line: 11
Column: 1
os.VfsLfs2.mkfs(bdev, progsize=256)
vfs = os.VfsLfs2(bdev, progsize=256)
os.mount(vfs, "/")
Reported by Pylint.
Line: 1
Column: 1
# format.py
# Re-create the file system
import os
import mimxrt
bdev = mimxrt.Flash()
os.VfsLfs2.mkfs(bdev, progsize=256)
Reported by Pylint.