The following issues were found
tests/basics/builtin_eval_buffer.py
9 issues
Line: 4
Column: 5
# test builtin eval with a buffer (bytearray/memoryview) input
try:
eval
bytearray
memoryview
except:
print("SKIP")
raise SystemExit
Reported by Pylint.
Line: 5
Column: 5
try:
eval
bytearray
memoryview
except:
print("SKIP")
raise SystemExit
Reported by Pylint.
Line: 6
Column: 5
try:
eval
bytearray
memoryview
except:
print("SKIP")
raise SystemExit
print(eval(bytearray(b'1 + 1')))
Reported by Pylint.
Line: 9
Column: 5
memoryview
except:
print("SKIP")
raise SystemExit
print(eval(bytearray(b'1 + 1')))
print(eval(memoryview(b'2 + 2')))
Reported by Pylint.
Line: 11
Column: 7
print("SKIP")
raise SystemExit
print(eval(bytearray(b'1 + 1')))
print(eval(memoryview(b'2 + 2')))
Reported by Pylint.
Line: 11
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval
print("SKIP")
raise SystemExit
print(eval(bytearray(b'1 + 1')))
print(eval(memoryview(b'2 + 2')))
Reported by Bandit.
Line: 12
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval
raise SystemExit
print(eval(bytearray(b'1 + 1')))
print(eval(memoryview(b'2 + 2')))
Reported by Bandit.
Line: 12
Column: 7
raise SystemExit
print(eval(bytearray(b'1 + 1')))
print(eval(memoryview(b'2 + 2')))
Reported by Pylint.
Line: 1
Column: 1
# test builtin eval with a buffer (bytearray/memoryview) input
try:
eval
bytearray
memoryview
except:
print("SKIP")
raise SystemExit
Reported by Pylint.
tests/internal_bench/funcall-3-funcall-local.py
9 issues
Line: 16
Column: 9
def test(num):
f_ = f
for i in iter(range(num)):
a = f_(i)
bench.run(test)
Reported by Pylint.
Line: 1
Column: 1
# Function call overhead test
# Perform the same trivial operation as calling function, cached in a
# local variable. This is commonly known optimization for overly dynamic
# languages (the idea is to cut on symbolic look up overhead, as local
# variables are accessed by offset, not by name)
import bench
def f(x):
Reported by Pylint.
Line: 1
Column: 1
# Function call overhead test
# Perform the same trivial operation as calling function, cached in a
# local variable. This is commonly known optimization for overly dynamic
# languages (the idea is to cut on symbolic look up overhead, as local
# variables are accessed by offset, not by name)
import bench
def f(x):
Reported by Pylint.
Line: 9
Column: 1
import bench
def f(x):
return x + 1
def test(num):
f_ = f
Reported by Pylint.
Line: 9
Column: 1
import bench
def f(x):
return x + 1
def test(num):
f_ = f
Reported by Pylint.
Line: 9
Column: 1
import bench
def f(x):
return x + 1
def test(num):
f_ = f
Reported by Pylint.
Line: 13
Column: 1
return x + 1
def test(num):
f_ = f
for i in iter(range(num)):
a = f_(i)
Reported by Pylint.
Line: 14
Column: 5
def test(num):
f_ = f
for i in iter(range(num)):
a = f_(i)
bench.run(test)
Reported by Pylint.
Line: 16
Column: 9
def test(num):
f_ = f
for i in iter(range(num)):
a = f_(i)
bench.run(test)
Reported by Pylint.
ports/esp8266/modules/port_diag.py
9 issues
Line: 1
Column: 1
import esp
import uctypes
import network
import lwip
def main():
ROM = uctypes.bytearray_at(0x40200000, 16)
Reported by Pylint.
Line: 2
Column: 1
import esp
import uctypes
import network
import lwip
def main():
ROM = uctypes.bytearray_at(0x40200000, 16)
Reported by Pylint.
Line: 3
Column: 1
import esp
import uctypes
import network
import lwip
def main():
ROM = uctypes.bytearray_at(0x40200000, 16)
Reported by Pylint.
Line: 4
Column: 1
import esp
import uctypes
import network
import lwip
def main():
ROM = uctypes.bytearray_at(0x40200000, 16)
Reported by Pylint.
Line: 1
Column: 1
import esp
import uctypes
import network
import lwip
def main():
ROM = uctypes.bytearray_at(0x40200000, 16)
Reported by Pylint.
Line: 7
Column: 1
import lwip
def main():
ROM = uctypes.bytearray_at(0x40200000, 16)
fid = esp.flash_id()
print("FlashROM:")
Reported by Pylint.
Line: 9
Column: 5
def main():
ROM = uctypes.bytearray_at(0x40200000, 16)
fid = esp.flash_id()
print("FlashROM:")
print("Flash ID: %x (Vendor: %x Device: %x)" % (fid, fid & 0xFF, fid & 0xFF00 | fid >> 16))
Reported by Pylint.
Line: 16
Column: 5
print("Flash ID: %x (Vendor: %x Device: %x)" % (fid, fid & 0xFF, fid & 0xFF00 | fid >> 16))
print("Flash bootloader data:")
SZ_MAP = {0: "512KB", 1: "256KB", 2: "1MB", 3: "2MB", 4: "4MB"}
FREQ_MAP = {0: "40MHZ", 1: "26MHZ", 2: "20MHz", 0xF: "80MHz"}
print("Byte @2: %02x" % ROM[2])
print(
"Byte @3: %02x (Flash size: %s Flash freq: %s)"
% (ROM[3], SZ_MAP.get(ROM[3] >> 4, "?"), FREQ_MAP.get(ROM[3] & 0xF))
Reported by Pylint.
Line: 17
Column: 5
print("Flash bootloader data:")
SZ_MAP = {0: "512KB", 1: "256KB", 2: "1MB", 3: "2MB", 4: "4MB"}
FREQ_MAP = {0: "40MHZ", 1: "26MHZ", 2: "20MHz", 0xF: "80MHz"}
print("Byte @2: %02x" % ROM[2])
print(
"Byte @3: %02x (Flash size: %s Flash freq: %s)"
% (ROM[3], SZ_MAP.get(ROM[3] >> 4, "?"), FREQ_MAP.get(ROM[3] & 0xF))
)
Reported by Pylint.
ports/esp32/modules/inisetup.py
9 issues
Line: 1
Column: 1
import uos
from flashbdev import bdev
def check_bootsec():
buf = bytearray(bdev.ioctl(5, 0)) # 5 is SEC_SIZE
bdev.readblocks(0, buf)
empty = True
for b in buf:
Reported by Pylint.
Line: 1
Column: 1
import uos
from flashbdev import bdev
def check_bootsec():
buf = bytearray(bdev.ioctl(5, 0)) # 5 is SEC_SIZE
bdev.readblocks(0, buf)
empty = True
for b in buf:
Reported by Pylint.
Line: 5
Column: 1
from flashbdev import bdev
def check_bootsec():
buf = bytearray(bdev.ioctl(5, 0)) # 5 is SEC_SIZE
bdev.readblocks(0, buf)
empty = True
for b in buf:
if b != 0xFF:
Reported by Pylint.
Line: 5
Column: 1
from flashbdev import bdev
def check_bootsec():
buf = bytearray(bdev.ioctl(5, 0)) # 5 is SEC_SIZE
bdev.readblocks(0, buf)
empty = True
for b in buf:
if b != 0xFF:
Reported by Pylint.
Line: 9
Column: 9
buf = bytearray(bdev.ioctl(5, 0)) # 5 is SEC_SIZE
bdev.readblocks(0, buf)
empty = True
for b in buf:
if b != 0xFF:
empty = False
break
if empty:
return True
Reported by Pylint.
Line: 18
Column: 1
fs_corrupted()
def fs_corrupted():
import time
while 1:
print(
"""\
Reported by Pylint.
Line: 19
Column: 5
def fs_corrupted():
import time
while 1:
print(
"""\
The filesystem appears to be corrupted. If you had important data there, you
Reported by Pylint.
Line: 33
Column: 1
time.sleep(3)
def setup():
check_bootsec()
print("Performing initial setup")
uos.VfsLfs2.mkfs(bdev)
vfs = uos.VfsLfs2(bdev)
uos.mount(vfs, "/")
Reported by Pylint.
Line: 39
Column: 34
uos.VfsLfs2.mkfs(bdev)
vfs = uos.VfsLfs2(bdev)
uos.mount(vfs, "/")
with open("boot.py", "w") as f:
f.write(
"""\
# This file is executed on every boot (including wake-boot from deepsleep)
#import esp
#esp.osdebug(None)
Reported by Pylint.
tests/basics/fun_error.py
9 issues
Line: 42
Column: 5
# kw given for positional, but a different positional is missing
try:
def f(x, y): pass
f(x=1)
except TypeError:
print('TypeError')
Reported by Pylint.
Line: 41
Column: 11
# kw given for positional, but a different positional is missing
try:
def f(x, y): pass
f(x=1)
except TypeError:
print('TypeError')
Reported by Pylint.
Line: 41
Column: 14
# kw given for positional, but a different positional is missing
try:
def f(x, y): pass
f(x=1)
except TypeError:
print('TypeError')
Reported by Pylint.
Line: 1
Column: 1
# test errors from bad function calls
# function doesn't take keyword args
try:
[].append(x=1)
except TypeError:
print('TypeError')
# function with variable number of positional args given too few
Reported by Pylint.
Line: 41
Column: 18
# kw given for positional, but a different positional is missing
try:
def f(x, y): pass
f(x=1)
except TypeError:
print('TypeError')
Reported by Pylint.
Line: 41
Column: 5
# kw given for positional, but a different positional is missing
try:
def f(x, y): pass
f(x=1)
except TypeError:
print('TypeError')
Reported by Pylint.
Line: 41
Column: 5
# kw given for positional, but a different positional is missing
try:
def f(x, y): pass
f(x=1)
except TypeError:
print('TypeError')
Reported by Pylint.
Line: 41
Column: 5
# kw given for positional, but a different positional is missing
try:
def f(x, y): pass
f(x=1)
except TypeError:
print('TypeError')
Reported by Pylint.
Line: 41
Column: 5
# kw given for positional, but a different positional is missing
try:
def f(x, y): pass
f(x=1)
except TypeError:
print('TypeError')
Reported by Pylint.
tests/thread/thread_exc1.py
9 issues
Line: 19
Column: 9
pass
with lock:
global n_finished
n_finished += 1
lock = _thread.allocate_lock()
n_thread = 4
n_finished = 0
Reported by Pylint.
Line: 18
Column: 9
except ValueError:
pass
with lock:
global n_finished
n_finished += 1
lock = _thread.allocate_lock()
n_thread = 4
Reported by Pylint.
Line: 1
Column: 1
# test raising and catching an exception within a thread
#
# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
import _thread
def foo():
raise ValueError
Reported by Pylint.
Line: 8
Column: 1
import _thread
def foo():
raise ValueError
def thread_entry():
try:
Reported by Pylint.
Line: 8
Column: 1
import _thread
def foo():
raise ValueError
def thread_entry():
try:
Reported by Pylint.
Line: 12
Column: 1
raise ValueError
def thread_entry():
try:
foo()
except ValueError:
pass
with lock:
Reported by Pylint.
Line: 18
Column: 9
except ValueError:
pass
with lock:
global n_finished
n_finished += 1
lock = _thread.allocate_lock()
n_thread = 4
Reported by Pylint.
Line: 23
Column: 1
lock = _thread.allocate_lock()
n_thread = 4
n_finished = 0
# spawn threads
for i in range(n_thread):
while True:
Reported by Pylint.
Line: 24
Column: 1
lock = _thread.allocate_lock()
n_thread = 4
n_finished = 0
# spawn threads
for i in range(n_thread):
while True:
try:
Reported by Pylint.
tests/basics/try3.py
9 issues
Line: 5
Column: 9
def f():
try:
foo()
except:
print("except 1")
try:
baz()
except:
Reported by Pylint.
Line: 9
Column: 13
except:
print("except 1")
try:
baz()
except:
print("except 2")
bar()
try:
Reported by Pylint.
Line: 12
Column: 9
baz()
except:
print("except 2")
bar()
try:
f()
except:
print("f except")
Reported by Pylint.
Line: 6
Column: 5
def f():
try:
foo()
except:
print("except 1")
try:
baz()
except:
print("except 2")
Reported by Pylint.
Line: 10
Column: 9
print("except 1")
try:
baz()
except:
print("except 2")
bar()
try:
f()
Reported by Pylint.
Line: 16
Column: 1
try:
f()
except:
print("f except")
Reported by Pylint.
Line: 1
Column: 1
# nested exceptions
def f():
try:
foo()
except:
print("except 1")
try:
baz()
Reported by Pylint.
Line: 3
Column: 1
# nested exceptions
def f():
try:
foo()
except:
print("except 1")
try:
baz()
Reported by Pylint.
Line: 3
Column: 1
# nested exceptions
def f():
try:
foo()
except:
print("except 1")
try:
baz()
Reported by Pylint.
ports/esp32/boards/manifest.py
9 issues
Line: 1
Column: 1
freeze("$(PORT_DIR)/modules")
freeze("$(MPY_DIR)/tools", ("upip.py", "upip_utarfile.py"))
freeze("$(MPY_DIR)/ports/esp8266/modules", "ntptime.py")
freeze("$(MPY_DIR)/drivers/dht", "dht.py")
freeze("$(MPY_DIR)/drivers/onewire")
include("$(MPY_DIR)/extmod/uasyncio/manifest.py")
include("$(MPY_DIR)/extmod/webrepl/manifest.py")
include("$(MPY_DIR)/drivers/neopixel/manifest.py")
Reported by Pylint.
Line: 2
Column: 1
freeze("$(PORT_DIR)/modules")
freeze("$(MPY_DIR)/tools", ("upip.py", "upip_utarfile.py"))
freeze("$(MPY_DIR)/ports/esp8266/modules", "ntptime.py")
freeze("$(MPY_DIR)/drivers/dht", "dht.py")
freeze("$(MPY_DIR)/drivers/onewire")
include("$(MPY_DIR)/extmod/uasyncio/manifest.py")
include("$(MPY_DIR)/extmod/webrepl/manifest.py")
include("$(MPY_DIR)/drivers/neopixel/manifest.py")
Reported by Pylint.
Line: 3
Column: 1
freeze("$(PORT_DIR)/modules")
freeze("$(MPY_DIR)/tools", ("upip.py", "upip_utarfile.py"))
freeze("$(MPY_DIR)/ports/esp8266/modules", "ntptime.py")
freeze("$(MPY_DIR)/drivers/dht", "dht.py")
freeze("$(MPY_DIR)/drivers/onewire")
include("$(MPY_DIR)/extmod/uasyncio/manifest.py")
include("$(MPY_DIR)/extmod/webrepl/manifest.py")
include("$(MPY_DIR)/drivers/neopixel/manifest.py")
Reported by Pylint.
Line: 4
Column: 1
freeze("$(PORT_DIR)/modules")
freeze("$(MPY_DIR)/tools", ("upip.py", "upip_utarfile.py"))
freeze("$(MPY_DIR)/ports/esp8266/modules", "ntptime.py")
freeze("$(MPY_DIR)/drivers/dht", "dht.py")
freeze("$(MPY_DIR)/drivers/onewire")
include("$(MPY_DIR)/extmod/uasyncio/manifest.py")
include("$(MPY_DIR)/extmod/webrepl/manifest.py")
include("$(MPY_DIR)/drivers/neopixel/manifest.py")
Reported by Pylint.
Line: 5
Column: 1
freeze("$(MPY_DIR)/tools", ("upip.py", "upip_utarfile.py"))
freeze("$(MPY_DIR)/ports/esp8266/modules", "ntptime.py")
freeze("$(MPY_DIR)/drivers/dht", "dht.py")
freeze("$(MPY_DIR)/drivers/onewire")
include("$(MPY_DIR)/extmod/uasyncio/manifest.py")
include("$(MPY_DIR)/extmod/webrepl/manifest.py")
include("$(MPY_DIR)/drivers/neopixel/manifest.py")
Reported by Pylint.
Line: 6
Column: 1
freeze("$(MPY_DIR)/ports/esp8266/modules", "ntptime.py")
freeze("$(MPY_DIR)/drivers/dht", "dht.py")
freeze("$(MPY_DIR)/drivers/onewire")
include("$(MPY_DIR)/extmod/uasyncio/manifest.py")
include("$(MPY_DIR)/extmod/webrepl/manifest.py")
include("$(MPY_DIR)/drivers/neopixel/manifest.py")
Reported by Pylint.
Line: 7
Column: 1
freeze("$(MPY_DIR)/drivers/dht", "dht.py")
freeze("$(MPY_DIR)/drivers/onewire")
include("$(MPY_DIR)/extmod/uasyncio/manifest.py")
include("$(MPY_DIR)/extmod/webrepl/manifest.py")
include("$(MPY_DIR)/drivers/neopixel/manifest.py")
Reported by Pylint.
Line: 8
Column: 1
freeze("$(MPY_DIR)/drivers/onewire")
include("$(MPY_DIR)/extmod/uasyncio/manifest.py")
include("$(MPY_DIR)/extmod/webrepl/manifest.py")
include("$(MPY_DIR)/drivers/neopixel/manifest.py")
Reported by Pylint.
Line: 1
Column: 1
freeze("$(PORT_DIR)/modules")
freeze("$(MPY_DIR)/tools", ("upip.py", "upip_utarfile.py"))
freeze("$(MPY_DIR)/ports/esp8266/modules", "ntptime.py")
freeze("$(MPY_DIR)/drivers/dht", "dht.py")
freeze("$(MPY_DIR)/drivers/onewire")
include("$(MPY_DIR)/extmod/uasyncio/manifest.py")
include("$(MPY_DIR)/extmod/webrepl/manifest.py")
include("$(MPY_DIR)/drivers/neopixel/manifest.py")
Reported by Pylint.
tests/basics/exceptpoly.py
9 issues
Line: 3
Column: 8
try:
raise ArithmeticError
except Exception:
print("Caught ArithmeticError via Exception")
try:
raise ArithmeticError
except ArithmeticError:
print("Caught ArithmeticError")
Reported by Pylint.
Line: 13
Column: 8
try:
raise AssertionError
except Exception:
print("Caught AssertionError via Exception")
try:
raise AssertionError
except AssertionError:
Reported by Pylint.
Line: 23
Column: 8
try:
raise AttributeError
except Exception:
print("Caught AttributeError via Exception")
try:
raise AttributeError
except AttributeError:
Reported by Pylint.
Line: 33
Column: 8
try:
raise EOFError
except Exception:
print("Caught EOFError via Exception")
try:
raise EOFError
except EOFError:
Reported by Pylint.
Line: 43
Column: 8
try:
raise Exception
except BaseException:
print("Caught Exception via BaseException")
try:
raise Exception
except Exception:
Reported by Pylint.
Line: 48
Column: 8
try:
raise Exception
except Exception:
print("Caught Exception")
try:
raise ImportError
except Exception:
Reported by Pylint.
Line: 53
Column: 8
try:
raise ImportError
except Exception:
print("Caught ImportError via Exception")
try:
raise ImportError
except ImportError:
Reported by Pylint.
Line: 93
Column: 8
try:
raise LookupError
except Exception:
print("Caught LookupError via Exception")
try:
raise LookupError
except LookupError:
Reported by Pylint.
Line: 1
Column: 1
try:
raise ArithmeticError
except Exception:
print("Caught ArithmeticError via Exception")
try:
raise ArithmeticError
except ArithmeticError:
print("Caught ArithmeticError")
Reported by Pylint.
tests/micropython/opt_level.py
9 issues
Line: 1
Column: 1
import micropython as micropython
# check we can get and set the level
micropython.opt_level(0)
print(micropython.opt_level())
micropython.opt_level(1)
print(micropython.opt_level())
# check that the optimisation levels actually differ
Reported by Pylint.
Line: 11
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html
# check that the optimisation levels actually differ
micropython.opt_level(0)
exec("print(__debug__)")
micropython.opt_level(1)
exec("print(__debug__)")
exec("assert 0")
Reported by Bandit.
Line: 11
Column: 1
# check that the optimisation levels actually differ
micropython.opt_level(0)
exec("print(__debug__)")
micropython.opt_level(1)
exec("print(__debug__)")
exec("assert 0")
Reported by Pylint.
Line: 13
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html
micropython.opt_level(0)
exec("print(__debug__)")
micropython.opt_level(1)
exec("print(__debug__)")
exec("assert 0")
Reported by Bandit.
Line: 13
Column: 1
micropython.opt_level(0)
exec("print(__debug__)")
micropython.opt_level(1)
exec("print(__debug__)")
exec("assert 0")
Reported by Pylint.
Line: 14
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html
exec("print(__debug__)")
micropython.opt_level(1)
exec("print(__debug__)")
exec("assert 0")
Reported by Bandit.
Line: 14
Column: 1
exec("print(__debug__)")
micropython.opt_level(1)
exec("print(__debug__)")
exec("assert 0")
Reported by Pylint.
Line: 1
Column: 1
import micropython as micropython
# check we can get and set the level
micropython.opt_level(0)
print(micropython.opt_level())
micropython.opt_level(1)
print(micropython.opt_level())
# check that the optimisation levels actually differ
Reported by Pylint.
Line: 1
Column: 1
import micropython as micropython
# check we can get and set the level
micropython.opt_level(0)
print(micropython.opt_level())
micropython.opt_level(1)
print(micropython.opt_level())
# check that the optimisation levels actually differ
Reported by Pylint.