summaryrefslogtreecommitdiff
path: root/extmod/moduzlib.c
AgeCommit message (Collapse)Author
2020-07-06Add license to some obvious files.Diego Elio Pettenò
2019-12-04protocols: Allow them to be (optionally) type-safeJeff Epler
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-01-18More make_new fixes for unix buildScott Shawcroft
2018-09-09uzlib: Upgrade to uzlib v2.9 releaseJeff Epler
This fixes a large number of crashes on malformed inputs.
2018-08-16Fix esp and samdScott Shawcroft
2018-07-11WIP: after merge; before testingDan Halbert
2018-06-18extmod: Update to use new mp_get_stream helper.Damien George
With this patch objects are only checked that they have the stream protocol at the start of their use as a stream, and afterwards the efficient mp_get_stream() helper is used to extract the stream protocol C methods.
2018-05-07uzlib: convert to submoduleJeff Epler
Textualy, the files in lib/uzlib/src were identical to the ones committed in extmod/uzlib so there should be no behavioral change possible as a result of this commit.
2017-10-04all: Remove inclusion of internal py header files.Damien George
Header files that are considered internal to the py core and should not normally be included directly are: py/nlr.h - internal nlr configuration and declarations py/bc0.h - contains bytecode macro definitions py/runtime0.h - contains basic runtime enums Instead, the top-level header files to include are one of: py/obj.h - includes runtime0.h and defines everything to use the mp_obj_t type py/runtime.h - includes mpstate.h and hence nlr.h, obj.h, runtime0.h, and defines everything to use the general runtime support functions Additional, specific headers (eg py/objlist.h) can be included if needed.
2017-08-13all: Raise exceptions via mp_raise_XXXJavier Candeira
- Changed: ValueError, TypeError, NotImplementedError - OSError invocations unchanged, because the corresponding utility function takes ints, not strings like the long form invocation. - OverflowError, IndexError and RuntimeError etc. not changed for now until we decide whether to add new utility functions.
2017-07-31all: Use the name MicroPython consistently in commentsAlexander Steffen
There were several different spellings of MicroPython present in comments, when there should be only one.
2017-06-24extmod/moduzlib: decompress: Remove stale "(void)n_args".Paul Sokolovsky
n_args is now actually used in this function.
2016-11-14all: Remove readall() method, which is equivalent to read() w/o args.Paul Sokolovsky
Its addition was due to an early exploration on how to add CPython-like stream interface. It's clear that it's not needed and just takes up bytes in all ports.
2016-10-07extmod: Use mp_raise_OSError helper function.Damien George
2016-09-24extmod/moduzlib: DecompIO: Add support for gzip-formatted streams.Paul Sokolovsky
This uses extension introduced in CPython 3.5: if wbits (dictionary size code) has value 16 + 8..15, it means that gzip-formatted stream expected.
2016-09-22all: Remove 'name' member from mp_obj_module_t struct.Damien George
One can instead lookup __name__ in the modules dict to get the value.
2016-09-04extmod/moduzlib: Support wbits arg to DecompIO.Paul Sokolovsky
2016-09-03extmod/moduzlib: Use mperrno.h for error constants.Paul Sokolovsky
2016-09-03extmod/moduzlib: Implement zlib stream decompressor class, DecompIO.Paul Sokolovsky
2016-08-17extmod/moduzlib: Refactor to new stream-compatible uzlib 2.0 API.Paul Sokolovsky
2016-01-11py: Change type signature of builtin funs that take variable or kw args.Damien George
With this patch the n_args parameter is changed type from mp_uint_t to size_t.
2015-11-29py: Add MP_ROM_* macros and mp_rom_* types and use them.Damien George
2015-03-14py, extmod: Remove include of unnecessary system headers.Damien George
2015-01-28moduzlib: Align out buffer to block size; shrink when decompression done.Paul Sokolovsky
2015-01-28moduzlib: Implement raw DEFLATE decoding support.Paul Sokolovsky
2015-01-20py, unix: Allow to compile with -Wunused-parameter.Damien George
See issue #699.
2015-01-01extmod: Prefix py/ for includes from py core directory.Damien George
2014-11-29Use MP_DEFINE_CONST_DICT macro to define module dicts.Damien George
This is just a clean-up of the code. Generated code is exactly the same.
2014-10-12moduzlib: Fix fn prototype and some code style; use it in stmhal port.Damien George
2014-10-13moduzlib: New zlib-like module, based on uzlib.Paul Sokolovsky