The following issues were found
tests/basics/slice_attrs.py
10 issues
Line: 12
Column: 5
t = A()[1:2]
except:
print("SKIP")
raise SystemExit
A()[1:2:3]
# test storing to attr (shouldn't be allowed)
Reported by Pylint.
Line: 15
Column: 1
raise SystemExit
A()[1:2:3]
# test storing to attr (shouldn't be allowed)
class B:
def __getitem__(self, idx):
try:
Reported by Pylint.
Line: 24
Column: 1
idx.start = 0
except AttributeError:
print('AttributeError')
B()[:]
Reported by Pylint.
Line: 1
Column: 1
# test builtin slice attributes access
# print slice attributes
class A:
def __getitem__(self, idx):
print(idx.start, idx.stop, idx.step)
try:
t = A()[1:2]
Reported by Pylint.
Line: 4
Column: 1
# test builtin slice attributes access
# print slice attributes
class A:
def __getitem__(self, idx):
print(idx.start, idx.stop, idx.step)
try:
t = A()[1:2]
Reported by Pylint.
Line: 4
Column: 1
# test builtin slice attributes access
# print slice attributes
class A:
def __getitem__(self, idx):
print(idx.start, idx.stop, idx.step)
try:
t = A()[1:2]
Reported by Pylint.
Line: 4
Column: 1
# test builtin slice attributes access
# print slice attributes
class A:
def __getitem__(self, idx):
print(idx.start, idx.stop, idx.step)
try:
t = A()[1:2]
Reported by Pylint.
Line: 18
Column: 1
A()[1:2:3]
# test storing to attr (shouldn't be allowed)
class B:
def __getitem__(self, idx):
try:
idx.start = 0
except AttributeError:
print('AttributeError')
Reported by Pylint.
Line: 18
Column: 1
A()[1:2:3]
# test storing to attr (shouldn't be allowed)
class B:
def __getitem__(self, idx):
try:
idx.start = 0
except AttributeError:
print('AttributeError')
Reported by Pylint.
Line: 18
Column: 1
A()[1:2:3]
# test storing to attr (shouldn't be allowed)
class B:
def __getitem__(self, idx):
try:
idx.start = 0
except AttributeError:
print('AttributeError')
Reported by Pylint.
tests/extmod/uasyncio_lock_cancel.py
10 issues
Line: 10
Column: 9
import asyncio
except ImportError:
print("SKIP")
raise SystemExit
async def task(i, lock, lock_flag):
print("task", i, "start")
try:
Reported by Pylint.
Line: 35
Column: 5
lock_flag = [True]
# Create 4 tasks and let them all run
t0 = asyncio.create_task(task(0, lock, lock_flag))
t1 = asyncio.create_task(task(1, lock, lock_flag))
t2 = asyncio.create_task(task(2, lock, lock_flag))
t3 = asyncio.create_task(task(3, lock, lock_flag))
await asyncio.sleep(0)
Reported by Pylint.
Line: 38
Column: 5
t0 = asyncio.create_task(task(0, lock, lock_flag))
t1 = asyncio.create_task(task(1, lock, lock_flag))
t2 = asyncio.create_task(task(2, lock, lock_flag))
t3 = asyncio.create_task(task(3, lock, lock_flag))
await asyncio.sleep(0)
# Cancel 2 of the tasks (which are waiting on the lock) and release the lock
t1.cancel()
t2.cancel()
Reported by Pylint.
Line: 1
Column: 1
# Test that locks work when cancelling multiple waiters on the lock
try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio
except ImportError:
print("SKIP")
Reported by Pylint.
Line: 13
Column: 1
raise SystemExit
async def task(i, lock, lock_flag):
print("task", i, "start")
try:
await lock.acquire()
except asyncio.CancelledError:
print("task", i, "cancel")
Reported by Pylint.
Line: 28
Column: 1
print("task", i, "done")
async def main():
# Create a lock and acquire it so the tasks below must wait
lock = asyncio.Lock()
await lock.acquire()
lock_flag = [True]
Reported by Pylint.
Line: 35
Column: 5
lock_flag = [True]
# Create 4 tasks and let them all run
t0 = asyncio.create_task(task(0, lock, lock_flag))
t1 = asyncio.create_task(task(1, lock, lock_flag))
t2 = asyncio.create_task(task(2, lock, lock_flag))
t3 = asyncio.create_task(task(3, lock, lock_flag))
await asyncio.sleep(0)
Reported by Pylint.
Line: 36
Column: 5
# Create 4 tasks and let them all run
t0 = asyncio.create_task(task(0, lock, lock_flag))
t1 = asyncio.create_task(task(1, lock, lock_flag))
t2 = asyncio.create_task(task(2, lock, lock_flag))
t3 = asyncio.create_task(task(3, lock, lock_flag))
await asyncio.sleep(0)
# Cancel 2 of the tasks (which are waiting on the lock) and release the lock
Reported by Pylint.
Line: 37
Column: 5
# Create 4 tasks and let them all run
t0 = asyncio.create_task(task(0, lock, lock_flag))
t1 = asyncio.create_task(task(1, lock, lock_flag))
t2 = asyncio.create_task(task(2, lock, lock_flag))
t3 = asyncio.create_task(task(3, lock, lock_flag))
await asyncio.sleep(0)
# Cancel 2 of the tasks (which are waiting on the lock) and release the lock
t1.cancel()
Reported by Pylint.
Line: 38
Column: 5
t0 = asyncio.create_task(task(0, lock, lock_flag))
t1 = asyncio.create_task(task(1, lock, lock_flag))
t2 = asyncio.create_task(task(2, lock, lock_flag))
t3 = asyncio.create_task(task(3, lock, lock_flag))
await asyncio.sleep(0)
# Cancel 2 of the tasks (which are waiting on the lock) and release the lock
t1.cancel()
t2.cancel()
Reported by Pylint.
tests/internal_bench/func_args-3.2-kw_3.py
10 issues
Line: 4
Column: 16
import bench
def func(a, b, c):
pass
def test(num):
for i in iter(range(num)):
Reported by Pylint.
Line: 4
Column: 13
import bench
def func(a, b, c):
pass
def test(num):
for i in iter(range(num)):
Reported by Pylint.
Line: 4
Column: 10
import bench
def func(a, b, c):
pass
def test(num):
for i in iter(range(num)):
Reported by Pylint.
Line: 1
Column: 1
import bench
def func(a, b, c):
pass
def test(num):
for i in iter(range(num)):
Reported by Pylint.
Line: 1
Column: 1
import bench
def func(a, b, c):
pass
def test(num):
for i in iter(range(num)):
Reported by Pylint.
Line: 4
Column: 1
import bench
def func(a, b, c):
pass
def test(num):
for i in iter(range(num)):
Reported by Pylint.
Line: 4
Column: 1
import bench
def func(a, b, c):
pass
def test(num):
for i in iter(range(num)):
Reported by Pylint.
Line: 4
Column: 1
import bench
def func(a, b, c):
pass
def test(num):
for i in iter(range(num)):
Reported by Pylint.
Line: 4
Column: 1
import bench
def func(a, b, c):
pass
def test(num):
for i in iter(range(num)):
Reported by Pylint.
Line: 8
Column: 1
pass
def test(num):
for i in iter(range(num)):
func(c=i, b=i, a=i)
bench.run(test)
Reported by Pylint.
tests/micropython/viper_const.py
10 issues
Line: 4
Column: 2
# test loading constants in viper functions
@micropython.viper
def f():
return b"bytes"
print(f())
Reported by Pylint.
Line: 12
Column: 2
print(f())
@micropython.viper
def f():
@micropython.viper
def g() -> int:
return 123
Reported by Pylint.
Line: 13
Column: 1
@micropython.viper
def f():
@micropython.viper
def g() -> int:
return 123
return g
Reported by Pylint.
Line: 14
Column: 6
@micropython.viper
def f():
@micropython.viper
def g() -> int:
return 123
return g
Reported by Pylint.
Line: 1
Column: 1
# test loading constants in viper functions
@micropython.viper
def f():
return b"bytes"
print(f())
Reported by Pylint.
Line: 5
Column: 1
@micropython.viper
def f():
return b"bytes"
print(f())
Reported by Pylint.
Line: 5
Column: 1
@micropython.viper
def f():
return b"bytes"
print(f())
Reported by Pylint.
Line: 13
Column: 1
@micropython.viper
def f():
@micropython.viper
def g() -> int:
return 123
return g
Reported by Pylint.
Line: 13
Column: 1
@micropython.viper
def f():
@micropython.viper
def g() -> int:
return 123
return g
Reported by Pylint.
Line: 15
Column: 5
@micropython.viper
def f():
@micropython.viper
def g() -> int:
return 123
return g
Reported by Pylint.
tests/thread/thread_lock4.py
10 issues
Line: 14
Column: 9
def fac(n):
x = 1
for i in range(1, n + 1):
x *= i
return x
def thread_entry():
Reported by Pylint.
Line: 23
Column: 20
while True:
with jobs_lock:
try:
f, arg = jobs.pop(0)
except IndexError:
return
ans = f(arg)
with output_lock:
output.append((arg, ans))
Reported by Pylint.
Line: 26
Column: 9
f, arg = jobs.pop(0)
except IndexError:
return
ans = f(arg)
with output_lock:
output.append((arg, ans))
# create a list of jobs
Reported by Pylint.
Line: 1
Column: 1
# test using lock to coordinate access to global mutable objects
#
# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
try:
import utime as time
except ImportError:
import time
import _thread
Reported by Pylint.
Line: 12
Column: 1
import _thread
def fac(n):
x = 1
for i in range(1, n + 1):
x *= i
return x
Reported by Pylint.
Line: 12
Column: 1
import _thread
def fac(n):
x = 1
for i in range(1, n + 1):
x *= i
return x
Reported by Pylint.
Line: 13
Column: 5
def fac(n):
x = 1
for i in range(1, n + 1):
x *= i
return x
Reported by Pylint.
Line: 15
Column: 9
def fac(n):
x = 1
for i in range(1, n + 1):
x *= i
return x
def thread_entry():
while True:
Reported by Pylint.
Line: 19
Column: 1
return x
def thread_entry():
while True:
with jobs_lock:
try:
f, arg = jobs.pop(0)
except IndexError:
Reported by Pylint.
Line: 23
Column: 17
while True:
with jobs_lock:
try:
f, arg = jobs.pop(0)
except IndexError:
return
ans = f(arg)
with output_lock:
output.append((arg, ans))
Reported by Pylint.
tests/internal_bench/func_args-1.2-pos_3.py
10 issues
Line: 4
Column: 10
import bench
def func(a, b, c):
pass
def test(num):
for i in iter(range(num)):
Reported by Pylint.
Line: 4
Column: 16
import bench
def func(a, b, c):
pass
def test(num):
for i in iter(range(num)):
Reported by Pylint.
Line: 4
Column: 13
import bench
def func(a, b, c):
pass
def test(num):
for i in iter(range(num)):
Reported by Pylint.
Line: 1
Column: 1
import bench
def func(a, b, c):
pass
def test(num):
for i in iter(range(num)):
Reported by Pylint.
Line: 1
Column: 1
import bench
def func(a, b, c):
pass
def test(num):
for i in iter(range(num)):
Reported by Pylint.
Line: 4
Column: 1
import bench
def func(a, b, c):
pass
def test(num):
for i in iter(range(num)):
Reported by Pylint.
Line: 4
Column: 1
import bench
def func(a, b, c):
pass
def test(num):
for i in iter(range(num)):
Reported by Pylint.
Line: 4
Column: 1
import bench
def func(a, b, c):
pass
def test(num):
for i in iter(range(num)):
Reported by Pylint.
Line: 4
Column: 1
import bench
def func(a, b, c):
pass
def test(num):
for i in iter(range(num)):
Reported by Pylint.
Line: 8
Column: 1
pass
def test(num):
for i in iter(range(num)):
func(i, i, i)
bench.run(test)
Reported by Pylint.
tests/micropython/heapalloc_yield_from.py
10 issues
Line: 3
Column: 1
# Check that yield-from can work without heap allocation
import micropython
# Yielding from a function generator
def sub_gen(a):
for i in range(a):
yield i
Reported by Pylint.
Line: 11
Column: 9
yield i
def gen(g):
yield from g
g = gen(sub_gen(4))
micropython.heap_lock()
Reported by Pylint.
Line: 1
Column: 1
# Check that yield-from can work without heap allocation
import micropython
# Yielding from a function generator
def sub_gen(a):
for i in range(a):
yield i
Reported by Pylint.
Line: 6
Column: 1
import micropython
# Yielding from a function generator
def sub_gen(a):
for i in range(a):
yield i
def gen(g):
Reported by Pylint.
Line: 6
Column: 1
import micropython
# Yielding from a function generator
def sub_gen(a):
for i in range(a):
yield i
def gen(g):
Reported by Pylint.
Line: 11
Column: 1
yield i
def gen(g):
yield from g
g = gen(sub_gen(4))
micropython.heap_lock()
Reported by Pylint.
Line: 11
Column: 1
yield i
def gen(g):
yield from g
g = gen(sub_gen(4))
micropython.heap_lock()
Reported by Pylint.
Line: 22
Column: 1
micropython.heap_unlock()
# Yielding from a user iterator
class G:
def __init__(self):
self.value = 0
def __iter__(self):
return self
Reported by Pylint.
Line: 22
Column: 1
micropython.heap_unlock()
# Yielding from a user iterator
class G:
def __init__(self):
self.value = 0
def __iter__(self):
return self
Reported by Pylint.
Line: 30
Column: 9
return self
def __next__(self):
v = self.value
self.value += 1
return v
g = gen(G())
Reported by Pylint.
tests/internal_bench/func_args-2-pos_default_2_of_3.py
10 issues
Line: 4
Column: 13
import bench
def func(a, b=1, c=2):
pass
def test(num):
for i in iter(range(num)):
Reported by Pylint.
Line: 4
Column: 10
import bench
def func(a, b=1, c=2):
pass
def test(num):
for i in iter(range(num)):
Reported by Pylint.
Line: 4
Column: 18
import bench
def func(a, b=1, c=2):
pass
def test(num):
for i in iter(range(num)):
Reported by Pylint.
Line: 1
Column: 1
import bench
def func(a, b=1, c=2):
pass
def test(num):
for i in iter(range(num)):
Reported by Pylint.
Line: 1
Column: 1
import bench
def func(a, b=1, c=2):
pass
def test(num):
for i in iter(range(num)):
Reported by Pylint.
Line: 4
Column: 1
import bench
def func(a, b=1, c=2):
pass
def test(num):
for i in iter(range(num)):
Reported by Pylint.
Line: 4
Column: 1
import bench
def func(a, b=1, c=2):
pass
def test(num):
for i in iter(range(num)):
Reported by Pylint.
Line: 4
Column: 1
import bench
def func(a, b=1, c=2):
pass
def test(num):
for i in iter(range(num)):
Reported by Pylint.
Line: 4
Column: 1
import bench
def func(a, b=1, c=2):
pass
def test(num):
for i in iter(range(num)):
Reported by Pylint.
Line: 8
Column: 1
pass
def test(num):
for i in iter(range(num)):
func(i)
bench.run(test)
Reported by Pylint.
tests/basics/builtin_exec_buffer.py
9 issues
Line: 4
Column: 5
# test builtin exec with a buffer (bytearray/memoryview) input
try:
exec
bytearray
memoryview
except:
print("SKIP")
raise SystemExit
Reported by Pylint.
Line: 5
Column: 5
try:
exec
bytearray
memoryview
except:
print("SKIP")
raise SystemExit
Reported by Pylint.
Line: 6
Column: 5
try:
exec
bytearray
memoryview
except:
print("SKIP")
raise SystemExit
exec(bytearray(b'print(1)'))
Reported by Pylint.
Line: 9
Column: 5
memoryview
except:
print("SKIP")
raise SystemExit
exec(bytearray(b'print(1)'))
exec(memoryview(b'print(2)'))
Reported by Pylint.
Line: 11
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html
print("SKIP")
raise SystemExit
exec(bytearray(b'print(1)'))
exec(memoryview(b'print(2)'))
Reported by Bandit.
Line: 11
Column: 1
print("SKIP")
raise SystemExit
exec(bytearray(b'print(1)'))
exec(memoryview(b'print(2)'))
Reported by Pylint.
Line: 12
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html
raise SystemExit
exec(bytearray(b'print(1)'))
exec(memoryview(b'print(2)'))
Reported by Bandit.
Line: 12
Column: 1
raise SystemExit
exec(bytearray(b'print(1)'))
exec(memoryview(b'print(2)'))
Reported by Pylint.
Line: 1
Column: 1
# test builtin exec with a buffer (bytearray/memoryview) input
try:
exec
bytearray
memoryview
except:
print("SKIP")
raise SystemExit
Reported by Pylint.
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.