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>
So this code can be compiled with the MicroPython native emitter, which
does not support "raise" without any arguments.
Signed-off-by: Damien George <damien@micropython.org>
This base64 library only uses `struct.unpack` which is available in the
built-in `struct` module, so no need for the micropython-lib extras.
Signed-off-by: Damien George <damien@micropython.org>
When running tests from subfolders, import by "full dotted path" rather
than just module name, removing the need to add the test parent folder to
`sys.path`.
This matches CPython more closely, which places `abspath(top)` at the start
of `sys.path` but doesn't include the test file parent dir at all.
It fixes issues where projects may include a `test_xxx.py` file in their
distribution which would (prior to this change) be unintentionally found by
unittest-discover.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Since deque was removed from this repository the built-in one needs to be
used, and that doesn't have unbounded growth. So use a list instead, which
is adequate becasue contextlib only needs append and pop, not double ended
behaviour (the previous pure-Python implementation of deque that was used
here anyway used a list as its storage container).
Also tweak the excessive-nesting test so it uses less memory and can run on
the unix port.
Signed-off-by: Damien George <damien@micropython.org>
This changes almost all uses of "u-module" to just "module" for the
following built-in modules:
- binascii
- collections
- errno
- io
- json
- socket
- struct
- sys
- time
There are some remaining uses of "u-module" naming, for the cases where the
built-in module is extended in Python, eg `python-stdlib/os` uses `uos`.
Also, there are remaining uses of `utime` when non-standard (compared to
CPython) functions are used, like `utime.ticks_ms()`.
Signed-off-by: Damien George <damien@micropython.org>
It's no longer necessary since the built-in C version of this type now
implements all the functionality here.
Signed-off-by: Matt Trentini <matt.trentini@gmail.com>
axtls doesn't define all the CERT_xxx constants, nor the MBEDTLS_VERSION
constant.
This change means that `tls.SSLContext` is imported into the module, but
that's subsequently overridden by the class definition in this module.
Signed-off-by: Damien George <damien@micropython.org>
MicroPython now supplies SSL/TLS functionality in a new built-in `tls`
module. The `ssl` module is now implemented purely in Python, in this
repository. Other libraries are updated to work with this scheme.
Signed-off-by: Felix Dörre <felix@dogcraft.de>
This is a replacement for the `zlib` module that used to be built-in and
has been replaced by the MicroPython-specific `deflate` module.
Also updates the `gzip` module in a similar fashion and provide the
`gzip.GzipFile` class and `gzip.open` function.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
- For packages that were just x.y, update to x.y.0.
- For that were x.y.z-n, update to x.y.(z+1)
From now on we'll apply semver rules:
- MAJOR version when you make incompatible API changes
- MINOR version when you add functionality in a backward compatible manner
- PATCH version when you make backward compatible bug fixes
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
With the recent MicroPython change to remove the u prefix by default on
builtins (micropython/micropython#11740) the format checker in fnmatch
which was detecting ure no longer works.
This commit updates the module to filter the regex automatically as needed.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
It is inserted automatically during publish/freezing and having them in the
code prevents the automatic process from happening.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit allows you to pass an exception object in as the exc_info kwarg
(CPython allows this), so logging exceptions can work even if the
MICROPY_PY_SYS_EXC_INFO option is disabled in the firmware.
Separately to that, currently even when sys.exc_info() is enabled, it's
only printing the traceback to _stream = sys.stderr - not to the configured
logging handlers. This means for instance if you've got a file log
handler it misses out on the tracebacks. That's also fixed in this commit.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Even though we now have a `string` module, just keep the existing
IDENTCHARS definition.
- If someone doesn't already have string installed (or aren't otherwise
importing it), this would add an extra dependency and more memory used.
- If they do, then the resulting concatenated string has to be allocated
separately, so there's no gain from using the string.x components.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This splits out each algorithm into its own extension package, so that only
the necessary algorithms can be installed.
This allows for a significant reduction in RAM and flash. i.e. previously
installing hashlib meant that all algorithms were imported.
Additionally ensures that any built-in hash algorithms (from uhashlib) are
still exposed (e.g. `md5`), and retains the existing behavior to use the
built-in preferentially.
Also includes a refactoring of the algorithms to reduce code size and
reduce the number of allocations they do as well as using bytearrays in
place of list-of-int where possible.
Add more comprehensive tests (using unittest).
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Prior to this commit, if no tests were found when running unittest discover
then nothing at all was written to stdout, leading one to think it's not
working at all. CPython unittest does display a "0 tests run" sort of
output in such a case, and this commit ensures this package does the same.
This is not included by default in most builds, and isn't necessary for
this module anyway.
Also fix the local variable shadowing the traceback module in _capture_exc.
Added test for both (works on CPython and MicroPython).
Version bump to 0.10.2.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Previously a child logger just uses the global default when unset.
Modified to matches the CPython behavior of using the parent's level.
Also implemented CPython's getEffectiveLevel() which provides a convenient
way to implement this. In our version, we only ever have one parent
(the root), so it only has to recurse one level.
Also set the default level to WARNING to match CPython.
Updated the examples to highlight the differences (but they now match).
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
* Add instructions for how to use micropython-lib.
* Add a terminology guide and use consistent terminology
(package/module/library).
* Improve code conventions and contributor guidelines.
* Misc readme updates.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>