This is a follow-up to b4565b41ea (PR #1043),
to support closures, async functions and generators in `inspect.signature`.
Signed-off-by: Damien George <damien@micropython.org>
Non-functional changes only:
- Fixed minor spelling mistakes in comments.
- Corrected typos in user-facing strings.
- No variables, logic, or functional code was modified.
Signed-off-by: Marcel Petrick <mail@marcelpetrick.it>
Changes are:
- Reorganize lint settings to new sections.
- Align ignore rules with micropython/micropython repo.
- Update to python38 syntax to enable `:=` operator.
Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
The current code only calculates sectors for SDHC, with a max of 32G
The new code will calculate sectors for SDXC, with a max of 2T
C_SIZE is 22 bits[69:48] and the high 2 bits of csd[7] are required
to be 0, currently, so i'm not masking them off.
The max value for C_SIZE is 0x3FFEFF, so C_SIZE+1*1024 is a 32-bit number.
bumped version in manifest.py
Signed-off-by: Ben Wynn <bwynn@glowie.com>
Optimizations applied here are:
- writing once-used helper functions inline in their place of use
- writing once-used constant tuples inline in their place of use (I would
have used `from micropython import const` but that renders the code not
runnable under CPython for testing, and also increases code size itself
for the import)
- renamed _tmod to _t
- renamed _format to _fmt
- optimised timedelta._tuple() slightly
Reduces datetime.mpy by: 8897 -> 8728, so saves 169 bytes.
Signed-off-by: Damien George <damien@micropython.org>
This commit applies the existing `localtz.patch` patch to add support for
naive datetime objects. That is, objects that don't have any info about
the current timezone.
This allows `datetime.datetime.now()` to work; prior to this patch it would
raise NotImplementedError.
Although we don't really have support for localtime vs gmtime on
bare-metal, ports such as the unix port and webassembly port do have this
distinction, and for them being able to do `datetime.datetime.now()` is
quite important (at least, that's what users expect to be able to do).
The associated unittest test has been updated.
This patch changes the size of datetime.mpy: 8466 -> 8897, so +431 bytes.
Signed-off-by: Damien George <damien@micropython.org>
This implements a very basic `inspect.signature()` function.
At the moment it returns only a simple `Signature` instance with a
`parameters` attribute that holds an `OrderedDict` whose length matches the
arity of the input function (the number of arguments it takes).
So, the following code works and is compatible with CPython:
def f(a, b, *, c):
pass
print(len(inspect.signature(f).parameters))
That should print 3.
Signed-off-by: Damien George <damien@micropython.org>
This tells the caller that no error has occurred. The child classes can
use this state to do double buffering correctly.
If any fundamental error occurs in submit_xfer, the underlying code will
raise an exception.
Signed-off-by: Hyx <hyx0329@outlook.com>
This trivial addition will allow less code differences between standard
Python classes and MicroPython code.
Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
If BLE disconnects in the middle of a send process, this change makes the
code raise `L2CAPDisconnectedError` rather than `TypeError` due to `_cid`
being `None`.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Although `Logger.exception` supports passing exception info with
`exc_info`, when you use `logging.exception` keyword arguments are not
forwarded to the root logger, which makes passing `exc_info` raise
`TypeError`.
Signed-off-by: Nick Budak <thatbudakguy@gmail.com>
Raw REPL mode is generally used as a command channel where all stdio
traffic is related directly to the raw commands and responses sent.
For this to work in aiorepl we need to ensure background tasks don't sent/
receive anything on stdio else the command channel will be corrupted.
The simplest way to achieve this is to make the raw commands blocking and
atomic rather than asyncio, assuming the user wont leave the device in raw
mode for too long at any one time.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
This includes the following commits:
- Allow long co-author and sign-off names.
- Disallow a leading slash in commit subject line.
- Apply stricter rules on git subject line.
- Show invalid commit subjects in quotes.
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
Also optimise both `isgenerator()` and `isgeneratorfunction()` so they use
the same lambda, and don't have to create it each time they are called.
Fixes issue #997.
Signed-off-by: Damien George <damien@micropython.org>
This commit will make it possible to add headers to a Websocket.
Among other things, this allows making a connection to online MQTT brokers
over websocket, using the header entry "Sec-WebSocket-Protocol":"mqtt" in
the handshake of the upgrade protocol.
Signed-off-by: Damien George <damien@micropython.org>
According to RFC https://datatracker.ietf.org/doc/html/rfc7230#section-3.2
header names are case-insensitive.
This commit makes sure that the module behaves consistently regardless of
the casing of "Content-type" and "Content-Length" (other headers are not
considered by the module).
Without this fix, the client seems to wait for the connection termination
(~10 seconds) prior to returning any content if the casing of
"Content-Length" is different.
Signed-off-by: FuNK3Y <fun__key@hotmail.com>
The host in headers extracted from the original url may not be the same as
the host in the redirect url. Poping out the host in headers force the
code to use the host in the redirect url, otherwise the redirect may fail
due to inconsistence of hosts in the original url and the redirect url.
Signed-off-by: 黃昕暐 <meebox@gmail.com>
Newer implementations of libc integrate the functions from librt, for
example glibc since 2.17 and uClibc-ng. So if the librt.so cannot be
loaded, it can be assumed that libc contains the expected functions.
Signed-off-by: Bas van Doren <basvdoren@gmail.com>
This commit fixes a typo and changes a tuple that needs to be mutable to a
list (because other parts of the code change elements of this list).
Signed-off-by: Damien George <damien@micropython.org>
The value of the STATUS register is always transmitted by the chip when
reading any command. So a R_REGISTER command and the turnaround time can
be spared by issuing a NOP command instead.
This implementation suggested by the datasheet.
This operation is compatible with both nRF24L01 and nRF24L01+.
Signed-off-by: Marcell Pünkösd <punkosdmarcell@rocketmail.com>
The timeout condition was not handled before. Upon timeout, this caused
the chip to stay active until another send command changed it's state.
Sometimes when it was unable to transmit the data, it got stuck in the tx
fifo causing it to fill up over time, which set the TX_FULL flag in the
STATUS register.
Since there was no exceptions raised, the user code could not differentiate
a successful send or a timeout condition.
Signed-off-by: Marcell Pünkösd <punkosdmarcell@rocketmail.com>
According to the datasheet of the NRF240L1 chip, 150 μs startup time is
only acceptable when the chip is clocked externally. Most modules use a
crystal, which require 1.5 ms to settle. It should be okay to wait more in
both cases, for a reliable startup.
Signed-off-by: Marcell Pünkösd <punkosdmarcell@rocketmail.com>
Commit 35d41dbb0e changed the API for using
SSL with umqtt, but only did a minor version increase. This broke various
uses of this library, eg
https://github.com/aws-samples/aws-iot-core-getting-started-micropython
Reinstate the original API for specifying an SSL connection. This library
now supports the following:
- default, ssl=None or ssl=False: no SSL
- ssl=True and optional ssl_params specified: use ssl.wrap_socket
- ssl=<SSLContext instance>: use provided SSL context to wrap socket
Signed-off-by: Damien George <damien@micropython.org>
If a ROMFS is mounted then "/rom/lib" is usually in `sys.path` before the
writable filesystem's "lib" entry. The ROMFS directory cannot be installed
to, so skip it if found.
Signed-off-by: Damien George <damien@micropython.org>