The following issues were found
lib/littlefs/lfs2_util.h
12 issues
Line: 171
CWE codes:
758
return __builtin_bswap32(a);
#else
return (((uint8_t*)&a)[0] << 0) |
(((uint8_t*)&a)[1] << 8) |
(((uint8_t*)&a)[2] << 16) |
(((uint8_t*)&a)[3] << 24);
#endif
}
Reported by Cppcheck.
Line: 171
CWE codes:
758
return __builtin_bswap32(a);
#else
return (((uint8_t*)&a)[0] << 0) |
(((uint8_t*)&a)[1] << 8) |
(((uint8_t*)&a)[2] << 16) |
(((uint8_t*)&a)[3] << 24);
#endif
}
Reported by Cppcheck.
Line: 172
CWE codes:
758
#else
return (((uint8_t*)&a)[0] << 0) |
(((uint8_t*)&a)[1] << 8) |
(((uint8_t*)&a)[2] << 16) |
(((uint8_t*)&a)[3] << 24);
#endif
}
static inline uint32_t lfs2_tole32(uint32_t a) {
Reported by Cppcheck.
Line: 172
CWE codes:
758
#else
return (((uint8_t*)&a)[0] << 0) |
(((uint8_t*)&a)[1] << 8) |
(((uint8_t*)&a)[2] << 16) |
(((uint8_t*)&a)[3] << 24);
#endif
}
static inline uint32_t lfs2_tole32(uint32_t a) {
Reported by Cppcheck.
Line: 173
CWE codes:
758
return (((uint8_t*)&a)[0] << 0) |
(((uint8_t*)&a)[1] << 8) |
(((uint8_t*)&a)[2] << 16) |
(((uint8_t*)&a)[3] << 24);
#endif
}
static inline uint32_t lfs2_tole32(uint32_t a) {
return lfs2_fromle32(a);
Reported by Cppcheck.
Line: 173
CWE codes:
758
return (((uint8_t*)&a)[0] << 0) |
(((uint8_t*)&a)[1] << 8) |
(((uint8_t*)&a)[2] << 16) |
(((uint8_t*)&a)[3] << 24);
#endif
}
static inline uint32_t lfs2_tole32(uint32_t a) {
return lfs2_fromle32(a);
Reported by Cppcheck.
Line: 195
CWE codes:
758
return a;
#else
return (((uint8_t*)&a)[0] << 24) |
(((uint8_t*)&a)[1] << 16) |
(((uint8_t*)&a)[2] << 8) |
(((uint8_t*)&a)[3] << 0);
#endif
}
Reported by Cppcheck.
Line: 195
CWE codes:
758
return a;
#else
return (((uint8_t*)&a)[0] << 24) |
(((uint8_t*)&a)[1] << 16) |
(((uint8_t*)&a)[2] << 8) |
(((uint8_t*)&a)[3] << 0);
#endif
}
Reported by Cppcheck.
Line: 196
CWE codes:
758
#else
return (((uint8_t*)&a)[0] << 24) |
(((uint8_t*)&a)[1] << 16) |
(((uint8_t*)&a)[2] << 8) |
(((uint8_t*)&a)[3] << 0);
#endif
}
static inline uint32_t lfs2_tobe32(uint32_t a) {
Reported by Cppcheck.
Line: 196
CWE codes:
758
#else
return (((uint8_t*)&a)[0] << 24) |
(((uint8_t*)&a)[1] << 16) |
(((uint8_t*)&a)[2] << 8) |
(((uint8_t*)&a)[3] << 0);
#endif
}
static inline uint32_t lfs2_tobe32(uint32_t a) {
Reported by Cppcheck.
drivers/nrf24l01/nrf24l01test.py
12 issues
Line: 3
Column: 1
"""Test for nrf24l01 module. Portable between MicroPython targets."""
import usys
import ustruct as struct
import utime
from machine import Pin, SPI
from nrf24l01 import NRF24L01
from micropython import const
Reported by Pylint.
Line: 4
Column: 1
"""Test for nrf24l01 module. Portable between MicroPython targets."""
import usys
import ustruct as struct
import utime
from machine import Pin, SPI
from nrf24l01 import NRF24L01
from micropython import const
Reported by Pylint.
Line: 5
Column: 1
import usys
import ustruct as struct
import utime
from machine import Pin, SPI
from nrf24l01 import NRF24L01
from micropython import const
# Slave pause between receiving data and checking for further packets.
Reported by Pylint.
Line: 6
Column: 1
import usys
import ustruct as struct
import utime
from machine import Pin, SPI
from nrf24l01 import NRF24L01
from micropython import const
# Slave pause between receiving data and checking for further packets.
_RX_POLL_DELAY = const(15)
Reported by Pylint.
Line: 8
Column: 1
import utime
from machine import Pin, SPI
from nrf24l01 import NRF24L01
from micropython import const
# Slave pause between receiving data and checking for further packets.
_RX_POLL_DELAY = const(15)
# Slave pauses an additional _SLAVE_SEND_DELAY ms after receiving data and before
# transmitting to allow the (remote) master time to get into receive mode. The
Reported by Pylint.
Line: 137
Column: 5
try:
import pyb
leds = [pyb.LED(i + 1) for i in range(4)]
except:
leds = []
Reported by Pylint.
Line: 140
Column: 1
import pyb
leds = [pyb.LED(i + 1) for i in range(4)]
except:
leds = []
print("NRF24L01 test module loaded")
print("NRF24L01 pinout for test:")
print(" CE on", cfg["ce"])
Reported by Pylint.
Line: 8
Column: 1
import utime
from machine import Pin, SPI
from nrf24l01 import NRF24L01
from micropython import const
# Slave pause between receiving data and checking for further packets.
_RX_POLL_DELAY = const(15)
# Slave pauses an additional _SLAVE_SEND_DELAY ms after receiving data and before
# transmitting to allow the (remote) master time to get into receive mode. The
Reported by Pylint.
Line: 31
Column: 1
pipes = (b"\xe1\xf0\xf0\xf0\xf0", b"\xd2\xf0\xf0\xf0\xf0")
def master():
csn = Pin(cfg["csn"], mode=Pin.OUT, value=1)
ce = Pin(cfg["ce"], mode=Pin.OUT, value=0)
if cfg["spi"] == -1:
spi = SPI(-1, sck=Pin(cfg["sck"]), mosi=Pin(cfg["mosi"]), miso=Pin(cfg["miso"]))
nrf = NRF24L01(spi, csn, ce, payload_size=8)
Reported by Pylint.
Line: 33
Column: 5
def master():
csn = Pin(cfg["csn"], mode=Pin.OUT, value=1)
ce = Pin(cfg["ce"], mode=Pin.OUT, value=0)
if cfg["spi"] == -1:
spi = SPI(-1, sck=Pin(cfg["sck"]), mosi=Pin(cfg["mosi"]), miso=Pin(cfg["miso"]))
nrf = NRF24L01(spi, csn, ce, payload_size=8)
else:
nrf = NRF24L01(SPI(cfg["spi"]), csn, ce, payload_size=8)
Reported by Pylint.
tests/basics/class2.py
12 issues
Line: 21
Column: 5
# __init__ should return None
class C3:
def __init__(self):
return 10
try:
C3()
except TypeError:
print('TypeError')
Reported by Pylint.
Line: 1
Column: 1
# class with __init__
class C1:
def __init__(self):
self.x = 1
c1 = C1()
print(type(c1) == C1)
print(c1.x)
Reported by Pylint.
Line: 3
Column: 1
# class with __init__
class C1:
def __init__(self):
self.x = 1
c1 = C1()
print(type(c1) == C1)
print(c1.x)
Reported by Pylint.
Line: 3
Column: 1
# class with __init__
class C1:
def __init__(self):
self.x = 1
c1 = C1()
print(type(c1) == C1)
print(c1.x)
Reported by Pylint.
Line: 5
Column: 9
class C1:
def __init__(self):
self.x = 1
c1 = C1()
print(type(c1) == C1)
print(c1.x)
Reported by Pylint.
Line: 8
Column: 7
self.x = 1
c1 = C1()
print(type(c1) == C1)
print(c1.x)
class C2:
def __init__(self, x):
self.x = x
Reported by Pylint.
Line: 11
Column: 1
print(type(c1) == C1)
print(c1.x)
class C2:
def __init__(self, x):
self.x = x
c2 = C2(4)
print(type(c2) == C2)
Reported by Pylint.
Line: 11
Column: 1
print(type(c1) == C1)
print(c1.x)
class C2:
def __init__(self, x):
self.x = x
c2 = C2(4)
print(type(c2) == C2)
Reported by Pylint.
Line: 13
Column: 9
class C2:
def __init__(self, x):
self.x = x
c2 = C2(4)
print(type(c2) == C2)
print(c2.x)
Reported by Pylint.
Line: 16
Column: 7
self.x = x
c2 = C2(4)
print(type(c2) == C2)
print(c2.x)
# __init__ should return None
class C3:
def __init__(self):
Reported by Pylint.
tests/perf_bench/misc_mandel.py
12 issues
Line: 1
Column: 1
# Compute the Mandelbrot set, to test complex numbers
def mandelbrot(w, h):
def in_set(c):
z = 0
for i in range(32):
z = z * z + c
if abs(z) > 100:
Reported by Pylint.
Line: 4
Column: 1
# Compute the Mandelbrot set, to test complex numbers
def mandelbrot(w, h):
def in_set(c):
z = 0
for i in range(32):
z = z * z + c
if abs(z) > 100:
Reported by Pylint.
Line: 4
Column: 1
# Compute the Mandelbrot set, to test complex numbers
def mandelbrot(w, h):
def in_set(c):
z = 0
for i in range(32):
z = z * z + c
if abs(z) > 100:
Reported by Pylint.
Line: 4
Column: 1
# Compute the Mandelbrot set, to test complex numbers
def mandelbrot(w, h):
def in_set(c):
z = 0
for i in range(32):
z = z * z + c
if abs(z) > 100:
Reported by Pylint.
Line: 5
Column: 5
def mandelbrot(w, h):
def in_set(c):
z = 0
for i in range(32):
z = z * z + c
if abs(z) > 100:
return i
Reported by Pylint.
Line: 6
Column: 9
def mandelbrot(w, h):
def in_set(c):
z = 0
for i in range(32):
z = z * z + c
if abs(z) > 100:
return i
return 0
Reported by Pylint.
Line: 8
Column: 13
def in_set(c):
z = 0
for i in range(32):
z = z * z + c
if abs(z) > 100:
return i
return 0
img = bytearray(w * h)
Reported by Pylint.
Line: 17
Column: 9
xscale = (w - 1) / 2.4
yscale = (h - 1) / 3.2
for v in range(h):
line = memoryview(img)[v * w : v * w + w]
for u in range(w):
c = in_set(complex(v / yscale - 2.3, u / xscale - 1.2))
line[u] = c
Reported by Pylint.
Line: 19
Column: 13
yscale = (h - 1) / 3.2
for v in range(h):
line = memoryview(img)[v * w : v * w + w]
for u in range(w):
c = in_set(complex(v / yscale - 2.3, u / xscale - 1.2))
line[u] = c
return img
Reported by Pylint.
Line: 20
Column: 13
for v in range(h):
line = memoryview(img)[v * w : v * w + w]
for u in range(w):
c = in_set(complex(v / yscale - 2.3, u / xscale - 1.2))
line[u] = c
return img
Reported by Pylint.
tests/inlineasm/asmconst.py
12 issues
Line: 4
Column: 2
# test constants in assembler
@micropython.asm_thumb
def c1():
movwt(r0, 0xFFFFFFFF)
movwt(r1, 0xF0000000)
sub(r0, r0, r1)
Reported by Pylint.
Line: 6
Column: 11
@micropython.asm_thumb
def c1():
movwt(r0, 0xFFFFFFFF)
movwt(r1, 0xF0000000)
sub(r0, r0, r1)
print(hex(c1()))
Reported by Pylint.
Line: 6
Column: 5
@micropython.asm_thumb
def c1():
movwt(r0, 0xFFFFFFFF)
movwt(r1, 0xF0000000)
sub(r0, r0, r1)
print(hex(c1()))
Reported by Pylint.
Line: 7
Column: 11
@micropython.asm_thumb
def c1():
movwt(r0, 0xFFFFFFFF)
movwt(r1, 0xF0000000)
sub(r0, r0, r1)
print(hex(c1()))
Reported by Pylint.
Line: 7
Column: 5
@micropython.asm_thumb
def c1():
movwt(r0, 0xFFFFFFFF)
movwt(r1, 0xF0000000)
sub(r0, r0, r1)
print(hex(c1()))
Reported by Pylint.
Line: 8
Column: 17
def c1():
movwt(r0, 0xFFFFFFFF)
movwt(r1, 0xF0000000)
sub(r0, r0, r1)
print(hex(c1()))
Reported by Pylint.
Line: 8
Column: 5
def c1():
movwt(r0, 0xFFFFFFFF)
movwt(r1, 0xF0000000)
sub(r0, r0, r1)
print(hex(c1()))
Reported by Pylint.
Line: 8
Column: 9
def c1():
movwt(r0, 0xFFFFFFFF)
movwt(r1, 0xF0000000)
sub(r0, r0, r1)
print(hex(c1()))
Reported by Pylint.
Line: 8
Column: 13
def c1():
movwt(r0, 0xFFFFFFFF)
movwt(r1, 0xF0000000)
sub(r0, r0, r1)
print(hex(c1()))
Reported by Pylint.
Line: 1
Column: 1
# test constants in assembler
@micropython.asm_thumb
def c1():
movwt(r0, 0xFFFFFFFF)
movwt(r1, 0xF0000000)
sub(r0, r0, r1)
Reported by Pylint.
tests/basics/getattr.py
12 issues
Line: 14
Column: 1
print(a.a, a.b)
# test that any exception raised in __getattr__ propagates out
class A:
def __getattr__(self, attr):
if attr == "value":
raise ValueError(123)
else:
raise AttributeError(456)
Reported by Pylint.
Line: 1
Column: 1
# test __getattr__
class A:
def __init__(self, d):
self.d = d
def __getattr__(self, attr):
return self.d[attr]
Reported by Pylint.
Line: 3
Column: 1
# test __getattr__
class A:
def __init__(self, d):
self.d = d
def __getattr__(self, attr):
return self.d[attr]
Reported by Pylint.
Line: 3
Column: 1
# test __getattr__
class A:
def __init__(self, d):
self.d = d
def __getattr__(self, attr):
return self.d[attr]
Reported by Pylint.
Line: 3
Column: 1
# test __getattr__
class A:
def __init__(self, d):
self.d = d
def __getattr__(self, attr):
return self.d[attr]
Reported by Pylint.
Line: 5
Column: 9
class A:
def __init__(self, d):
self.d = d
def __getattr__(self, attr):
return self.d[attr]
a = A({'a':1, 'b':2})
Reported by Pylint.
Line: 14
Column: 1
print(a.a, a.b)
# test that any exception raised in __getattr__ propagates out
class A:
def __getattr__(self, attr):
if attr == "value":
raise ValueError(123)
else:
raise AttributeError(456)
Reported by Pylint.
Line: 14
Column: 1
print(a.a, a.b)
# test that any exception raised in __getattr__ propagates out
class A:
def __getattr__(self, attr):
if attr == "value":
raise ValueError(123)
else:
raise AttributeError(456)
Reported by Pylint.
Line: 14
Column: 1
print(a.a, a.b)
# test that any exception raised in __getattr__ propagates out
class A:
def __getattr__(self, attr):
if attr == "value":
raise ValueError(123)
else:
raise AttributeError(456)
Reported by Pylint.
Line: 16
Column: 9
# test that any exception raised in __getattr__ propagates out
class A:
def __getattr__(self, attr):
if attr == "value":
raise ValueError(123)
else:
raise AttributeError(456)
a = A()
try:
Reported by Pylint.
tests/basics/python34.py
12 issues
Line: 36
Column: 1
# from basics/sys1.py
# uPy prints version 3.4
import usys
print(usys.version[:3])
print(usys.version_info[0], usys.version_info[1])
# from basics/exception1.py
# in 3.7 no comma is printed if there is only 1 arg (in 3.4-3.6 one is printed)
Reported by Pylint.
Line: 7
Column: 5
exec
except NameError:
print("SKIP")
raise SystemExit
# from basics/fun_kwvarargs.py
# test evaluation order of arguments (in 3.4 it's backwards, 3.5 it's fixed)
def f4(*vargs, **kwargs):
print(vargs, kwargs)
Reported by Pylint.
Line: 19
Column: 1
f4(*print_ret(['a', 'b']), kw_arg=print_ret(None))
# test evaluation order of dictionary key/value pair (in 3.4 it's backwards)
{print_ret(1):print_ret(2)}
# from basics/syntaxerror.py
def test_syntax(code):
try:
exec(code)
Reported by Pylint.
Line: 24
Column: 9
# from basics/syntaxerror.py
def test_syntax(code):
try:
exec(code)
except SyntaxError:
print("SyntaxError")
test_syntax("f(*a, *b)") # can't have multiple * (in 3.5 we can)
test_syntax("f(**a, **b)") # can't have multiple ** (in 3.5 we can)
test_syntax("f(*a, b)") # can't have positional after *
Reported by Pylint.
Line: 24
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html
# from basics/syntaxerror.py
def test_syntax(code):
try:
exec(code)
except SyntaxError:
print("SyntaxError")
test_syntax("f(*a, *b)") # can't have multiple * (in 3.5 we can)
test_syntax("f(**a, **b)") # can't have multiple ** (in 3.5 we can)
test_syntax("f(*a, b)") # can't have positional after *
Reported by Bandit.
Line: 1
Column: 1
# tests that differ when running under Python 3.4 vs 3.5/3.6/3.7
try:
exec
except NameError:
print("SKIP")
raise SystemExit
# from basics/fun_kwvarargs.py
Reported by Pylint.
Line: 11
Column: 1
# from basics/fun_kwvarargs.py
# test evaluation order of arguments (in 3.4 it's backwards, 3.5 it's fixed)
def f4(*vargs, **kwargs):
print(vargs, kwargs)
def print_ret(x):
print(x)
return x
f4(*print_ret(['a', 'b']), kw_arg=print_ret(None))
Reported by Pylint.
Line: 11
Column: 1
# from basics/fun_kwvarargs.py
# test evaluation order of arguments (in 3.4 it's backwards, 3.5 it's fixed)
def f4(*vargs, **kwargs):
print(vargs, kwargs)
def print_ret(x):
print(x)
return x
f4(*print_ret(['a', 'b']), kw_arg=print_ret(None))
Reported by Pylint.
Line: 13
Column: 1
# test evaluation order of arguments (in 3.4 it's backwards, 3.5 it's fixed)
def f4(*vargs, **kwargs):
print(vargs, kwargs)
def print_ret(x):
print(x)
return x
f4(*print_ret(['a', 'b']), kw_arg=print_ret(None))
# test evaluation order of dictionary key/value pair (in 3.4 it's backwards)
Reported by Pylint.
Line: 13
Column: 1
# test evaluation order of arguments (in 3.4 it's backwards, 3.5 it's fixed)
def f4(*vargs, **kwargs):
print(vargs, kwargs)
def print_ret(x):
print(x)
return x
f4(*print_ret(['a', 'b']), kw_arg=print_ret(None))
# test evaluation order of dictionary key/value pair (in 3.4 it's backwards)
Reported by Pylint.
tests/perf_bench/benchrun.py
12 issues
Line: 13
Column: 18
# Pick sensible parameters given N, M
cur_nm = (0, 0)
param = None
for nm, p in bm_params.items():
if 10 * nm[0] <= 12 * N and nm[1] <= M and nm > cur_nm:
cur_nm = nm
param = p
if param is None:
print(-1, -1, "no matching params")
Reported by Pylint.
Line: 22
Column: 19
return
# Run and time benchmark
run, result = bm_setup(param)
t0 = ticks_us()
run()
t1 = ticks_us()
norm, out = result()
print(ticks_diff(t1, t0), norm, out)
Reported by Pylint.
Line: 1
Column: 1
def bm_run(N, M):
try:
from utime import ticks_us, ticks_diff
except ImportError:
import time
ticks_us = lambda: int(time.perf_counter() * 1000000)
ticks_diff = lambda a, b: a - b
Reported by Pylint.
Line: 1
Column: 1
def bm_run(N, M):
try:
from utime import ticks_us, ticks_diff
except ImportError:
import time
ticks_us = lambda: int(time.perf_counter() * 1000000)
ticks_diff = lambda a, b: a - b
Reported by Pylint.
Line: 1
Column: 1
def bm_run(N, M):
try:
from utime import ticks_us, ticks_diff
except ImportError:
import time
ticks_us = lambda: int(time.perf_counter() * 1000000)
ticks_diff = lambda a, b: a - b
Reported by Pylint.
Line: 1
Column: 1
def bm_run(N, M):
try:
from utime import ticks_us, ticks_diff
except ImportError:
import time
ticks_us = lambda: int(time.perf_counter() * 1000000)
ticks_diff = lambda a, b: a - b
Reported by Pylint.
Line: 3
Column: 9
def bm_run(N, M):
try:
from utime import ticks_us, ticks_diff
except ImportError:
import time
ticks_us = lambda: int(time.perf_counter() * 1000000)
ticks_diff = lambda a, b: a - b
Reported by Pylint.
Line: 5
Column: 9
try:
from utime import ticks_us, ticks_diff
except ImportError:
import time
ticks_us = lambda: int(time.perf_counter() * 1000000)
ticks_diff = lambda a, b: a - b
# Pick sensible parameters given N, M
Reported by Pylint.
Line: 13
Column: 9
# Pick sensible parameters given N, M
cur_nm = (0, 0)
param = None
for nm, p in bm_params.items():
if 10 * nm[0] <= 12 * N and nm[1] <= M and nm > cur_nm:
cur_nm = nm
param = p
if param is None:
print(-1, -1, "no matching params")
Reported by Pylint.
Line: 13
Column: 13
# Pick sensible parameters given N, M
cur_nm = (0, 0)
param = None
for nm, p in bm_params.items():
if 10 * nm[0] <= 12 * N and nm[1] <= M and nm > cur_nm:
cur_nm = nm
param = p
if param is None:
print(-1, -1, "no matching params")
Reported by Pylint.
tests/net_inet/ssl_errors.py
12 issues
Line: 8
Column: 1
try:
import uerrno as errno, usocket as socket, ussl as ssl
except:
import errno, socket, ssl
def test(addr, hostname, block=True):
print("---", hostname or addr)
Reported by Pylint.
Line: 12
Column: 10
import errno, socket, ssl
def test(addr, hostname, block=True):
print("---", hostname or addr)
s = socket.socket()
s.setblocking(block)
try:
s.connect(addr)
Reported by Pylint.
Line: 26
Column: 17
try:
if sys.implementation.name == "micropython":
s = ssl.wrap_socket(s, do_handshake=block)
else:
s = ssl.wrap_socket(s, do_handshake_on_connect=block)
print("wrap: True")
except OSError:
print("wrap: error")
Reported by Pylint.
Line: 28
Column: 17
if sys.implementation.name == "micropython":
s = ssl.wrap_socket(s, do_handshake=block)
else:
s = ssl.wrap_socket(s, do_handshake_on_connect=block)
print("wrap: True")
except OSError:
print("wrap: error")
if not block:
Reported by Pylint.
Line: 1
Column: 1
# test that socket.connect() on a non-blocking socket raises EINPROGRESS
# and that an immediate write/send/read/recv does the right thing
import sys
try:
import uerrno as errno, usocket as socket, ussl as ssl
except:
import errno, socket, ssl
Reported by Pylint.
Line: 7
Column: 5
import sys
try:
import uerrno as errno, usocket as socket, ussl as ssl
except:
import errno, socket, ssl
def test(addr, hostname, block=True):
Reported by Pylint.
Line: 9
Column: 5
try:
import uerrno as errno, usocket as socket, ussl as ssl
except:
import errno, socket, ssl
def test(addr, hostname, block=True):
print("---", hostname or addr)
s = socket.socket()
Reported by Pylint.
Line: 12
Column: 1
import errno, socket, ssl
def test(addr, hostname, block=True):
print("---", hostname or addr)
s = socket.socket()
s.setblocking(block)
try:
s.connect(addr)
Reported by Pylint.
Line: 14
Column: 5
def test(addr, hostname, block=True):
print("---", hostname or addr)
s = socket.socket()
s.setblocking(block)
try:
s.connect(addr)
print("connected")
except OSError as e:
Reported by Pylint.
Line: 19
Column: 5
try:
s.connect(addr)
print("connected")
except OSError as e:
if e.errno != errno.EINPROGRESS:
raise
print("EINPROGRESS")
try:
Reported by Pylint.
tests/extmod/urandom_extra.py
12 issues
Line: 8
Column: 9
import random
except ImportError:
print("SKIP")
raise SystemExit
try:
random.randint
except AttributeError:
print("SKIP")
Reported by Pylint.
Line: 14
Column: 5
random.randint
except AttributeError:
print("SKIP")
raise SystemExit
print("randrange")
for i in range(50):
assert 0 <= random.randrange(4) < 4
assert 2 <= random.randrange(2, 6) < 6
Reported by Pylint.
Line: 1
Column: 1
try:
import urandom as random
except ImportError:
try:
import random
except ImportError:
print("SKIP")
raise SystemExit
Reported by Pylint.
Line: 18
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
print("randrange")
for i in range(50):
assert 0 <= random.randrange(4) < 4
assert 2 <= random.randrange(2, 6) < 6
assert -2 <= random.randrange(-2, 2) < 2
assert random.randrange(1, 9, 2) in (1, 3, 5, 7)
assert random.randrange(2, 1, -1) in (1, 2)
Reported by Bandit.
Line: 19
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
print("randrange")
for i in range(50):
assert 0 <= random.randrange(4) < 4
assert 2 <= random.randrange(2, 6) < 6
assert -2 <= random.randrange(-2, 2) < 2
assert random.randrange(1, 9, 2) in (1, 3, 5, 7)
assert random.randrange(2, 1, -1) in (1, 2)
# empty range
Reported by Bandit.
Line: 20
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
for i in range(50):
assert 0 <= random.randrange(4) < 4
assert 2 <= random.randrange(2, 6) < 6
assert -2 <= random.randrange(-2, 2) < 2
assert random.randrange(1, 9, 2) in (1, 3, 5, 7)
assert random.randrange(2, 1, -1) in (1, 2)
# empty range
try:
Reported by Bandit.
Line: 21
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert 0 <= random.randrange(4) < 4
assert 2 <= random.randrange(2, 6) < 6
assert -2 <= random.randrange(-2, 2) < 2
assert random.randrange(1, 9, 2) in (1, 3, 5, 7)
assert random.randrange(2, 1, -1) in (1, 2)
# empty range
try:
random.randrange(0)
Reported by Bandit.
Line: 22
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert 2 <= random.randrange(2, 6) < 6
assert -2 <= random.randrange(-2, 2) < 2
assert random.randrange(1, 9, 2) in (1, 3, 5, 7)
assert random.randrange(2, 1, -1) in (1, 2)
# empty range
try:
random.randrange(0)
except ValueError:
Reported by Bandit.
Line: 50
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
print("randint")
for i in range(50):
assert 0 <= random.randint(0, 4) <= 4
assert 2 <= random.randint(2, 6) <= 6
assert -2 <= random.randint(-2, 2) <= 2
# empty range
try:
Reported by Bandit.
Line: 51
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
print("randint")
for i in range(50):
assert 0 <= random.randint(0, 4) <= 4
assert 2 <= random.randint(2, 6) <= 6
assert -2 <= random.randint(-2, 2) <= 2
# empty range
try:
random.randint(2, 1)
Reported by Bandit.