summaryrefslogtreecommitdiff
path: root/py
AgeCommit message (Collapse)Author
2016-09-05py: Add MICROPY_USE_INTERNAL_PRINTF option, defaults to enabled.Delio Brignoli
This new config option allows to control whether MicroPython uses its own internal printf or not (if not, an external one should be linked in). Accompanying this new option is the inclusion of lib/utils/printf.c in the core list of source files, so that ports no longer need to include it themselves.
2016-09-04py/emitglue.c: provide mp_raw_code_load_file for any unix architectureChris Packham
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
2016-09-02py: If str/bytes hash is 0 then explicitly compute it.Damien George
2016-09-02py/makeqstrdata.py: Compute the qstr hash from bytes, not characters.Damien George
2016-09-01py/mpprint: Fail an assertion with unsupported format specifiers.Delio Brignoli
Arguments of an unknown type cannot be skipped and continuing to parse a format string after encountering an unknown format specifier leads to undefined behaviour. This patch helps to find use of unsupported formats.
2016-09-01extmod: Add machine_spi with generic SPI C-protocol and helper methods.Damien George
The idea is that all ports can use these helper methods and only need to provide initialisation of the SPI bus, as well as a single transfer function. The coding pattern follows the stream protocol and helper methods.
2016-08-30py/mkrules.mk: Allow to override name of libmicropython.aPaul Sokolovsky
Or alternatively, refer to an exact library file, not just phony target "lib".
2016-08-27py/bc.h: Rename _mp_code_state to _mp_code_state_t.Damien George
This rename was missed in the previous patch.
2016-08-27py: Rename struct mp_code_state to mp_code_state_t.Damien George
Also at _t to mp_exc_stack pre-declaration in struct typedef.
2016-08-26py/emitglue: Use more compact mp_raise_ValueError function.Damien George
2016-08-26py/modstruct: Use more compact mp_raise_ValueError function.Damien George
Saves a few bytes of code size.
2016-08-26py/compile: Don't compile assert statements when optimisations enabled.Damien George
As per CPython.
2016-08-26py/gc: Add MICROPY_GC_CONSERVATIVE_CLEAR option to always zero memory.Damien George
There can be stray pointers in memory blocks that are not properly zero'd after allocation. This patch adds a new config option to always zero all allocated memory (via gc_alloc and gc_realloc) and hence help to eliminate stray pointers. See issue #2195.
2016-08-24extmod/modubinascii: Make crc32() support configurable.Paul Sokolovsky
Disable by default, enable in unix port.
2016-08-24py/stream.c: use mp_obj_get_type in mp_get_stream_raiseKrzysztof Blazewicz
In current state `mp_get_stream_raise` assumes that `self_in` is an object and always performs a pointer derefence which may cause a segfault. This function shall throw an exception whenever `self_in` does not implement a stream protocol, that includes qstr's and numbers. fixes #2331
2016-08-15py/sequence: Allow to use bignums as indices in slice objects.Damien George
See issue #2264.
2016-08-15py/obj.h: For obj reprs A,B,C use void* explicitly for mp_obj_t typedef.Damien George
The machine_ptr_t type is long obsolete as the type of mp_obj_t is now defined by the object representation, ie by MICROPY_OBJ_REPR. So just use void* explicitly for the typedef of mp_obj_t. If a port wants to use something different then they should define a new object representation.
2016-08-14py/objstr: Use mp_raise_{Type,Value}Error instead of mp_raise_msg.Damien George
This patch does further refactoring using the new mp_raise_TypeError and mp_raise_ValueError functions.
2016-08-14py/runtime.h: Move comment about mp_not_implemented to correct place.Damien George
2016-08-14py/objtuple: In tuple_cmp_helper, use mp_check_self instead of raising.Damien George
Only tuple, namedtuple and attrtuple use the tuple_cmp_helper function, and they all have getiter=mp_obj_tuple_getiter, so the check here is only to ensure that the self object is consistent. Hence use mp_check_self.
2016-08-12py: Get rid of assert() in method argument checking functions.Paul Sokolovsky
Checks for number of args removes where guaranteed by function descriptor, self checking is replaced with mp_check_self(). In few cases, exception is raised instead of assert.
2016-08-12py/objdict: Get rid of asserts (remove/replace with mp_check_self()).Paul Sokolovsky
2016-08-12py/runtime.h: Define mp_check_self(pred) helper macro.Paul Sokolovsky
Indended to replace raw asserts in bunch of files. Expands to empty if MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG is defined, otehrwise by default still to assert, though a particular port may define it to something else.
2016-08-12py/runtime: Factor out exception raising helpers.Paul Sokolovsky
Introduce mp_raise_msg(), mp_raise_ValueError(), mp_raise_TypeError() instead of previous pattern nlr_raise(mp_obj_new_exception_msg(...)). Save few bytes on each call, which are many.
2016-08-07py/mpconfig.h: Define MP_ALWAYSINLINE for reuse.Paul Sokolovsky
Similar to existing MP_NOINLINE.
2016-08-07py/objstr,objstrunicode: Fix inconistent #if indentation.Paul Sokolovsky
2016-08-07py/objstr: Make .partition()/.rpartition() methods configurable.Paul Sokolovsky
Default is disabled, enabled for unix port. Saves 600 bytes on x86.
2016-08-04py/mkrules.mk: Allow to add more items for "clean" target using CLEAN_EXTRA.Paul Sokolovsky
2016-07-31py/py.mk: Extra switches to build "embedded" BerkeleyDB BTree lib.Paul Sokolovsky
2016-07-30py/mpconfig.h: Add MICROPY_STREAMS_POSIX_API setting.Paul Sokolovsky
To filter out even prototypes of mp_stream_posix_*() functions, which require POSIX types like ssize_t & off_t, which may be not available in some ports.
2016-07-30lib/embed/abort_: Implementation of abort_() function raising uPy exception.Paul Sokolovsky
Helpful when porting existing C libraries to MicroPython. abort()ing in embedded environment isn't a good idea, so when compiling such library, -Dabort=abort_ option can be given to redirect standard abort() to this "safe" version.
2016-07-30py/stream: Add adapter methods with POSIX-compatible signatures.Paul Sokolovsky
Previoussly such read() and write() methods were used by modussl_axtls, move to py/stream for reuse.
2016-07-28py/objstringio: Implement MP_STREAM_SEEK ioctl and add seek() method.Paul Sokolovsky
2016-07-28py/objstringio: Add MP_STREAM_FLUSH ioctl and flush() method.Paul Sokolovsky
No-op for this object.
2016-07-27py/stream: Implement generic flush() method, in terms of C-level ioctl.Paul Sokolovsky
2016-07-26py/stream: Stream module works with errno's, so should include mperrno.h.Paul Sokolovsky
2016-07-25py/objstrunicode: str_index_to_ptr: Implement positive indexing properly.Paul Sokolovsky
Order out-of-bounds check, completion check, and increment in the right way.
2016-07-25py/objstrunicode: str_index_to_ptr: Should handle bytes too.Paul Sokolovsky
There's single str_index_to_ptr() function, called for both bytes and unicode objects, so should handle each properly.
2016-07-25py/stream.h: Remove dated comment of POSIX-specificity of EAGAIN.Paul Sokolovsky
We have adopted POSIX-compatible error numbers as MicroPython's native.
2016-07-25py/stream.h: Move mp_stream_write_adaptor() inside ifdef block.Paul Sokolovsky
2016-07-22unix: Enable MICROPY_PY_STR_BYTES_CMP_WARN.Paul Sokolovsky
Also, fix a warning text (remove "duplicate" BytesWarning).
2016-07-22py/mpconfig.h: Fix description for MICROPY_PY_STR_BYTES_CMP_WARN.Paul Sokolovsky
2016-07-22py/obj: Issue a warning when str and bytes objects are compared.Paul Sokolovsky
Something like: if foo == "bar": will be always false if foo is b"bar". In CPython, warning is issued if interpreter is started as "python3 -b". In MicroPython, MICROPY_PY_STR_BYTES_CMP_WARN setting controls it.
2016-07-21py: Fix nlrthumb.c when DEBUG=1 is definedDave Hylands
2016-07-21py/gc: Implement GC running by allocation threshold.Paul Sokolovsky
Currently, MicroPython runs GC when it could not allocate a block of memory, which happens when heap is exhausted. However, that policy can't work well with "inifinity" heaps, e.g. backed by a virtual memory - there will be a lot of swap thrashing long before VM will be exhausted. Instead, in such cases "allocation threshold" policy is used: a GC is run after some number of allocations have been made. Details vary, for example, number or total amount of allocations can be used, threshold may be self-adjusting based on GC outcome, etc. This change implements a simple variant of such policy for MicroPython. Amount of allocated memory so far is used for threshold, to make it useful to typical finite-size, and small, heaps as used with MicroPython ports. And such GC policy is indeed useful for such types of heaps too, as it allows to better control fragmentation. For example, if a threshold is set to half size of heap, then for an application which usually makes big number of small allocations, that will (try to) keep half of heap memory in a nice defragmented state for an occasional large allocation. For an application which doesn't exhibit such behavior, there won't be any visible effects, except for GC running more frequently, which however may affect performance. To address this, the GC threshold is configurable, and by default is off so far. It's configured with gc.threshold(amount_in_bytes) call (can be queries without an argument).
2016-07-16esp8266: Cache Xtensa-built libaxtls.a in local build dir.Paul Sokolovsky
Allows to build the library variant for other archs in parallel.
2016-07-14py/stream: Implement 2- and 3-arg write() method as an extension to CPython.Paul Sokolovsky
3-arg form: stream.write(data, offset, length) 2-arg form: stream.write(data, length) These allow efficient buffer writing without incurring extra memory allocation for slicing or creating memoryview() object, what is important for low-memory ports. All arguments must be positional. It might be not so bad idea to standardize on 3-arg form, but 2-arg case would need check and raising an exception anyway then, so instead it was just made to work.
2016-07-13extmod/modussl_axtls: Further changes to allow alternative SSL modules.Paul Sokolovsky
Make variable MICROPY_SSL_AXTLS=1 should be defined to activate modussl_axtls and link with -laxtls.
2016-07-13extmod/modussl: Rename to modussl_axtls.c, to allow impl using other SSL libs.Paul Sokolovsky
2016-07-11py/nlrx64.S: Prefix mp_thread_get_state with an underscore on Mac.Damien George