summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2017-10-03py/objset: Check that RHS of a binary op is a set/frozenset.Damien George
CPython docs explicitly state that the RHS of a set/frozenset binary op must be a set to prevent user errors. It also preserves commutativity of the ops, eg: "abc" & set() is a TypeError, and so should be set() & "abc". This change actually decreases unix (x64) code by 160 bytes; it increases stm32 by 4 bytes and esp8266 by 28 bytes (but previous patch already introduced a much large saving).
2017-10-03py/objset: Simplify set and frozenset by separating their locals dicts.Damien George
A lot of set's methods (the mutable ones) are not allowed to operate on a frozenset, and giving frozenset a separate locals dict with only the methods that it supports allows to simplify the logic that verifies if args are a set or a frozenset. Even though the new frozenset locals dict is relatively large (88 bytes on 32-bit archs) there is a much bigger saving coming from the removal of a const string for an error message, along with the removal of some checks for set or frozenset type. Changes in code size due to this patch are (for ports that changed at all): unix x64: -56 unix nanbox: -304 stm32: -64 esp8266: -124 cc3200: -40 Apart from the reduced code, frozenset now has better tab-completion because it only lists the valid methods. And the error message for accessing an invalid method is now more detailed (it includes the method name that wasn't found).
2017-10-03tests/extmod: Add test for ure regexes leading to infinite recursion.Paul Sokolovsky
These now should be caught properly and lead to RuntimeError instead of crash.
2017-10-03extmod/modure: Add stack overflow checking when executing a regex.Paul Sokolovsky
2017-10-02extmod/re1.5: Upgrade to v0.8.2, adds hook for stack overflow checking.Paul Sokolovsky
2017-09-29tools/upip: Upgrade to 1.2.2.Paul Sokolovsky
TLS SNI support, fixes after making str.rstrip() behavior compliant.
2017-09-26py/objfloat: Support raising a negative number to a fractional power.Damien George
This returns a complex number, following CPython behaviour. For ports that don't have complex numbers enabled this will raise a ValueError which gives a fail-safe for scripts that were written assuming complex numbers exist.
2017-09-26py: Add config option to print warnings/errors to stderr.David Lechner
This adds a new configuration option to print runtime warnings and errors to stderr. On Unix, CPython prints warnings and unhandled exceptions to stderr, so the unix port here is configured to use this option. The unix port already printed unhandled exceptions on the main thread to stderr. This patch fixes unhandled exceptions on other threads and warnings (issue #2838) not printing on stderr. Additionally, a couple tests needed to be fixed to handle this new behavior. This is done by also capturing stderr when running tests.
2017-09-25py: Clarify which mp_unary_op_t's may appear in the bytecode.Paul Sokolovsky
Not all can, so we don't need to reserve bytecodes for them, and can use free slots for something else later.
2017-09-25py/persistentcode: Define mp_raw_code_save_file() for any unix target.Anton Patrushev
A unix target should provide POSIX open/write/close functions regardless of its machine architecture. Fixes issue #3325.
2017-09-25drivers/display/ssd1306.py: Improve performance of graphics methods.Peter Hinch
It removes the need for a wrapper Python function to dispatch to the framebuf method which makes each function call a bit faster, roughly 2.5x. This patch also adds the rest of the framebuf methods to the SSD class.
2017-09-25stm32/timer: Enable ARPE so that timer freq can be changed smoothly.Damien George
The timer prescaler is buffered by default, and this patch enables ARPE which buffers the auto-reload register. With both of these registers buffered it's now possible to smoothly change the timer's frequency and have a smoothly varying PWM output.
2017-09-24extmod/re1.5: Update to 0.8.1.Paul Sokolovsky
Allow literal minus in char classes to be in trailing position, e.g. [a-c-]. (Previously, minus was allowed only at the start.) This increases ARM Thumb2 code size by 8 bytes.
2017-09-22py/runtime0: Add comments about unary/binary-op enums used in bytecode.Damien George
2017-09-22lib/embed/abort_: Use mp_raise_msg helper function.Damien George
2017-09-22py/vm: Use lowercase letter at start of exception message.Damien George
For consistency with all the other exception messages.
2017-09-22stm32/usbdev: Move all the USB device descriptor state into its struct.Damien George
2017-09-22stm32/usbdev: Make device descriptor callbacks take a state pointer.Damien George
2017-09-21stm32/usbdev: Merge all global USB device state into a single struct.Damien George
This is the final piece of USB device refactoring to support multiple USB device instances.
2017-09-21stm32/usbdev: Simplify pointers to MSC state and block dev operations.Damien George
2017-09-21stm32/usbdev: Put all state for the USB device driver in a struct.Damien George
2017-09-21stm32/usbdev/core: Add state parameter to all callback functions.Damien George
2017-09-21stm32/usbdev: Simplify HID tx/rx buffer passing.Damien George
2017-09-21stm32/usbdev: Simplify CDC tx/rx buffer passing.Damien George
2017-09-21stm32/usbdev: Put all HID state in a struct.Damien George
2017-09-21stm32/usbdev: Put all CDC state in a struct.Damien George
2017-09-21py/vstr: Raise a RuntimeError if fixed vstr buffer overflows.Damien George
Current users of fixed vstr buffers (building file paths) assume that there is no overflow and do not check for overflow after building the vstr. This has the potential to lead to NULL pointer dereferences (when vstr_null_terminated_str returns NULL because it can't allocate RAM for the terminating byte) and stat'ing and loading invalid path names (due to the path being truncated). The safest and simplest thing to do in these cases is just raise an exception if a write goes beyond the end of a fixed vstr buffer, which is what this patch does. It also simplifies the vstr code.
2017-09-21py/stream: Remove unnecessary checks for NULL return from vstr_add_len.Damien George
The vstr argument to the calls to vstr_add_len are dynamically allocated (ie fixed_buf=false) and so vstr_add_len will never return NULL. So there's no need to check for it. Any out-of-memory errors are raised by the call to m_renew in vstr_ensure_extra.
2017-09-21py/objexcept: Prevent infinite recursion when allocating exceptions.Damien George
The aim of this patch is to rewrite the functions that create exception instances (mp_obj_exception_make_new and mp_obj_new_exception_msg_varg) so that they do not call any functions that may raise an exception. Otherwise it's possible to create infinite recursion with an exception being raised while trying to create an exception object. The two main things that are done to accomplish this are: 1. Change mp_obj_new_exception_msg_varg to just format the string, then call mp_obj_exception_make_new to actually create the exception object. 2. In mp_obj_exception_make_new and mp_obj_new_exception_msg_varg try to allocate all memory first using functions that don't raise exceptions If any of the memory allocations fail (return NULL) then degrade gracefully by trying other options for memory allocation, eg using the emergency exception buffer. 3. Use a custom printer backend to conservatively format strings: if it can't allocate memory then it just truncates the string. As part of this rewrite, raising an exception without a message, like KeyError(123), will now use the emergency buffer to store the arg and traceback data if there is no heap memory available. Memory use with this patch is unchanged. Code size is increased by: bare-arm: +136 minimal x86: +124 unix x64: +72 unix nanbox: +96 stm32: +88 esp8266: +92 cc3200: +80
2017-09-20stm32/usbdev: Change static function variable to non-static.Damien George
It's written straight away in the function on every call so it doesn't need to be static.
2017-09-20stm32/usbdev: Make the USBD callback struct const so it can go in ROM.Damien George
2017-09-19py/objstr: strip: Don't strip "\0" by default.Paul Sokolovsky
An issue was due to incorrectly taking size of default strip characters set.
2017-09-18py/mpconfig.h: Add note that using computed gotos in VM is not C99.Damien George
2017-09-18py/{objfloat,objcomplex}: Optimise MP_UNARY_OP_ABS by reusing variables.Damien George
2017-09-18py/modbuiltins: Implement abs() by dispatching to MP_UNARY_OP_ABS.Paul Sokolovsky
This allows user classes to implement __abs__ special method, and saves code size (104 bytes for x86_64), even though during refactor, an issue was fixed and few optimizations were made: * abs() of minimum (negative) small int value is calculated properly. * objint_longlong and objint_mpz avoid allocating new object is the argument is already non-negative.
2017-09-17docs/btree: Describe page caching policy of the underlying implementation.Paul Sokolovsky
2017-09-16tests/cpydiff: Add cases for locals() discrepancies.Paul Sokolovsky
MicroPython doesn't maintain local symbolic environment, so any feature depending on it won't work as expected.
2017-09-13py/emitbc: Remove stray semicolon in outer scope.Damien George
2017-09-13py/runtime.h: Change empty mp_warning macro so var-args are non empty.Damien George
Variable arguments in a macro should take at least 1 argument.
2017-09-13stm32/mpconfigport.h: Add configuration for max periphs on L4 series.Damien George
2017-09-13docs/library/framebuf.rst: Generalise constructor to all colour formats.Peter Hinch
2017-09-13stm32/timer: Make pyb.Timer() instances persistent.Damien George
Prior to this patch calling pyb.Timer(id) would always create a new timer instance, even if there was an existing one. This patch fixes this behaviour to match other peripherals, like UART, such that constructing a timer with just the id will retrieve any existing instances. The patch also refactors the way timers are validated on construction to simplify and reduce code size.
2017-09-12py/builtinhelp: Change signature of help text var from pointer to array.Damien George
As a pointer (const char *) it takes up an extra word of storage which is in RAM.
2017-09-12extmod/machine_pinbase: Put PinBase singleton in ROM.Damien George
This patch also removes the empty type "pinbase_type" (which crashes if accessed) and uses "machine_pinbase_type" instead as the type of the PinBase singleton.
2017-09-12py/nlrx86: Fix building for Android/x86.ASM
Tested using Clang on self-hosted Termux environment https://termux.com/.
2017-09-12stm32/make-stmconst.py: Make sure mpz const data lives in ROM.Damien George
2017-09-11README: Update "Dependencies" section.Paul Sokolovsky
Given that various ports now require submodules, rewrite the section to be more generic. Also, add git submodule update command to other sections for easy user start.
2017-09-10tests/run-tests: Fix copy-paste mistake in var name.Paul Sokolovsky
2017-09-10tests/run-tests: Skip class_inplace_op for minimal profile.Paul Sokolovsky
Don't assume that MICROPY_PY_ALL_SPECIAL_METHODS is defined, as required for inplace special methods. Fixes Zephyr tests.
2017-09-10zephyr/Makefile: Revamp "test" target after ports were moved to ports/.Paul Sokolovsky