summaryrefslogtreecommitdiffstatshomepage
path: root/py
Commit message (Collapse)AuthorAge
* 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.
* py/mkenv.mk: Use $(TOP) instead of ".." to reference tools, mpy-cross.Damien George2017-05-19
|
* py/objrange: Fix slicing of range when step of slice is negative.Damien George2017-05-18
|
* py/sequence: Fix boundary errors when slicing with a negative step.Damien George2017-05-18
|
* py/objstringio: Fix StringIO reads at or beyond EOF.Tom Collins2017-05-15
| | | | Existing code failed if seek() went past EOF (which is acceptable when writing).
* py/modsys: update conditionals for code referencing sys.stdoutTom Collins2017-05-14
| | | | Working on a build with PY_IO enabled (for PY_UJSON support) but PY_SYS_STDFILES disabled (no filesystem). There are multiple references to mp_sys_stdout_obj that should only be enabled if both PY_IO and PY_SYS_STDFILES are enabled.
* py/lexer: Process CR earlier to allow newlines checks on chr1.Tom Collins2017-05-12
| | | | | Resolves an issue where lexer failed to accept CR after line continuation character. It also simplifies the code.
* py/mkrules.mk: Add dependency of .mpy files upon mpy-cross.Damien George2017-05-11
| | | | | | This ensures that mpy-cross is automatically built (and is up-to-date) for ports that use frozen bytecode. It also makes sure that .mpy files are re-built if mpy-cross is changed.
* unix/main: Implement -m option for packages.Paul Sokolovsky2017-05-09
|
* py/lexer: Simplify lexer startup by using dummy bytes and next_char().Tom Collins2017-05-09
| | | | | | | Now consistently uses the EOL processing ("\r" and "\r\n" convert to "\n") and EOF processing (ensure "\n" before EOF) provided by next_char(). In particular the lexer can now correctly handle input that starts with CR.
* py/binary: Handle storing big-ints to all arrays types.Damien George2017-05-09
| | | | | | | Prior to this patch only 'q' and 'Q' type arrays could store big-int values. With this patch any big int that is stored to an array is handled by the big-int implementation, regardless of the typecode of the array. This allows arrays to work with all type sizes on all architectures.
* py/modio: resource_stream: Implement "package" param handling.Paul Sokolovsky2017-05-06
|
* py/objint: In int.from_bytes, only create big-int if really needed.Damien George2017-05-06
| | | | | This patch ensures that int.from_bytes only creates a big-int if necessary, by checking the value for a small-int overflow as it's being parsed.
* py/modio: Implement uio.resource_stream(package, resource_path).Paul Sokolovsky2017-05-03
| | | | | | | | | | | | | | The with semantics of this function is close to pkg_resources.resource_stream() function from setuptools, which is the canonical way to access non-source files belonging to a package (resources), regardless of what medium the package uses (e.g. individual source files vs zip archive). In the case of MicroPython, this function allows to access resources which are frozen into the executable, besides accessing resources in the file system. This is initial stage of the implementation, which actually doesn't implement "package" part of the semantics, just accesses frozen resources from "root", or filesystem resource - from current dir.
* py: Cleanup use of global DEBUG preprocessor definitionstijn2017-04-30
| | | | | | | | | The standard preprocessor definition to differentiate debug and non-debug builds is NDEBUG, not DEBUG, so don't rely on the latter: - just delete the use of it in objint_longlong.c as it has been stale code for years anyway (since commit [c4029e5]): SUFFIX isn't used anywhere. - replace DEBUG with MICROPY_DEBUG_NLR in nlr.h: it is rarely used anymore so can be off by default