The following issues were found
tests/float/cmath_fun.py
27 issues
Line: 4
Column: 5
# test the functions imported from cmath
try:
from cmath import *
except ImportError:
print("SKIP")
raise SystemExit
# make sure these constants exist in cmath
Reported by Pylint.
Line: 4
Column: 5
# test the functions imported from cmath
try:
from cmath import *
except ImportError:
print("SKIP")
raise SystemExit
# make sure these constants exist in cmath
Reported by Pylint.
Line: 4
Column: 5
# test the functions imported from cmath
try:
from cmath import *
except ImportError:
print("SKIP")
raise SystemExit
# make sure these constants exist in cmath
Reported by Pylint.
Line: 4
Column: 5
# test the functions imported from cmath
try:
from cmath import *
except ImportError:
print("SKIP")
raise SystemExit
# make sure these constants exist in cmath
Reported by Pylint.
Line: 4
Column: 5
# test the functions imported from cmath
try:
from cmath import *
except ImportError:
print("SKIP")
raise SystemExit
# make sure these constants exist in cmath
Reported by Pylint.
Line: 4
Column: 5
# test the functions imported from cmath
try:
from cmath import *
except ImportError:
print("SKIP")
raise SystemExit
# make sure these constants exist in cmath
Reported by Pylint.
Line: 4
Column: 5
# test the functions imported from cmath
try:
from cmath import *
except ImportError:
print("SKIP")
raise SystemExit
# make sure these constants exist in cmath
Reported by Pylint.
Line: 4
Column: 5
# test the functions imported from cmath
try:
from cmath import *
except ImportError:
print("SKIP")
raise SystemExit
# make sure these constants exist in cmath
Reported by Pylint.
Line: 4
Column: 5
# test the functions imported from cmath
try:
from cmath import *
except ImportError:
print("SKIP")
raise SystemExit
# make sure these constants exist in cmath
Reported by Pylint.
Line: 4
Column: 5
# test the functions imported from cmath
try:
from cmath import *
except ImportError:
print("SKIP")
raise SystemExit
# make sure these constants exist in cmath
Reported by Pylint.
tests/esp32/resolve_on_connect.py
27 issues
Line: 9
Column: 5
raise SystemExit
try:
import usocket as socket, sys
except:
import socket, sys
def test_bind_resolves_0_0_0_0():
Reported by Pylint.
Line: 10
Column: 1
try:
import usocket as socket, sys
except:
import socket, sys
def test_bind_resolves_0_0_0_0():
s = socket.socket()
Reported by Pylint.
Line: 11
Column: 5
try:
import usocket as socket, sys
except:
import socket, sys
def test_bind_resolves_0_0_0_0():
s = socket.socket()
try:
Reported by Pylint.
Line: 17
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b104_hardcoded_bind_all_interfaces.html
def test_bind_resolves_0_0_0_0():
s = socket.socket()
try:
s.bind(("0.0.0.0", 31245))
print("bind actually bound")
s.close()
except Exception as e:
print("bind raised", e)
Reported by Bandit.
Line: 20
Column: 12
s.bind(("0.0.0.0", 31245))
print("bind actually bound")
s.close()
except Exception as e:
print("bind raised", e)
def test_bind_resolves_localhost():
s = socket.socket()
Reported by Pylint.
Line: 30
Column: 12
s.bind(("localhost", 31245))
print("bind actually bound")
s.close()
except Exception as e:
print("bind raised", e)
def test_connect_resolves():
s = socket.socket()
Reported by Pylint.
Line: 40
Column: 12
s.connect(("micropython.org", 80))
print("connect actually connected")
s.close()
except Exception as e:
print("connect raised", e)
def test_connect_non_existent():
s = socket.socket()
Reported by Pylint.
Line: 52
Column: 12
s.close()
except OSError as e:
print("connect raised OSError")
except Exception as e:
print("connect raised", e)
test_funs = [n for n in dir() if n.startswith("test_")]
for f in sorted(test_funs):
Reported by Pylint.
Line: 59
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval
test_funs = [n for n in dir() if n.startswith("test_")]
for f in sorted(test_funs):
print("--", f, end=": ")
eval(f + "()")
Reported by Bandit.
Line: 59
Column: 5
test_funs = [n for n in dir() if n.startswith("test_")]
for f in sorted(test_funs):
print("--", f, end=": ")
eval(f + "()")
Reported by Pylint.
tools/upip_utarfile.py
27 issues
Line: 1
Column: 1
import uctypes
# http://www.gnu.org/software/tar/manual/html_node/Standard.html
TAR_HEADER = {
"name": (uctypes.ARRAY | 0, uctypes.UINT8 | 100),
"size": (uctypes.ARRAY | 124, uctypes.UINT8 | 11),
}
DIRTYPE = "dir"
Reported by Pylint.
Line: 79
Column: 9
return None
d = TarInfo()
d.name = str(h.name, "utf-8").rstrip("\0")
d.size = int(bytes(h.size), 8)
d.type = [REGTYPE, DIRTYPE][d.name[-1] == "/"]
self.subf = d.subf = FileSection(self.f, d.size, roundup(d.size, 512))
return d
Reported by Pylint.
Line: 80
Column: 9
d = TarInfo()
d.name = str(h.name, "utf-8").rstrip("\0")
d.size = int(bytes(h.size), 8)
d.type = [REGTYPE, DIRTYPE][d.name[-1] == "/"]
self.subf = d.subf = FileSection(self.f, d.size, roundup(d.size, 512))
return d
def __iter__(self):
Reported by Pylint.
Line: 81
Column: 9
d = TarInfo()
d.name = str(h.name, "utf-8").rstrip("\0")
d.size = int(bytes(h.size), 8)
d.type = [REGTYPE, DIRTYPE][d.name[-1] == "/"]
self.subf = d.subf = FileSection(self.f, d.size, roundup(d.size, 512))
return d
def __iter__(self):
return self
Reported by Pylint.
Line: 82
Column: 21
d.name = str(h.name, "utf-8").rstrip("\0")
d.size = int(bytes(h.size), 8)
d.type = [REGTYPE, DIRTYPE][d.name[-1] == "/"]
self.subf = d.subf = FileSection(self.f, d.size, roundup(d.size, 512))
return d
def __iter__(self):
return self
Reported by Pylint.
Line: 1
Column: 1
import uctypes
# http://www.gnu.org/software/tar/manual/html_node/Standard.html
TAR_HEADER = {
"name": (uctypes.ARRAY | 0, uctypes.UINT8 | 100),
"size": (uctypes.ARRAY | 124, uctypes.UINT8 | 11),
}
DIRTYPE = "dir"
Reported by Pylint.
Line: 13
Column: 1
REGTYPE = "file"
def roundup(val, align):
return (val + align - 1) & ~(align - 1)
class FileSection:
def __init__(self, f, content_len, aligned_len):
Reported by Pylint.
Line: 17
Column: 1
return (val + align - 1) & ~(align - 1)
class FileSection:
def __init__(self, f, content_len, aligned_len):
self.f = f
self.content_len = content_len
self.align = aligned_len - content_len
Reported by Pylint.
Line: 19
Column: 9
class FileSection:
def __init__(self, f, content_len, aligned_len):
self.f = f
self.content_len = content_len
self.align = aligned_len - content_len
def read(self, sz=65536):
if self.content_len == 0:
Reported by Pylint.
Line: 23
Column: 5
self.content_len = content_len
self.align = aligned_len - content_len
def read(self, sz=65536):
if self.content_len == 0:
return b""
if sz > self.content_len:
sz = self.content_len
data = self.f.read(sz)
Reported by Pylint.
tests/basics/fun_kwonlydef.py
27 issues
Line: 32
Column: 1
f4(f=6, e=55, d=4, c=33, b=2, a=11)
# positional with default, then keyword only
def f5(a, b=4, *c, d=8):
print(a, b, c, d)
f5(1)
f5(1, d=9)
f5(1, b=44, d=9)
Reported by Pylint.
Line: 1
Column: 1
# test function args, keyword only with default value
# a single arg with a default
def f1(*, a=1):
print(a)
f1()
f1(a=2)
# 1 arg default, 1 not
Reported by Pylint.
Line: 4
Column: 1
# test function args, keyword only with default value
# a single arg with a default
def f1(*, a=1):
print(a)
f1()
f1(a=2)
# 1 arg default, 1 not
Reported by Pylint.
Line: 4
Column: 1
# test function args, keyword only with default value
# a single arg with a default
def f1(*, a=1):
print(a)
f1()
f1(a=2)
# 1 arg default, 1 not
Reported by Pylint.
Line: 4
Column: 11
# test function args, keyword only with default value
# a single arg with a default
def f1(*, a=1):
print(a)
f1()
f1(a=2)
# 1 arg default, 1 not
Reported by Pylint.
Line: 10
Column: 16
f1(a=2)
# 1 arg default, 1 not
def f2(*, a=1, b):
print(a, b)
f2(b=2)
f2(a=2, b=3)
# 1 positional, 1 arg default, 1 not
Reported by Pylint.
Line: 10
Column: 1
f1(a=2)
# 1 arg default, 1 not
def f2(*, a=1, b):
print(a, b)
f2(b=2)
f2(a=2, b=3)
# 1 positional, 1 arg default, 1 not
Reported by Pylint.
Line: 10
Column: 11
f1(a=2)
# 1 arg default, 1 not
def f2(*, a=1, b):
print(a, b)
f2(b=2)
f2(a=2, b=3)
# 1 positional, 1 arg default, 1 not
Reported by Pylint.
Line: 10
Column: 1
f1(a=2)
# 1 arg default, 1 not
def f2(*, a=1, b):
print(a, b)
f2(b=2)
f2(a=2, b=3)
# 1 positional, 1 arg default, 1 not
Reported by Pylint.
Line: 16
Column: 19
f2(a=2, b=3)
# 1 positional, 1 arg default, 1 not
def f3(a, *, b=2, c):
print(a, b, c)
f3(1, c=3)
f3(1, b=3, c=4)
f3(1, **{'c':3})
f3(1, **{'b':'3', 'c':4})
Reported by Pylint.
tests/pyb/can.py
27 issues
Line: 8
Column: 1
raise SystemExit
from array import array
import micropython
import pyb
# test we can correctly create by id (2 handled in can2.py test)
for bus in (-1, 0, 1, 3):
try:
Reported by Pylint.
Line: 9
Column: 1
from array import array
import micropython
import pyb
# test we can correctly create by id (2 handled in can2.py test)
for bus in (-1, 0, 1, 3):
try:
CAN(bus, CAN.LOOPBACK)
Reported by Pylint.
Line: 5
Column: 5
from pyb import CAN
except ImportError:
print("SKIP")
raise SystemExit
from array import array
import micropython
import pyb
Reported by Pylint.
Line: 180
Column: 9
can.setfilter(1, CAN.LIST16, 1, (5, 6, 7, 8))
def cb0(bus, reason):
print("cb0")
if reason == 0:
print("pending")
if reason == 1:
print("full")
Reported by Pylint.
Line: 180
Column: 9
can.setfilter(1, CAN.LIST16, 1, (5, 6, 7, 8))
def cb0(bus, reason):
print("cb0")
if reason == 0:
print("pending")
if reason == 1:
print("full")
Reported by Pylint.
Line: 190
Column: 9
print("overflow")
def cb1(bus, reason):
print("cb1")
if reason == 0:
print("pending")
if reason == 1:
print("full")
Reported by Pylint.
Line: 190
Column: 9
print("overflow")
def cb1(bus, reason):
print("cb1")
if reason == 0:
print("pending")
if reason == 1:
print("full")
Reported by Pylint.
Line: 200
Column: 10
print("overflow")
def cb0a(bus, reason):
print("cb0a")
if reason == 0:
print("pending")
if reason == 1:
print("full")
Reported by Pylint.
Line: 200
Column: 10
print("overflow")
def cb0a(bus, reason):
print("cb0a")
if reason == 0:
print("pending")
if reason == 1:
print("full")
Reported by Pylint.
Line: 210
Column: 10
print("overflow")
def cb1a(bus, reason):
print("cb1a")
if reason == 0:
print("pending")
if reason == 1:
print("full")
Reported by Pylint.
tests/multi_net/uasyncio_tcp_readinto.py
27 issues
Line: 44
Column: 5
ev = asyncio.Event()
server = await asyncio.start_server(handle_connection, "0.0.0.0", PORT)
print("server running")
multitest.next()
async with server:
await asyncio.wait_for(ev.wait(), 10)
async def tcp_client():
Reported by Pylint.
Line: 50
Column: 52
async def tcp_client():
reader, writer = await asyncio.open_connection(IP, PORT)
ba = bytearray(2)
n = await reader.readinto(ba)
print(n)
print(ba[:n])
Reported by Pylint.
Line: 74
Column: 26
def instance0():
multitest.globals(IP=multitest.get_network_ip())
asyncio.run(tcp_server())
def instance1():
multitest.next()
Reported by Pylint.
Line: 74
Column: 5
def instance0():
multitest.globals(IP=multitest.get_network_ip())
asyncio.run(tcp_server())
def instance1():
multitest.next()
Reported by Pylint.
Line: 79
Column: 5
def instance1():
multitest.next()
asyncio.run(tcp_client())
Reported by Pylint.
Line: 10
Column: 9
import asyncio
except ImportError:
print("SKIP")
raise SystemExit
try:
import uarray as array
except ImportError:
try:
Reported by Pylint.
Line: 19
Column: 9
import array
except ImportError:
print("SKIP")
raise SystemExit
PORT = 8000
async def handle_connection(reader, writer):
Reported by Pylint.
Line: 24
Column: 29
PORT = 8000
async def handle_connection(reader, writer):
writer.write(b"ab")
await writer.drain()
writer.write(b"c")
await writer.drain()
Reported by Pylint.
Line: 40
Column: 5
async def tcp_server():
global ev
ev = asyncio.Event()
server = await asyncio.start_server(handle_connection, "0.0.0.0", PORT)
print("server running")
multitest.next()
async with server:
Reported by Pylint.
Line: 42
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b104_hardcoded_bind_all_interfaces.html
async def tcp_server():
global ev
ev = asyncio.Event()
server = await asyncio.start_server(handle_connection, "0.0.0.0", PORT)
print("server running")
multitest.next()
async with server:
await asyncio.wait_for(ev.wait(), 10)
Reported by Bandit.
tests/extmod/vfs_lfs_file.py
27 issues
Line: 6
Column: 5
try:
import uos
uos.VfsLfs1
uos.VfsLfs2
except (ImportError, AttributeError):
print("SKIP")
raise SystemExit
Reported by Pylint.
Line: 7
Column: 5
import uos
uos.VfsLfs1
uos.VfsLfs2
except (ImportError, AttributeError):
print("SKIP")
raise SystemExit
Reported by Pylint.
Line: 10
Column: 5
uos.VfsLfs2
except (ImportError, AttributeError):
print("SKIP")
raise SystemExit
class RAMBlockDevice:
ERASE_BLOCK_SIZE = 1024
Reported by Pylint.
Line: 29
Column: 25
for i in range(len(buf)):
self.data[addr + i] = buf[i]
def ioctl(self, op, arg):
if op == 4: # block count
return len(self.data) // self.ERASE_BLOCK_SIZE
if op == 5: # block size
return self.ERASE_BLOCK_SIZE
if op == 6: # erase block
Reported by Pylint.
Line: 38
Column: 10
return 0
def test(bdev, vfs_class):
print("test", vfs_class)
# mkfs
vfs_class.mkfs(bdev)
Reported by Pylint.
Line: 1
Column: 1
# Test for VfsLittle using a RAM device, file IO
try:
import uos
uos.VfsLfs1
uos.VfsLfs2
except (ImportError, AttributeError):
print("SKIP")
Reported by Pylint.
Line: 13
Column: 1
raise SystemExit
class RAMBlockDevice:
ERASE_BLOCK_SIZE = 1024
def __init__(self, blocks):
self.data = bytearray(blocks * self.ERASE_BLOCK_SIZE)
Reported by Pylint.
Line: 19
Column: 5
def __init__(self, blocks):
self.data = bytearray(blocks * self.ERASE_BLOCK_SIZE)
def readblocks(self, block, buf, off):
addr = block * self.ERASE_BLOCK_SIZE + off
for i in range(len(buf)):
buf[i] = self.data[addr + i]
def writeblocks(self, block, buf, off):
Reported by Pylint.
Line: 21
Column: 9
def readblocks(self, block, buf, off):
addr = block * self.ERASE_BLOCK_SIZE + off
for i in range(len(buf)):
buf[i] = self.data[addr + i]
def writeblocks(self, block, buf, off):
addr = block * self.ERASE_BLOCK_SIZE + off
for i in range(len(buf)):
Reported by Pylint.
Line: 24
Column: 5
for i in range(len(buf)):
buf[i] = self.data[addr + i]
def writeblocks(self, block, buf, off):
addr = block * self.ERASE_BLOCK_SIZE + off
for i in range(len(buf)):
self.data[addr + i] = buf[i]
def ioctl(self, op, arg):
Reported by Pylint.
tests/unicode/unicode_id.py
26 issues
Line: 14
Column: 1
print(α, αβγ, bβ, βb)
# function, argument, local identifiers
def α(β, γ):
δ = β + γ
print(β, γ, δ)
α(1, 2)
Reported by Pylint.
Line: 1
Column: 1
# test unicode in identifiers
# comment
# αβγδϵφζ
# global identifiers
α = 1
αβγ = 2
bβ = 3
Reported by Pylint.
Line: 7
Column: 1
# αβγδϵφζ
# global identifiers
α = 1
αβγ = 2
bβ = 3
βb = 4
print(α, αβγ, bβ, βb)
Reported by Pylint.
Line: 8
Column: 1
# global identifiers
α = 1
αβγ = 2
bβ = 3
βb = 4
print(α, αβγ, bβ, βb)
# function, argument, local identifiers
Reported by Pylint.
Line: 9
Column: 1
# global identifiers
α = 1
αβγ = 2
bβ = 3
βb = 4
print(α, αβγ, bβ, βb)
# function, argument, local identifiers
def α(β, γ):
Reported by Pylint.
Line: 10
Column: 1
α = 1
αβγ = 2
bβ = 3
βb = 4
print(α, αβγ, bβ, βb)
# function, argument, local identifiers
def α(β, γ):
δ = β + γ
Reported by Pylint.
Line: 10
Column: 1
α = 1
αβγ = 2
bβ = 3
βb = 4
print(α, αβγ, bβ, βb)
# function, argument, local identifiers
def α(β, γ):
δ = β + γ
Reported by Pylint.
Line: 14
Column: 1
print(α, αβγ, bβ, βb)
# function, argument, local identifiers
def α(β, γ):
δ = β + γ
print(β, γ, δ)
α(1, 2)
Reported by Pylint.
Line: 14
Column: 1
print(α, αβγ, bβ, βb)
# function, argument, local identifiers
def α(β, γ):
δ = β + γ
print(β, γ, δ)
α(1, 2)
Reported by Pylint.
Line: 14
Column: 1
print(α, αβγ, bβ, βb)
# function, argument, local identifiers
def α(β, γ):
δ = β + γ
print(β, γ, δ)
α(1, 2)
Reported by Pylint.
tests/basics/builtin_exec.py
26 issues
Line: 10
Column: 7
raise SystemExit
print(exec("def foo(): return 42"))
print(foo())
d = {}
exec("def bar(): return 84", d)
print(d["bar"]())
Reported by Pylint.
Line: 7
Column: 5
exec
except NameError:
print("SKIP")
raise SystemExit
print(exec("def foo(): return 42"))
print(foo())
d = {}
Reported by Pylint.
Line: 9
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html
print("SKIP")
raise SystemExit
print(exec("def foo(): return 42"))
print(foo())
d = {}
exec("def bar(): return 84", d)
print(d["bar"]())
Reported by Bandit.
Line: 9
Column: 7
print("SKIP")
raise SystemExit
print(exec("def foo(): return 42"))
print(foo())
d = {}
exec("def bar(): return 84", d)
print(d["bar"]())
Reported by Pylint.
Line: 13
Column: 1
print(foo())
d = {}
exec("def bar(): return 84", d)
print(d["bar"]())
# passing None/dict as args to globals/locals
foo = 11
exec('print(foo)')
Reported by Pylint.
Line: 13
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html
print(foo())
d = {}
exec("def bar(): return 84", d)
print(d["bar"]())
# passing None/dict as args to globals/locals
foo = 11
exec('print(foo)')
Reported by Bandit.
Line: 18
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html
# passing None/dict as args to globals/locals
foo = 11
exec('print(foo)')
exec('print(foo)', None)
exec('print(foo)', {'foo':3}, None)
exec('print(foo)', None, {'foo':3})
exec('print(foo)', None, {'bar':3})
exec('print(foo)', {'bar':3}, locals())
Reported by Bandit.
Line: 18
Column: 1
# passing None/dict as args to globals/locals
foo = 11
exec('print(foo)')
exec('print(foo)', None)
exec('print(foo)', {'foo':3}, None)
exec('print(foo)', None, {'foo':3})
exec('print(foo)', None, {'bar':3})
exec('print(foo)', {'bar':3}, locals())
Reported by Pylint.
Line: 19
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html
# passing None/dict as args to globals/locals
foo = 11
exec('print(foo)')
exec('print(foo)', None)
exec('print(foo)', {'foo':3}, None)
exec('print(foo)', None, {'foo':3})
exec('print(foo)', None, {'bar':3})
exec('print(foo)', {'bar':3}, locals())
Reported by Bandit.
Line: 19
Column: 1
# passing None/dict as args to globals/locals
foo = 11
exec('print(foo)')
exec('print(foo)', None)
exec('print(foo)', {'foo':3}, None)
exec('print(foo)', None, {'foo':3})
exec('print(foo)', None, {'bar':3})
exec('print(foo)', {'bar':3}, locals())
Reported by Pylint.
tests/misc/non_compliant.py
26 issues
Line: 44
Column: 5
# uPy raises TypeError, shold be ValueError
try:
"%c" % b"\x01\x02"
except (TypeError, ValueError):
print("TypeError, ValueError")
# attributes/subscr not implemented
try:
Reported by Pylint.
Line: 143
Column: 1
print("A.foo")
class B(object, A):
pass
B().foo()
Reported by Pylint.
Line: 150
Column: 1
B().foo()
# can't assign property (or other special accessors) to already-subclassed class
class A:
pass
class B(A):
pass
Reported by Pylint.
Line: 154
Column: 1
pass
class B(A):
pass
try:
A.bar = property()
Reported by Pylint.
Line: 8
Column: 5
import ustruct
except ImportError:
print("SKIP")
raise SystemExit
# when super can't find self
try:
exec("def f(): super()")
except SyntaxError:
Reported by Pylint.
Line: 12
Column: 5
# when super can't find self
try:
exec("def f(): super()")
except SyntaxError:
print("SyntaxError")
# store to exception attribute is not allowed
try:
Reported by Pylint.
Line: 12
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html
# when super can't find self
try:
exec("def f(): super()")
except SyntaxError:
print("SyntaxError")
# store to exception attribute is not allowed
try:
Reported by Bandit.
Line: 1
Column: 1
# tests for things that are not implemented, or have non-compliant behaviour
try:
import uarray as array
import ustruct
except ImportError:
print("SKIP")
raise SystemExit
Reported by Pylint.
Line: 121
Column: 1
print("NotImplementedError")
# can't assign attributes to a function
def f():
pass
try:
f.x = 1
Reported by Pylint.
Line: 121
Column: 1
print("NotImplementedError")
# can't assign attributes to a function
def f():
pass
try:
f.x = 1
Reported by Pylint.