mirror of
https://github.com/micropython/micropython.git
synced 2026-01-06 12:10:13 +01:00
unix/modsocket: Use type-checking mp_obj_get_int.
MP_OBJ_SMALL_INT_VALUE would give erroneous results, such as assertion
failures in the coverage build and other oddities like:
>>> s = socket.socket()
>>> s.recv(3.14)
MemoryError: memory allocation failed, allocating 4235896656 bytes
Signed-off-by: Jeff Epler <jepler@gmail.com>
This commit is contained in:
committed by
Damien George
parent
6d640a15ab
commit
e9da4c9c98
22
tests/extmod/socket_badconstructor.py
Normal file
22
tests/extmod/socket_badconstructor.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# Test passing in bad values to socket.socket constructor.
|
||||
|
||||
try:
|
||||
import socket
|
||||
except:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
try:
|
||||
s = socket.socket(None)
|
||||
except TypeError:
|
||||
print("TypeError")
|
||||
|
||||
try:
|
||||
s = socket.socket(socket.AF_INET, None)
|
||||
except TypeError:
|
||||
print("TypeError")
|
||||
|
||||
try:
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_RAW, None)
|
||||
except TypeError:
|
||||
print("TypeError")
|
||||
Reference in New Issue
Block a user