Commit Graph

27 Commits

Author SHA1 Message Date
microDev a52eb88031
run code formatting script 2021-03-15 19:27:36 +05:30
sw23 88fcf4ef7e Removing implementation-specific values for socket/socketpool class attributes 2020-11-02 19:59:07 -05:00
sw23 1f179b3317 Adding socket and socketpool class attributes 2020-10-30 23:19:27 -04:00
Taku Fukada 56c898da80 Modify some Python stubs 2020-08-07 01:01:28 +09:00
Taku Fukada d356581651 Fix several type hints 2020-07-27 18:05:13 +09:00
Taku Fukada 54a342a7f5 Add and correct some type hints 2020-07-24 18:20:03 +09:00
dherrada 9e3fa863f1
Merge branch 'main' into type_hints 2020-07-21 16:18:51 -04:00
Scott Shawcroft 610e0171aa
Disable existing native networking.
We're moving towards a co-processor model and a Wiznet library is
already available.

New native APIs will replace these for chips with networking like the
ESP32S2 but they won't be these.
2020-07-17 17:43:02 -07:00
dherrada 612c6bb86b
Merge branch 'main' into type_hints 2020-07-17 14:55:30 -04:00
Diego Elio Pettenò 34b4993d63 Add license to some obvious files. 2020-07-06 19:16:25 +01:00
dherrada bce77adecd Added type hints previously missed 2020-07-03 16:03:19 -04:00
dherrada d0d949cd24 Made every init return None 2020-07-03 14:23:34 -04:00
dherrada 9116470fd7 Added type hints to socket 2020-07-03 11:24:53 -04:00
dherrada 54cb1feea0 Removed all 'self, )' 2020-07-02 13:28:36 -04:00
Scott Shawcroft 4e8de3c554
Swap sphinx to autoapi and the inline stubs 2020-05-12 17:28:24 -07:00
dherrada 603df58f97
Did stage, socket, storage 2020-05-11 13:40:02 -04:00
Jeff Epler 238e121236 protocols: Allow them to be (optionally) type-safe
Protocols are nice, but there is no way for C code to verify whether
a type's "protocol" structure actually implements some particular
protocol.  As a result, you can pass an object that implements the
"vfs" protocol to one that expects the "stream" protocol, and the
opposite of awesomeness ensues.

This patch adds an OPTIONAL (but enabled by default) protocol identifier
as the first member of any protocol structure.  This identifier is
simply a unique QSTR chosen by the protocol designer and used by each
protocol implementer.  When checking for protocol support, instead of
just checking whether the object's type has a non-NULL protocol field,
use `mp_proto_get` which implements the protocol check when possible.

The existing protocols are now named:
    protocol_framebuf
    protocol_i2c
    protocol_pin
    protocol_stream
    protocol_spi
    protocol_vfs
(most of these are unused in CP and are just inherited from MP; vfs and
stream are definitely used though)

I did not find any crashing examples, but here's one to give a flavor of what
is improved, using `micropython_coverage`.  Before the change,
the vfs "ioctl" protocol is invoked, and the result is not intelligible
as json (but it could have resulted in a hard fault, potentially):

    >>> import uos, ujson
    >>> u = uos.VfsPosix('/tmp')
    >>> ujson.load(u)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ValueError: syntax error in JSON

After the change, the vfs object is correctly detected as not supporting
the stream protocol:
    >>> ujson.load(p)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    OSError: stream operation not supported
2019-12-04 09:29:57 -06:00
Scott Shawcroft cfe24b8532
Improve rST consistency for rst2pyi use 2019-05-30 19:02:47 -07:00
Scott Shawcroft f29de51325
Check native object in case of early access
If a native displayio object is accessed before it's super().__init__()
has been called, then a placeholder is given that will cause a crash if
accessed. This is tricky to get right so we detect this case and raise
a NotInplementedError instead of crashing.

Fixes #1881
2019-05-13 17:31:30 -07:00
Nick Moore 58d1d99701 Fix socket.recv() buffer length from e23bad3a 2019-05-02 13:13:56 +10:00
Joshua Coats e23bad3a3a shared-bindings/socket: add socket_recv_into 2019-03-23 10:49:43 -07:00
Scott Shawcroft bd3c36ce6d
fixup m0 and nrf 2019-01-14 18:08:45 -08:00
Nick Moore 5bb12793a0 update documentation and translations again 2018-10-11 22:19:46 +11:00
Nick Moore 823ff779ca network module c api into shared-module 2018-10-11 14:02:18 +11:00
Nick Moore 15b59bee1b change initialization method + mod_network names 2018-10-04 22:31:47 +10:00
Nick Moore d33f6214f1 modify modnetwork and modusocket for circuitpython 2018-10-04 22:02:25 +10:00
Nick Moore f4c32139f5 Copy modnetwork and modusocket across from MicroPython 2018-10-04 22:02:25 +10:00