summaryrefslogtreecommitdiff
path: root/py
AgeCommit message (Collapse)Author
2019-08-19extmod/modure: Make regex dump-code debugging feature optional.Damien George
Enabled via MICROPY_PY_URE_DEBUG, disabled by default (but enabled on unix coverage build). This is a rarely used feature that costs a lot of code (500-800 bytes flash). Debugging of regular expressions can be done offline with other tools.
2019-08-19py/nlr: Use MP_UNREACHABLE at the end of arch-specific nlr_jump funcs.Damien George
Recent versions of gcc perform optimisations which can lead to the following code from the MP_NLR_JUMP_HEAD macro being omitted: top->ret_val = val; \ MP_NLR_RESTORE_PYSTACK(top); \ *_top_ptr = top->prev; \ This is noticeable (at least) in the unix coverage on x86-64 built with gcc 9.1.0. This is because the nlr_jump function is marked as no-return, so gcc deduces that the above code has no effect. Adding MP_UNREACHABLE tells the compiler that the asm code may branch elsewhere, and so it cannot optimise away the code.
2019-08-19py: Introduce MP_UNREACHABLE macro to annotate unreachable code.Damien George
And use it to replace the same pattern at the end of nlrthumb.c:nlr_jump.
2019-08-17py/modmath: Implement math.isclose() for non-complex numbers.stijn
As per PEP 485, this function appeared in for Python 3.5. Configured via MICROPY_PY_MATH_ISCLOSE which is disabled by default, but enabled for the ports which already have MICROPY_PY_MATH_SPECIAL_FUNCTIONS enabled.
2019-08-15py/objarray: Fix amount of free space in array when doing slice assign.Damien George
Prior to this patch the amount of free space in an array (including bytearray) was not being maintained correctly for the case of slice assignment which changed the size of the array. Under certain cases (as encoded in the new test) it was possible that the array could grow beyond its allocated memory block and corrupt the heap. Fixes issue #4127.
2019-08-15py: Implement new sys.atexit feature.Milan Rossa
This patch implements a new sys.atexit function which registers a function that is later executed when the main script ends. It is configurable via MICROPY_PY_SYS_ATEXIT, disabled by default. This is not compliant with CPython, rather it can be used to implement a CPython compatible "atexit" module if desired (similar to how sys.print_exception can be used to implement functionality of the "traceback" module).
2019-08-06py/showbc: Fix off-by-one when showing address of unknown opcode.Milan Rossa
2019-08-06py: Allow to pass in read-only buffers to viper and inline-asm funcs.Damien George
Fixes #4936.
2019-07-31py/modio: Call mp_import_name to do resource stream import.Paul m. p. P
So code is not duplicated and it can take advantage of __import__ being overridden.
2019-07-31py/runtime: Allow to override builtins.__import__ with Python func.Paul m. p. P
This patch adds a simple but powerful hook into the import system, in a CPython compatible way, by allowing to override builtins.__import__. This does introduce some overhead to all imports but it's minor: - the dict lookup of __import__ is bypassed if there are no modifications to the builtins module (which is the case at start up); - imports are not performance critical, usually done just at the start of a script; - compared to how much work is done in an import, looking up a value in a dict is a relatively small additional piece of work.
2019-07-31py/builtinimport: Populate __file__ when importing frozen or mpy files.Paul m. p. P
Note that bytecode already includes the source filename as a qstr so there is no additional memory used by the interning operation here.
2019-07-30py/objdict: Quote non-string types when used as keys in JSON output.Eric Poulsen
JSON requires that keys of objects be strings. CPython will therefore automatically quote simple types (NoneType, bool, int, float) when they are used directly as keys in JSON output. To prevent subtle bugs and emit compliant JSON, MicroPython should at least test for such keys so they aren't silently let through. Then doing the actual quoting is a similar cost to raising an exception, so that's what is implemented by this patch. Fixes issue #4790.
2019-07-25py/sequence: Fix grammar in comment about equality.Yonatan Goldschmidt
2019-07-17py/objstringio: Guard bytesio_stream_p struct w/ MICROPY_PY_IO_BYTESIO.Paul m. p. P
It's static and can lead to a compilation warning/error when MICROPY_PY_IO_BYTESIO is disabled.
2019-07-17py/scheduler: Rename sched_stack to sched_queue.Jim Mussared
Behaviour was changed from stack to queue in 8977c7eb581f5d06500edb1ea29aea5cbda04f28, and this updates variable names to match. Also updates other references (docs, error messages).
2019-07-12py/makeqstrdata.py: Allow using \r\n as a qstr if a port requires it.Paul m. p. P
2019-07-12py/asmarm: Use __builtin___clear_cache instead of __clear_cache.David Lechner
__clear_cache causes a compile error when using clang. Instead use __builtin___clear_cache which is available under both gcc and clang. Also replace tabs with spaces in this section of code (introduced by a previous commit).
2019-07-09py/objgenerator: Add missing #if guard for PY_GENERATOR_PEND_THROW.Laurens Valk
Without it, gen_instance_pend_throw_obj is defined but not used when MICROPY_PY_GENERATOR_PEND_THROW is set to 0.
2019-07-03py/nlrthumb: Check __thumb2__ instead of __ARM_ARCH_6M__.David Lechner
This fixes compiling for older architectures (e.g. armv5tej). According to [1], the limit of R0-R7 for the STR and LDR instructions is tied to the Thumb instruction set and not any specific processor architectures. [1]: http://www.keil.com/support/man/docs/armasm/armasm_dom1361289906890.htm
2019-07-03py/asmarm: Use __clear_cache on Linux/GCC when creating new asm code.David Lechner
Comes from https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/caches-and-self-modifying-code This fixes a crash when running MicroPython using qemu-arm.
2019-07-01py/persistentcode: Ensure prelude_offset is always initialised.Paul m. p. P
2019-07-01lib/utils/sys_stdio_mphal: Add support to poll sys.stdin and sys.stdout.Damien George
A port must provide the following function for this to work: uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags);
2019-06-28py/persistentcode: Fix compilation with load and save both enabled.Jun Wu
With both MICROPY_PERSISTENT_CODE_SAVE and MICROPY_PERSISTENT_CODE_LOAD enabled the code fails to compile, due to undeclared 'n_obj'. If MICROPY_EMIT_NATIVE is disabled there are more errors due to the use of undefined fields in mp_raw_code_t. This patch fixes such compilation by avoiding undefined fields. MICROPY_EMIT_NATIVE was changed to MICROPY_EMIT_MACHINE_CODE in this file to match the mp_raw_code_t definition.
2019-06-28py: Define EMIT_MACHINE_CODE as EMIT_NATIVE || EMIT_INLINE_ASM.Jun Wu
The combination MICROPY_EMIT_NATIVE || MICROPY_EMIT_INLINE_ASM is used in many places, so define a new macro for it.
2019-06-25py/mkrules.mk: Use $(CPP) not $(CC) -E for preprocessor rule.Paul m. p. P
2019-06-19py/nlrthumb: Save and restore VFP registers s16-s21 when CPU has them.Damien George
These s16-s21 registers are used by gcc so need to be saved. Future versions of gcc (beyond v9.1.0), or other compilers, may eventually need additional registers saved/restored. See issue #4844.
2019-06-05extmod: Factor out makefile rules from py.mk to new extmod.mk file.Damien George
To logically separate extmod related rules out, and prevent py.mk from growing too large.
2019-06-05py/obj: Optimise small-int comparison to 0 in mp_obj_is_true.Yonatan Goldschmidt
Instead of converting to a small-int at runtime this can be done at compile time, then we only have a simple comparison during runtime. This reduces code size on some ports (e.g -4 on qemu-arm, -52 on unix nanbox), and for others at least doesn't increase code size.
2019-06-03mpy-cross: Do not automatically build mpy-cross, rather do it manually.Damien George
Building mpy-cross automatically leads to some issues with the build process and slows it down. Instead, require it to be built manually.
2019-05-29py/nativeglue: Remove dependency on mp_fun_table in dyn-compiler mode.Damien George
mpy-cross uses MICROPY_DYNAMIC_COMPILER and MICROPY_EMIT_NATIVE but does not actually need to execute native functions, and does not need mp_fun_table. This commit makes it so mp_fun_table and all its entries are not built when MICROPY_DYNAMIC_COMPILER is enabled, significantly reducing the size of the mpy-cross executable and allowing it to be built on more machines/OS's.
2019-05-29py/nativeglue: Make private glue funs all static, remove commented code.Damien George
2019-05-29all: Bump version to 1.11.v1.11Damien George
2019-05-27py/vm: Remove obsolete comments about matching of exception opcodes.Damien George
These are incorrect since 5a2599d96299ad37cda954f1de345159f9acf11c
2019-05-22py/mkrules.mk: Remove unnecessary ; in makefile.Sebastien Rinsoz
This ; make Windows compilation fail with GNU makefile 4.2.1. It was added in 0dc85c9f86735c35cf14555482b2c8923cf31a6a as part of a shell if- statement, but this if-statement was subsequently removed in 23a693ec2d8c2a194f61482dc0e1adb070fb6ad4 so the semicolon is not needed.
2019-05-22py: Update makefiles to use $(TOUCH) instead of hard coded "touch".Sebastien Rinsoz
The variable $(TOUCH) is initialized with the "touch" value in mkenv.mk like for the other command line tools (rm, echo, cp, mkdir etc). With this, for example, Windows users can specify the path of touch.exe.
2019-05-21py: Update makefiles to use $(CAT) variable instead of hard coded "cat".Sébastien Rinsoz
The variable $(CAT) is initialised with the "cat" value in mkenv.mk like for the other command line tools (rm, echo, cp, mkdir etc). With this, for example, Windows users can specify the path of cat.exe.
2019-05-21py/objarray: Add decode method to bytearray.stijn
Reuse the implementation for bytes since it works the same way regardless of the underlying type. This method gets added for CPython compatibility of bytearray, but to keep the code simple and small array.array now also has a working decode method, which is non-standard but doesn't hurt.
2019-05-17various: Update early copyright years to match actual edit history.Damien George
2019-05-17various: Add and update my copyright line based on git history.Paul Sokolovsky
For modules I initially created or made substantial contributions to.
2019-05-14py/objarray: Add support for memoryview.itemsize attribute.stijn
This allows figuring out the number of bytes in the memoryview object as len(memview) * memview.itemsize. The feature is enabled via MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE and is disabled by default.
2019-05-13py/persistentcode: Change "len" type to size_t for mp_obj_str_get_data.Henrik Vendelbo
2019-05-09py/misc.h: Rename _MP_STRINGIFY to not use leading underscore in ident.Damien George
Macro identifiers with a leading underscore are reserved.
2019-05-09py/objgenerator: Remove unneeded forward decl and clean up white space.Damien George
2019-05-09py/objgenerator: Fix handling of None passed as 2nd arg to throw().Damien George
Fixes issue #4527.
2019-05-07mpy-cross: Add --version command line option to print version info.Damien George
Prints something like: MicroPython v1.10-304-g8031b7a25 on 2019-05-02; mpy-cross emitting mpy v4
2019-05-06py: remove "if (0)" and "if (false)" branches.Jun Wu
Prior to this commit, building the unix port with `DEBUG=1` and `-finstrument-functions` the compilation would fail with an error like "control reaches end of non-void function". This change fixes this by removing the problematic "if (0)" branches. Not all branches affect compilation, but they are all removed for consistency.
2019-05-06extmod/moducryptolib: Add AES-CTR support.Yonatan Goldschmidt
Selectable at compile time via MICROPY_PY_UCRYPTOLIB_CTR. Disabled by default.
2019-05-03py/native: Improve support for bool type in viper functions.Damien George
Variables with type bool now act more like an int, and there is proper casting to/from Python objects.
2019-05-01py/asmthumb: Support asm_thumb code running on normal ARM processors.Damien George
With this change, @micropython.asm_thumb functions will work on standard ARM processors (that are in ARM state by default), in scripts and precompiled .mpy files. Addresses issue #4675.
2019-04-23py/mpprint: Support printing %ld and %lu formats on 64-bit archs.Damien George
Fixes issue #4702.