The following issues were found
tests/extmod/ure_span.py
5 issues
Line: 10
Column: 9
import re
except ImportError:
print("SKIP")
raise SystemExit
try:
m = re.match(".", "a")
m.span
except AttributeError:
Reported by Pylint.
Line: 14
Column: 5
try:
m = re.match(".", "a")
m.span
except AttributeError:
print("SKIP")
raise SystemExit
Reported by Pylint.
Line: 17
Column: 5
m.span
except AttributeError:
print("SKIP")
raise SystemExit
def print_spans(match):
print("----")
try:
Reported by Pylint.
Line: 1
Column: 1
# test match.span(), and nested spans
try:
import ure as re
except ImportError:
try:
import re
except ImportError:
print("SKIP")
Reported by Pylint.
Line: 20
Column: 1
raise SystemExit
def print_spans(match):
print("----")
try:
i = 0
while True:
print(match.span(i), match.start(i), match.end(i))
Reported by Pylint.
ports/esp8266/makeimg.py
5 issues
Line: 14
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b303-md5
assert len(sys.argv) == 4
md5 = hashlib.md5()
with open(sys.argv[3], "wb") as fout:
with open(sys.argv[1], "rb") as f:
data_flash = f.read()
Reported by Bandit.
Line: 1
Column: 1
import sys
import struct
import hashlib
# This region at the start of flash contains a small header and then segments
# containing .text, .data and .rodata, and so must be large enough to hold all
# of this. This data is loaded to the appropriate places in RAM by the ROM
# bootloader at boot. After this in flash comes .irom0.text, which must begin
# on a flash erase-page boundary.
Reported by Pylint.
Line: 12
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
# on a flash erase-page boundary.
SEGS_MAX_SIZE = 0x9000
assert len(sys.argv) == 4
md5 = hashlib.md5()
with open(sys.argv[3], "wb") as fout:
Reported by Bandit.
Line: 28
Column: 9
# Print info about segments in this first part of flash
num_segs = struct.unpack_from("<BBBBI", data_flash, 0)[1]
offset = 8
for seg_num in range(num_segs):
seg_name = [".text", ".data", ".rodata"][seg_num]
seg_offset, seg_size = struct.unpack_from("<II", data_flash, offset)
print(" {:7} {} at 0x{:x}".format(seg_name, seg_size, seg_offset))
offset += 8 + seg_size
Reported by Pylint.
Line: 39
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
data_rom = f.read()
pad = b"\xff" * (SEGS_MAX_SIZE - len(data_flash))
assert len(pad) >= 4
fout.write(pad[:-4])
md5.update(pad[:-4])
len_data = struct.pack("I", SEGS_MAX_SIZE + len(data_rom))
fout.write(len_data)
md5.update(len_data)
Reported by Bandit.
tests/misc/sys_exc_info.py
5 issues
Line: 10
Column: 5
sys.exc_info
except:
print("SKIP")
raise SystemExit
def f():
print(sys.exc_info()[0:2])
Reported by Pylint.
Line: 19
Column: 1
try:
raise ValueError("value", 123)
except:
print(sys.exc_info()[0:2])
f()
# Outside except block, sys.exc_info() should be back to None's
f()
Reported by Pylint.
Line: 1
Column: 1
try:
import usys as sys
except ImportError:
import sys
try:
sys.exc_info
except:
print("SKIP")
Reported by Pylint.
Line: 13
Column: 1
raise SystemExit
def f():
print(sys.exc_info()[0:2])
try:
raise ValueError("value", 123)
Reported by Pylint.
Line: 13
Column: 1
raise SystemExit
def f():
print(sys.exc_info()[0:2])
try:
raise ValueError("value", 123)
Reported by Pylint.
tests/extmod/ure_limit.py
5 issues
Line: 7
Column: 5
import ure as re
except ImportError:
print("SKIP")
raise SystemExit
def test_re(r):
try:
re.compile(r)
Reported by Pylint.
Line: 13
Column: 5
def test_re(r):
try:
re.compile(r)
except:
print("Error")
# too many chars in []
test_re("[" + "a" * 256 + "]")
Reported by Pylint.
Line: 1
Column: 1
# Test overflow in ure.compile output code.
try:
import ure as re
except ImportError:
print("SKIP")
raise SystemExit
Reported by Pylint.
Line: 10
Column: 1
raise SystemExit
def test_re(r):
try:
re.compile(r)
except:
print("Error")
Reported by Pylint.
Line: 10
Column: 1
raise SystemExit
def test_re(r):
try:
re.compile(r)
except:
print("Error")
Reported by Pylint.
ports/nrf/examples/musictest.py
5 issues
Line: 8
Column: 1
# play("P3")
#
from machine import Pin
import music
def play(pin_str):
p = Pin(pin_str, mode=Pin.OUT)
Reported by Pylint.
Line: 9
Column: 1
#
from machine import Pin
import music
def play(pin_str):
p = Pin(pin_str, mode=Pin.OUT)
music.play(music.PRELUDE, pin=p)
Reported by Pylint.
Line: 1
Column: 1
#
# Example usage where "P3" is the Buzzer pin.
#
# from musictest import play
# play("P3")
#
from machine import Pin
import music
Reported by Pylint.
Line: 12
Column: 1
import music
def play(pin_str):
p = Pin(pin_str, mode=Pin.OUT)
music.play(music.PRELUDE, pin=p)
Reported by Pylint.
Line: 13
Column: 5
def play(pin_str):
p = Pin(pin_str, mode=Pin.OUT)
music.play(music.PRELUDE, pin=p)
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.
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.
tests/basics/builtin_slice.py
5 issues
Line: 1
Column: 1
# test builtin slice
# print slice
class A:
def __getitem__(self, idx):
print(idx)
return idx
s = A()[1:2:3]
Reported by Pylint.
Line: 4
Column: 1
# test builtin slice
# print slice
class A:
def __getitem__(self, idx):
print(idx)
return idx
s = A()[1:2:3]
Reported by Pylint.
Line: 4
Column: 1
# test builtin slice
# print slice
class A:
def __getitem__(self, idx):
print(idx)
return idx
s = A()[1:2:3]
Reported by Pylint.
Line: 4
Column: 1
# test builtin slice
# print slice
class A:
def __getitem__(self, idx):
print(idx)
return idx
s = A()[1:2:3]
Reported by Pylint.
Line: 11
Column: 7
s = A()[1:2:3]
# check type
print(type(s) is slice)
Reported by Pylint.
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/extmod/ujson_dump_separators.py
5 issues
Line: 2
Column: 5
try:
from uio import StringIO
import ujson as json
except:
try:
from io import StringIO
import json
except ImportError:
print("SKIP")
Reported by Pylint.
Line: 3
Column: 5
try:
from uio import StringIO
import ujson as json
except:
try:
from io import StringIO
import json
except ImportError:
print("SKIP")
Reported by Pylint.
Line: 4
Column: 1
try:
from uio import StringIO
import ujson as json
except:
try:
from io import StringIO
import json
except ImportError:
print("SKIP")
Reported by Pylint.
Line: 10
Column: 9
import json
except ImportError:
print("SKIP")
raise SystemExit
for sep in [
None,
(", ", ": "),
(",", ": "),
Reported by Pylint.
Line: 1
Column: 1
try:
from uio import StringIO
import ujson as json
except:
try:
from io import StringIO
import json
except ImportError:
print("SKIP")
Reported by Pylint.