summaryrefslogtreecommitdiffstatshomepage
path: root/py
Commit message (Collapse)AuthorAge
* py/builtinevex: Add typechecking of globals/locals args to eval/exec.Tom Collins2017-07-21
|
* all: Remove trailing spaces, per coding conventions.Damien George2017-07-19
|
* py/modmicropython: Cast stack_limit value so it prints correctly.Damien George2017-07-18
| | | | Without this cast the print will give a wrong result on nan-boxing builds.
* py/asmx64: Support moving a 64-bit immediate to one of top 8 registers.Damien George2017-07-18
| | | | | | | If constants (eg mp_const_none_obj) are placed in very high memory locations that require 64-bits for the pointer then the assembler must be able to emit instructions to move such pointers to one of the top 8 registers (ie r8-r15).
* py/vm: Make n_state variable local to just set-up part of VM.Damien George2017-07-18
| | | | | | It's not used anywhere else in the VM loop, and clashes with (is shadowed by) the n_state variable that's redeclared towards the end of the mp_execute_bytecode function. Code size is unchanged.
* all: Unify header guard usage.Alexander Steffen2017-07-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code conventions suggest using header guards, but do not define how those should look like and instead point to existing files. However, not all existing files follow the same scheme, sometimes omitting header guards altogether, sometimes using non-standard names, making it easy to accidentally pick a "wrong" example. This commit ensures that all header files of the MicroPython project (that were not simply copied from somewhere else) follow the same pattern, that was already present in the majority of files, especially in the py folder. The rules are as follows. Naming convention: * start with the words MICROPY_INCLUDED * contain the full path to the file * replace special characters with _ In addition, there are no empty lines before #ifndef, between #ifndef and one empty line before #endif. #endif is followed by a comment containing the name of the guard macro. py/grammar.h cannot use header guards by design, since it has to be included multiple times in a single C file. Several other files also do not need header guards as they are only used internally and guaranteed to be included only once: * MICROPY_MPHALPORT_H * mpconfigboard.h * mpconfigport.h * mpthreadport.h * pin_defs_*.h * qstrdefs*.h
* py/gc: Refactor assertions in gc_free function.Damien George2017-07-12
| | | | | gc_free() expects either NULL or a valid pointer into the heap, so the checks for a valid pointer can be turned into assertions.
* py/compile: Fix enum variable declaration.Damien George2017-07-09
|
* py/objgenerator: Allow to hash generators and generator instances.Damien George2017-07-07
| | | | | Adds nothing to the code size, since it uses existing empty slots in the type structures.
* py,extmod: Some casts and minor refactors to quiet compiler warnings.Tom Collins2017-07-07
|
* py/compile: Use switch-case to match token and operator.Krzysztof Blazewicz2017-07-05
| | | | Reduces code size.
* py/compile: Combine arith and bit-shift ops into 1 compile routine.Krzysztof Blazewicz2017-07-05
| | | | This refactoring saves code space.
* py/repl: Change mp_uint_t to size_t in repl helpers.Damien George2017-07-04
|
* py: Change mp_uint_t to size_t in builtins code.Damien George2017-07-04
|
* py/objdict: Factorise dict accessor helper to reduce code size.Damien George2017-07-04
| | | | | | | | | | | | Code size change in bytes for this patch is: bare-arm: -72 minimal x86: -48 unix x64: -32 unix nanbox: -120 stmhal: -68 cc3200: -64 esp8266: -56
* py/makeversionhdr.py: Update to parse new release line in docs/conf.py.Damien George2017-07-04
| | | | | The line in docs/conf.py with the release/version number was recently changed and this patch makes the makeversionhdr.py script work again.
* py/modmath: Check for zero division in log with 2 args.Damien George2017-07-04
|
* py/vm: Make "if" control flow more obvious in YIELD_FROM opcode.Damien George2017-07-04
|
* py/objstr: Remove unnecessary "sign" variable in formatting code.Damien George2017-07-04
|
* py/runtime: Mark m_malloc_fail() as NORETURN.Damien George2017-07-04
|
* py/binary: Add missing "break" statements.Damien George2017-07-04
|
* py/objstr: Move uPy function wrappers to just after the C function.Damien George2017-07-02
| | | | This matches the coding/layout style of all the other objects.
* py/mpprint: Remove unreachable check for neg return of mp_format_float.Damien George2017-06-30
|
* py/objnamedtuple: Simplify and remove use of alloca building namedtuple.Damien George2017-06-29
| | | | | | | | | | | | | | | | Prior to this patch there were 2 paths for creating the namedtuple, one for when no keyword args were passed, and one when there were keyword args. And alloca was used in the keyword-arg path to temporarily create the array of elements for the namedtuple, which would then be copied to a heap-allocated object (the namedtuple itself). This patch simplifies the code by combining the no-keyword and keyword paths, and removing the need for the alloca by constructing the namedtuple on the heap before populating it. Heap usage in unchanged, stack usage is reduced, use of alloca is removed, and code size is not increased and is actually reduced by between 20-30 bytes for most ports.
* py/builtinimport: Remove unreachable code for relative imports.Damien George2017-06-28
| | | | | | | | | | | | The while-loop that calls chop_component will guarantee that level==-1 at the end of the loop. Hence the code following it is unnecessary. The check for p==this_name will catch imports that are beyond the top-level, and also covers the case of new_mod_q==MP_QSTR_ (equivalent to new_mod_l==0) so that check is removed. There is also a new check at the start for level>=0 to guard against __import__ being called with bad level values.
* py/frozenmod.h: Add missing header guardsAlexander Steffen2017-06-28
|
* py/mpconfig.h: Remove spaces in "Micro Python" and remove blank line.Damien George2017-06-26
|
* py/compile: Optimise emitter label indices to save a word of heap.Damien George2017-06-22
| | | | | | | Previous to this patch, a label with value "0" was used to indicate an invalid label, but that meant a wasted word (at slot 0) in the array of label offsets. This patch adjusts the label indices so the first one starts at 0, and the maximum value indicates an invalid label.
* py/compile: Fix bug with break/continue in else of optimised for-range.Damien George2017-06-22
| | | | | | | | | | | | | | | | | This patch fixes a bug whereby the Python stack was not correctly reset if there was a break/continue statement in the else black of an optimised for-range loop. For example, in the following code the "j" variable from the inner for loop was not being popped off the Python stack: for i in range(4): for j in range(4): pass else: continue This is now fixed with this patch.
* py/objint: In to_bytes(), allow length arg to be any int and check sign.Damien George2017-06-15
|
* py/objint: Support "big" byte-order in int.to_bytes().Damien George2017-06-15
|
* all: Make more use of mp_raise_{msg,TypeError,ValueError} helpers.Damien George2017-06-15
|
* py/compile: Raise SyntaxError if positional args are given after */**.Damien George2017-06-14
| | | | | | | | In CPython 3.4 this raises a SyntaxError. In CPython 3.5+ having a positional after * is allowed but uPy has the wrong semantics and passes the arguments in the incorrect order. To prevent incorrect use of a function going unnoticed it is important to raise the SyntaxError in uPy, until the behaviour is fixed to follow CPython 3.5+.
* py/modthread: Raise RuntimeError in release() if lock is not acquired.Damien George2017-06-14
|
* py/formatfloat: Fix number of digits and exponent sign when rounding.Damien George2017-06-13
| | | | | | | This patch fixes 2 things when printing a floating-point number that requires rounding up of the mantissa: - retain the correct precision; eg 0.99 becomes 1.0, not 1.00 - if the exponent goes from -1 to 0 then render it as +0, not -0
* py/objstringio: If created from immutable object, follow copy on write policy.Paul Sokolovsky2017-06-09
| | | | | Don't create copy of immutable object's contents until .write() is called on BytesIO.
* py/makeqstrdefs.py: Make script run correctly with Python 2.6.Damien George2017-06-09
|
* py: Provide mp_decode_uint_skip() to help reduce stack usage.Damien George2017-06-09
| | | | | | | | | Taking the address of a local variable leads to increased stack usage, so the mp_decode_uint_skip() function is added to reduce the need for taking addresses. The changes in this patch reduce stack usage of a Python call by 8 bytes on ARM Thumb, by 16 bytes on non-windowing Xtensa archs, and by 16 bytes on x86-64. Code size is also slightly reduced on most archs by around 32 bytes.
* py/modsys: Allow to compile with obj-repr D and PY_ATTRTUPLE disabled.Damien George2017-06-08
|
* py/objstr: Allow to compile with obj-repr D, and unicode disabled.Damien George2017-06-08
|
* py/persistentcode: Allow to compile with complex numbers disabled.Damien George2017-06-08
|
* extmod/modlwip: Fix error codes for duplicate calls to connect().Paul Sokolovsky2017-06-04
| | | | | | | | If socket is already connected, POSIX requires returning EISCONN. If connection was requested, but not yet complete (for non-blocking socket), error code is EALREADY. http://pubs.opengroup.org/onlinepubs/7908799/xns/connect.html
* py/objstr: Catch case of negative "maxsplit" arg to str.rsplit().Damien George2017-06-02
| | | | | Negative values mean no limit on the number of splits so should delegate to the .split() method.
* py/modbuiltins: Add core-provided version of input() function.Damien George2017-06-01
| | | | | | | The implementation is taken from stmhal/input.c, with code added to handle ctrl-C. This built-in is controlled by MICROPY_PY_BUILTINS_INPUT and is disabled by default. It uses readline() to capture input but this can be overridden by defining the mp_hal_readline macro.
* various: Spelling fixesVille Skyttä2017-05-29
|
* py/objstringio: Catch mp_uint_t overflow of stream position in write().Tom Collins2017-05-26
|
* py/mkrules.mk: Fix auto-qstr generation when "make -B" is used.Damien George2017-05-26
| | | | | | | | | | | | For make v3.81, using "make -B" can set $? to empty and in this case the auto-qstr generation needs to pass all args (ie $^) to cpp. The previous fix for this (which was removed in 23a693ec2d8c2a194f61482dc0e1adb070fb6ad4) used if statements in the shell command, which gave very long lines that didn't work on certain systems (eg cygwin). The fix in this patch is to use an $if(...) expression, which will evaluate to $? (only newer prerequisites) if it's non empty, otherwise it will use $^ (all prerequisites).
* py/emitbc: Fix bug with BC emitter computing Python stack size.Damien George2017-05-25
| | | | | | | | | | | Previous to this patch the mp_emit_bc_adjust_stack_size function would adjust the current stack size but would not increase the maximum stack size if the current size went above it. This meant that certain Python code (eg a try-finally block with no statements inside it) would not have enough Python stack allocated to it. This patch fixes the problem by always checking if the current stack size goes above the maximum, and adjusting the latter if it does.
* py/vm: Fix bug with unwind jump popping the iterator from a for loop.Damien George2017-05-25
| | | | | This patch fixes a regression introduced by 088740ecc40476fd0796a3ef6a68ee7c677eae64
* py/vm: Fix bug with stackless mode and unwinding of exceptions.Damien George2017-05-25
| | | | | | | | | This patch fixes a regression introduced by 71a3d6ec3bd02c5bd13334537e1bd146bb643bad Previous to this patch the n_state variable was referring to that computed at the very start of the mp_execute_bytecode function. This patch fixes it so that n_state is recomputed when the code_state changes.