The following issues were found
examples/network/http_client_ssl.py
8 issues
Line: 3
Column: 1
try:
import usocket as _socket
except:
import _socket
try:
import ussl as ssl
except:
import ssl
Reported by Pylint.
Line: 7
Column: 1
import _socket
try:
import ussl as ssl
except:
import ssl
def main(use_stream=True):
s = _socket.socket()
Reported by Pylint.
Line: 21
Column: 9
print("Connect address:", addr)
s.connect(addr)
s = ssl.wrap_socket(s)
print(s)
if use_stream:
# Both CPython and MicroPython SSLSocket objects support read() and
# write() methods.
Reported by Pylint.
Line: 1
Column: 1
try:
import usocket as _socket
except:
import _socket
try:
import ussl as ssl
except:
import ssl
Reported by Pylint.
Line: 11
Column: 1
import ssl
def main(use_stream=True):
s = _socket.socket()
ai = _socket.getaddrinfo("google.com", 443)
print("Address infos:", ai)
addr = ai[0][-1]
Reported by Pylint.
Line: 12
Column: 5
def main(use_stream=True):
s = _socket.socket()
ai = _socket.getaddrinfo("google.com", 443)
print("Address infos:", ai)
addr = ai[0][-1]
Reported by Pylint.
Line: 14
Column: 5
def main(use_stream=True):
s = _socket.socket()
ai = _socket.getaddrinfo("google.com", 443)
print("Address infos:", ai)
addr = ai[0][-1]
print("Connect address:", addr)
s.connect(addr)
Reported by Pylint.
Line: 21
Column: 5
print("Connect address:", addr)
s.connect(addr)
s = ssl.wrap_socket(s)
print(s)
if use_stream:
# Both CPython and MicroPython SSLSocket objects support read() and
# write() methods.
Reported by Pylint.
tests/basics/except_match_tuple.py
8 issues
Line: 4
Column: 5
# test exception matching against a tuple
try:
fail
except (Exception,):
print('except 1')
try:
fail
Reported by Pylint.
Line: 9
Column: 5
print('except 1')
try:
fail
except (Exception, Exception):
print('except 2')
try:
fail
Reported by Pylint.
Line: 19
Column: 5
print('except 3')
try:
fail
except (TypeError, ValueError, Exception):
print('except 4')
Reported by Pylint.
Line: 5
Column: 8
try:
fail
except (Exception,):
print('except 1')
try:
fail
except (Exception, Exception):
Reported by Pylint.
Line: 10
Column: 8
try:
fail
except (Exception, Exception):
print('except 2')
try:
fail
except (TypeError, NameError):
Reported by Pylint.
Line: 10
Column: 8
try:
fail
except (Exception, Exception):
print('except 2')
try:
fail
except (TypeError, NameError):
Reported by Pylint.
Line: 20
Column: 8
try:
fail
except (TypeError, ValueError, Exception):
print('except 4')
Reported by Pylint.
Line: 1
Column: 1
# test exception matching against a tuple
try:
fail
except (Exception,):
print('except 1')
try:
fail
Reported by Pylint.
tests/micropython/native_gen.py
8 issues
Line: 4
Column: 2
# test for native generators
# simple generator with yield and return
@micropython.native
def gen1(x):
yield x
yield x + 1
return x + 2
Reported by Pylint.
Line: 20
Column: 2
print(e.args[0])
# using yield from
@micropython.native
def gen2(x):
yield from range(x)
print(list(gen2(3)))
Reported by Pylint.
Line: 1
Column: 1
# test for native generators
# simple generator with yield and return
@micropython.native
def gen1(x):
yield x
yield x + 1
return x + 2
Reported by Pylint.
Line: 5
Column: 1
# simple generator with yield and return
@micropython.native
def gen1(x):
yield x
yield x + 1
return x + 2
Reported by Pylint.
Line: 5
Column: 1
# simple generator with yield and return
@micropython.native
def gen1(x):
yield x
yield x + 1
return x + 2
Reported by Pylint.
Line: 16
Column: 1
print(next(g))
try:
next(g)
except StopIteration as e:
print(e.args[0])
# using yield from
@micropython.native
def gen2(x):
Reported by Pylint.
Line: 21
Column: 1
# using yield from
@micropython.native
def gen2(x):
yield from range(x)
print(list(gen2(3)))
Reported by Pylint.
Line: 21
Column: 1
# using yield from
@micropython.native
def gen2(x):
yield from range(x)
print(list(gen2(3)))
Reported by Pylint.
tests/extmod/uheapq1.py
8 issues
Line: 2
Column: 5
try:
import uheapq as heapq
except:
try:
import heapq
except ImportError:
print("SKIP")
raise SystemExit
Reported by Pylint.
Line: 3
Column: 1
try:
import uheapq as heapq
except:
try:
import heapq
except ImportError:
print("SKIP")
raise SystemExit
Reported by Pylint.
Line: 8
Column: 9
import heapq
except ImportError:
print("SKIP")
raise SystemExit
try:
heapq.heappop([])
except IndexError:
print("IndexError")
Reported by Pylint.
Line: 21
Column: 19
print("TypeError")
def pop_and_print(h):
l = []
while h:
l.append(str(heapq.heappop(h)))
print(" ".join(l))
Reported by Pylint.
Line: 1
Column: 1
try:
import uheapq as heapq
except:
try:
import heapq
except ImportError:
print("SKIP")
raise SystemExit
Reported by Pylint.
Line: 21
Column: 1
print("TypeError")
def pop_and_print(h):
l = []
while h:
l.append(str(heapq.heappop(h)))
print(" ".join(l))
Reported by Pylint.
Line: 21
Column: 1
print("TypeError")
def pop_and_print(h):
l = []
while h:
l.append(str(heapq.heappop(h)))
print(" ".join(l))
Reported by Pylint.
Line: 22
Column: 5
def pop_and_print(h):
l = []
while h:
l.append(str(heapq.heappop(h)))
print(" ".join(l))
Reported by Pylint.
tests/cpydiff/core_import_split_ns_pkgs.py
8 issues
Line: 12
Column: 1
sys.path.append(sys.path[1] + "/modules")
sys.path.append(sys.path[1] + "/modules2")
import subpkg.foo
import subpkg.bar
print("Two modules of a split namespace package imported")
Reported by Pylint.
Line: 13
Column: 1
sys.path.append(sys.path[1] + "/modules2")
import subpkg.foo
import subpkg.bar
print("Two modules of a split namespace package imported")
Reported by Pylint.
Line: 12
Column: 1
sys.path.append(sys.path[1] + "/modules")
sys.path.append(sys.path[1] + "/modules2")
import subpkg.foo
import subpkg.bar
print("Two modules of a split namespace package imported")
Reported by Pylint.
Line: 13
Column: 1
sys.path.append(sys.path[1] + "/modules2")
import subpkg.foo
import subpkg.bar
print("Two modules of a split namespace package imported")
Reported by Pylint.
Line: 4
Column: 1
"""
categories: Core,import
description: MicroPython does't support namespace packages split across filesystem.
cause: MicroPython's import system is highly optimized for simplicity, minimal memory usage, and minimal filesystem search overhead.
workaround: Don't install modules belonging to the same namespace package in different directories. For MicroPython, it's recommended to have at most 3-component module search paths: for your current application, per-user (writable), system-wide (non-writable).
"""
import sys
sys.path.append(sys.path[1] + "/modules")
Reported by Pylint.
Line: 5
Column: 1
categories: Core,import
description: MicroPython does't support namespace packages split across filesystem.
cause: MicroPython's import system is highly optimized for simplicity, minimal memory usage, and minimal filesystem search overhead.
workaround: Don't install modules belonging to the same namespace package in different directories. For MicroPython, it's recommended to have at most 3-component module search paths: for your current application, per-user (writable), system-wide (non-writable).
"""
import sys
sys.path.append(sys.path[1] + "/modules")
sys.path.append(sys.path[1] + "/modules2")
Reported by Pylint.
Line: 12
Column: 1
sys.path.append(sys.path[1] + "/modules")
sys.path.append(sys.path[1] + "/modules2")
import subpkg.foo
import subpkg.bar
print("Two modules of a split namespace package imported")
Reported by Pylint.
Line: 13
Column: 1
sys.path.append(sys.path[1] + "/modules2")
import subpkg.foo
import subpkg.bar
print("Two modules of a split namespace package imported")
Reported by Pylint.
tests/extmod/ujson_dump_iobase.py
8 issues
Line: 11
Column: 9
import io, json
except ImportError:
print("SKIP")
raise SystemExit
if not hasattr(io, "IOBase"):
print("SKIP")
raise SystemExit
Reported by Pylint.
Line: 20
Column: 5
# a user stream that only has the write method
class S(io.IOBase):
def __init__(self):
self.buf = ""
def write(self, buf):
if type(buf) == bytearray:
# uPy passes a bytearray, CPython passes a str
Reported by Pylint.
Line: 1
Column: 1
# test ujson.dump in combination with uio.IOBase
try:
import uio as io
import ujson as json
except ImportError:
try:
import io, json
except ImportError:
Reported by Pylint.
Line: 8
Column: 9
import ujson as json
except ImportError:
try:
import io, json
except ImportError:
print("SKIP")
raise SystemExit
if not hasattr(io, "IOBase"):
Reported by Pylint.
Line: 19
Column: 1
# a user stream that only has the write method
class S(io.IOBase):
def __init__(self):
self.buf = ""
def write(self, buf):
if type(buf) == bytearray:
Reported by Pylint.
Line: 19
Column: 1
# a user stream that only has the write method
class S(io.IOBase):
def __init__(self):
self.buf = ""
def write(self, buf):
if type(buf) == bytearray:
Reported by Pylint.
Line: 23
Column: 5
def __init__(self):
self.buf = ""
def write(self, buf):
if type(buf) == bytearray:
# uPy passes a bytearray, CPython passes a str
buf = str(buf, "ascii")
self.buf += buf
return len(buf)
Reported by Pylint.
Line: 24
Column: 12
self.buf = ""
def write(self, buf):
if type(buf) == bytearray:
# uPy passes a bytearray, CPython passes a str
buf = str(buf, "ascii")
self.buf += buf
return len(buf)
Reported by Pylint.
ports/stm32/usbhost/Class/MSC/Src/usbh_msc_scsi.c
8 issues
Line: 346
CWE codes:
758
MSC_Handle->hbot.cbw.field.CB[0] = OPCODE_WRITE10;
/*logical block address*/
MSC_Handle->hbot.cbw.field.CB[2] = (((uint8_t*)&address)[3]);
MSC_Handle->hbot.cbw.field.CB[3] = (((uint8_t*)&address)[2]);
MSC_Handle->hbot.cbw.field.CB[4] = (((uint8_t*)&address)[1]);
MSC_Handle->hbot.cbw.field.CB[5] = (((uint8_t*)&address)[0]);
Reported by Cppcheck.
Line: 347
CWE codes:
758
/*logical block address*/
MSC_Handle->hbot.cbw.field.CB[2] = (((uint8_t*)&address)[3]);
MSC_Handle->hbot.cbw.field.CB[3] = (((uint8_t*)&address)[2]);
MSC_Handle->hbot.cbw.field.CB[4] = (((uint8_t*)&address)[1]);
MSC_Handle->hbot.cbw.field.CB[5] = (((uint8_t*)&address)[0]);
/*Tranfer length */
Reported by Cppcheck.
Line: 348
CWE codes:
758
/*logical block address*/
MSC_Handle->hbot.cbw.field.CB[2] = (((uint8_t*)&address)[3]);
MSC_Handle->hbot.cbw.field.CB[3] = (((uint8_t*)&address)[2]);
MSC_Handle->hbot.cbw.field.CB[4] = (((uint8_t*)&address)[1]);
MSC_Handle->hbot.cbw.field.CB[5] = (((uint8_t*)&address)[0]);
/*Tranfer length */
MSC_Handle->hbot.cbw.field.CB[7] = (((uint8_t *)&length)[1]) ;
Reported by Cppcheck.
Line: 353
CWE codes:
758
/*Tranfer length */
MSC_Handle->hbot.cbw.field.CB[7] = (((uint8_t *)&length)[1]) ;
MSC_Handle->hbot.cbw.field.CB[8] = (((uint8_t *)&length)[0]) ;
MSC_Handle->hbot.state = BOT_SEND_CBW;
MSC_Handle->hbot.cmd_state = BOT_CMD_WAIT;
Reported by Cppcheck.
Line: 406
CWE codes:
758
MSC_Handle->hbot.cbw.field.CB[0] = OPCODE_READ10;
/*logical block address*/
MSC_Handle->hbot.cbw.field.CB[2] = (((uint8_t*)&address)[3]);
MSC_Handle->hbot.cbw.field.CB[3] = (((uint8_t*)&address)[2]);
MSC_Handle->hbot.cbw.field.CB[4] = (((uint8_t*)&address)[1]);
MSC_Handle->hbot.cbw.field.CB[5] = (((uint8_t*)&address)[0]);
Reported by Cppcheck.
Line: 407
CWE codes:
758
/*logical block address*/
MSC_Handle->hbot.cbw.field.CB[2] = (((uint8_t*)&address)[3]);
MSC_Handle->hbot.cbw.field.CB[3] = (((uint8_t*)&address)[2]);
MSC_Handle->hbot.cbw.field.CB[4] = (((uint8_t*)&address)[1]);
MSC_Handle->hbot.cbw.field.CB[5] = (((uint8_t*)&address)[0]);
/*Tranfer length */
Reported by Cppcheck.
Line: 408
CWE codes:
758
/*logical block address*/
MSC_Handle->hbot.cbw.field.CB[2] = (((uint8_t*)&address)[3]);
MSC_Handle->hbot.cbw.field.CB[3] = (((uint8_t*)&address)[2]);
MSC_Handle->hbot.cbw.field.CB[4] = (((uint8_t*)&address)[1]);
MSC_Handle->hbot.cbw.field.CB[5] = (((uint8_t*)&address)[0]);
/*Tranfer length */
MSC_Handle->hbot.cbw.field.CB[7] = (((uint8_t *)&length)[1]) ;
Reported by Cppcheck.
Line: 413
CWE codes:
758
/*Tranfer length */
MSC_Handle->hbot.cbw.field.CB[7] = (((uint8_t *)&length)[1]) ;
MSC_Handle->hbot.cbw.field.CB[8] = (((uint8_t *)&length)[0]) ;
MSC_Handle->hbot.state = BOT_SEND_CBW;
MSC_Handle->hbot.cmd_state = BOT_CMD_WAIT;
Reported by Cppcheck.
tests/basics/class_super_aslocal.py
8 issues
Line: 5
Column: 9
class A:
def foo(self):
super = [1, 2]
super.pop()
print(super)
A().foo()
Reported by Pylint.
Line: 1
Column: 1
# test using the name "super" as a local variable
class A:
def foo(self):
super = [1, 2]
super.pop()
print(super)
A().foo()
Reported by Pylint.
Line: 3
Column: 1
# test using the name "super" as a local variable
class A:
def foo(self):
super = [1, 2]
super.pop()
print(super)
A().foo()
Reported by Pylint.
Line: 3
Column: 1
# test using the name "super" as a local variable
class A:
def foo(self):
super = [1, 2]
super.pop()
print(super)
A().foo()
Reported by Pylint.
Line: 3
Column: 1
# test using the name "super" as a local variable
class A:
def foo(self):
super = [1, 2]
super.pop()
print(super)
A().foo()
Reported by Pylint.
Line: 4
Column: 5
# test using the name "super" as a local variable
class A:
def foo(self):
super = [1, 2]
super.pop()
print(super)
A().foo()
Reported by Pylint.
Line: 4
Column: 5
# test using the name "super" as a local variable
class A:
def foo(self):
super = [1, 2]
super.pop()
print(super)
A().foo()
Reported by Pylint.
Line: 4
Column: 5
# test using the name "super" as a local variable
class A:
def foo(self):
super = [1, 2]
super.pop()
print(super)
A().foo()
Reported by Pylint.
tests/basics/class_str.py
8 issues
Line: 1
Column: 1
class C1:
def __init__(self, value):
self.value = value
def __str__(self):
return "str<C1 {}>".format(self.value)
class C2:
def __init__(self, value):
Reported by Pylint.
Line: 1
Column: 1
class C1:
def __init__(self, value):
self.value = value
def __str__(self):
return "str<C1 {}>".format(self.value)
class C2:
def __init__(self, value):
Reported by Pylint.
Line: 1
Column: 1
class C1:
def __init__(self, value):
self.value = value
def __str__(self):
return "str<C1 {}>".format(self.value)
class C2:
def __init__(self, value):
Reported by Pylint.
Line: 8
Column: 1
def __str__(self):
return "str<C1 {}>".format(self.value)
class C2:
def __init__(self, value):
self.value = value
def __repr__(self):
return "repr<C2 {}>".format(self.value)
Reported by Pylint.
Line: 8
Column: 1
def __str__(self):
return "str<C1 {}>".format(self.value)
class C2:
def __init__(self, value):
self.value = value
def __repr__(self):
return "repr<C2 {}>".format(self.value)
Reported by Pylint.
Line: 15
Column: 1
def __repr__(self):
return "repr<C2 {}>".format(self.value)
class C3:
def __init__(self, value):
self.value = value
def __str__(self):
return "str<C3 {}>".format(self.value)
Reported by Pylint.
Line: 31
Column: 1
c2 = C2(2)
print(c2)
s11 = str(c1)
print(s11)
# This will use builtin repr(), which uses id(), which is of course different
# between CPython and MicroPython
s12 = repr(c1)
print("C1 object at" in s12)
Reported by Pylint.
Line: 38
Column: 1
s12 = repr(c1)
print("C1 object at" in s12)
s21 = str(c2)
print(s21)
s22 = repr(c2)
print(s22)
c3 = C3(1)
Reported by Pylint.
tests/cpydiff/core_generator_noexit.py
8 issues
Line: 9
Column: 1
"""
class foo(object):
def __enter__(self):
print("Enter")
def __exit__(self, *args):
print("Exit")
Reported by Pylint.
Line: 9
Column: 1
"""
class foo(object):
def __enter__(self):
print("Enter")
def __exit__(self, *args):
print("Exit")
Reported by Pylint.
Line: 9
Column: 1
"""
class foo(object):
def __enter__(self):
print("Enter")
def __exit__(self, *args):
print("Exit")
Reported by Pylint.
Line: 17
Column: 1
print("Exit")
def bar(x):
with foo():
while True:
x += 1
yield x
Reported by Pylint.
Line: 17
Column: 1
print("Exit")
def bar(x):
with foo():
while True:
x += 1
yield x
Reported by Pylint.
Line: 17
Column: 1
print("Exit")
def bar(x):
with foo():
while True:
x += 1
yield x
Reported by Pylint.
Line: 24
Column: 1
yield x
def func():
g = bar(0)
for _ in range(3):
print(next(g))
Reported by Pylint.
Line: 25
Column: 5
def func():
g = bar(0)
for _ in range(3):
print(next(g))
func()
Reported by Pylint.