The following issues were found
tests/basics/string_count.py
4 issues
Line: 5
Column: 5
str.count
except AttributeError:
print("SKIP")
raise SystemExit
print("".count(""))
print("".count("a"))
print("a".count(""))
print("a".count("a"))
Reported by Pylint.
Line: 1
Column: 1
try:
str.count
except AttributeError:
print("SKIP")
raise SystemExit
print("".count(""))
print("".count("a"))
print("a".count(""))
Reported by Pylint.
Line: 51
Column: 1
print("aaaa".count('a', -1, 5))
print("abbabba".count("abba"))
def t():
return True
print("0000".count('0', t()))
try:
Reported by Pylint.
Line: 51
Column: 1
print("aaaa".count('a', -1, 5))
print("abbabba".count("abba"))
def t():
return True
print("0000".count('0', t()))
try:
Reported by Pylint.
tests/basics/string_escape.py
4 issues
Line: 1
Column: 1
a = "a\1b"
print(len(a))
print(ord(a[1]))
print(len("a\123b"))
a = "a\12345b"
print(len(a))
print(ord(a[1]))
a = "a\xffb"
Reported by Pylint.
Line: 1
Column: 1
a = "a\1b"
print(len(a))
print(ord(a[1]))
print(len("a\123b"))
a = "a\12345b"
print(len(a))
print(ord(a[1]))
a = "a\xffb"
Reported by Pylint.
Line: 5
Column: 1
print(len(a))
print(ord(a[1]))
print(len("a\123b"))
a = "a\12345b"
print(len(a))
print(ord(a[1]))
a = "a\xffb"
print(len(a))
Reported by Pylint.
Line: 9
Column: 1
print(len(a))
print(ord(a[1]))
a = "a\xffb"
print(len(a))
print(ord(a[1]))
Reported by Pylint.
tests/basics/subclass_native_iter.py
4 issues
Line: 1
Column: 1
# test subclassing a native type which can be iterated over
class mymap(map):
pass
m = mymap(lambda x: x + 10, range(4))
print(list(m))
Reported by Pylint.
Line: 3
Column: 1
# test subclassing a native type which can be iterated over
class mymap(map):
pass
m = mymap(lambda x: x + 10, range(4))
print(list(m))
Reported by Pylint.
Line: 3
Column: 1
# test subclassing a native type which can be iterated over
class mymap(map):
pass
m = mymap(lambda x: x + 10, range(4))
print(list(m))
Reported by Pylint.
Line: 3
Column: 1
# test subclassing a native type which can be iterated over
class mymap(map):
pass
m = mymap(lambda x: x + 10, range(4))
print(list(m))
Reported by Pylint.
tests/basics/syntaxerror_return.py
4 issues
Line: 9
Column: 5
exec
except NameError:
print("SKIP")
raise SystemExit
try:
exec('return; print("this should not be executed.")')
# if we get here then MICROPY_CPYTHON_COMPAT is disabled and test
# should be skipped.
Reported by Pylint.
Line: 12
Column: 5
raise SystemExit
try:
exec('return; print("this should not be executed.")')
# if we get here then MICROPY_CPYTHON_COMPAT is disabled and test
# should be skipped.
print("SKIP")
raise SystemExit
except SyntaxError:
Reported by Pylint.
Line: 12
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html
raise SystemExit
try:
exec('return; print("this should not be executed.")')
# if we get here then MICROPY_CPYTHON_COMPAT is disabled and test
# should be skipped.
print("SKIP")
raise SystemExit
except SyntaxError:
Reported by Bandit.
Line: 1
Column: 1
# With MICROPY_CPYTHON_COMPAT, the "return" statement can only appear in a
# function.
# Otherwise (in minimal builds), it ends execution of a module/class.
try:
exec
except NameError:
print("SKIP")
raise SystemExit
Reported by Pylint.
tests/basics/true_value.py
4 issues
Line: 14
Column: 1
if not "":
print("Empty string")
if "foo":
print("Non-empty string")
if not ():
print("Empty tuple")
if ("",):
Reported by Pylint.
Line: 19
Column: 1
if not ():
print("Empty tuple")
if ("",):
print("Non-empty tuple")
if not []:
print("Empty list")
if [0]:
Reported by Pylint.
Line: 29
Column: 1
if not {}:
print("Empty dict")
if {0:0}:
print("Non-empty dict")
Reported by Pylint.
Line: 1
Column: 1
# Test true-ish value handling
if not False:
print("False")
if not None:
print("None")
if not 0:
Reported by Pylint.
tests/basics/try1.py
4 issues
Line: 4
Column: 5
# basic exceptions
x = 1
try:
x.a()
except:
print(x)
try:
raise IndexError
Reported by Pylint.
Line: 5
Column: 1
x = 1
try:
x.a()
except:
print(x)
try:
raise IndexError
except IndexError:
Reported by Pylint.
Line: 1
Column: 1
# basic exceptions
x = 1
try:
x.a()
except:
print(x)
try:
raise IndexError
Reported by Pylint.
Line: 2
Column: 1
# basic exceptions
x = 1
try:
x.a()
except:
print(x)
try:
raise IndexError
Reported by Pylint.
tests/basics/async_for.py
4 issues
Line: 18
Column: 13
try:
value = next(self._it)
except StopIteration:
raise StopAsyncIteration
return value
async def coro():
async for letter in AsyncIteratorWrapper('abc'):
print(letter)
Reported by Pylint.
Line: 1
Column: 1
# test basic async for execution
# example taken from PEP0492
class AsyncIteratorWrapper:
def __init__(self, obj):
print('init')
self._it = iter(obj)
def __aiter__(self):
Reported by Pylint.
Line: 4
Column: 1
# test basic async for execution
# example taken from PEP0492
class AsyncIteratorWrapper:
def __init__(self, obj):
print('init')
self._it = iter(obj)
def __aiter__(self):
Reported by Pylint.
Line: 21
Column: 1
raise StopAsyncIteration
return value
async def coro():
async for letter in AsyncIteratorWrapper('abc'):
print(letter)
o = coro()
try:
Reported by Pylint.
tests/basics/assign_expr_syntaxerror.py
4 issues
Line: 5
Column: 15
def test(code):
try:
print(eval(code))
except SyntaxError:
print('SyntaxError')
test("x := 1")
test("((x, y) := 1)")
Reported by Pylint.
Line: 5
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval
def test(code):
try:
print(eval(code))
except SyntaxError:
print('SyntaxError')
test("x := 1")
test("((x, y) := 1)")
Reported by Bandit.
Line: 1
Column: 1
# test SyntaxError with := operator
def test(code):
try:
print(eval(code))
except SyntaxError:
print('SyntaxError')
test("x := 1")
Reported by Pylint.
Line: 3
Column: 1
# test SyntaxError with := operator
def test(code):
try:
print(eval(code))
except SyntaxError:
print('SyntaxError')
test("x := 1")
Reported by Pylint.
tests/basics/while_cond.py
4 issues
Line: 5
Column: 1
while 0:
print(0)
else:
print(1)
while 1:
print(2)
break
Reported by Pylint.
Line: 22
Column: 1
while False:
print('a')
else:
print('b')
while True:
print('a')
break
Reported by Pylint.
Line: 35
Column: 1
while not True:
print('a')
else:
print('b')
Reported by Pylint.
Line: 1
Column: 1
# test while conditions which are optimised by the compiler
while 0:
print(0)
else:
print(1)
while 1:
print(2)
Reported by Pylint.
tests/cpydiff/modules/foo.py
4 issues
Line: 2
Column: 1
print("foo")
xxx
Reported by Pylint.
Line: 2
Column: 1
print("foo")
xxx
Reported by Pylint.
Line: 1
Column: 1
print("foo")
xxx
Reported by Pylint.
Line: 1
Column: 1
print("foo")
xxx
Reported by Pylint.