summaryrefslogtreecommitdiffstatshomepage
path: root/py
Commit message (Collapse)AuthorAge
* py: Cast argument for printf to int, to be compatible with more ports.Damien George2015-06-22
| | | | This allows stmhal to be compiled with MICROPY_DEBUG_PRINTERS.
* py: Use a wrapper to explicitly check self argument of builtin methods.Damien George2015-06-20
| | | | | | | | | | | | | | | Previous to this patch a call such as list.append(1, 2) would lead to a seg fault. This is because list.append is a builtin method and the first argument to such methods is always assumed to have the correct type. Now, when a builtin method is extracted like this it is wrapped in a checker object which checks the the type of the first argument before calling the builtin function. This feature is contrelled by MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG and is enabled by default. See issue #1216.
* py: Make showbc decode UNPACK_EX, and use correct range for unop/binop.Damien George2015-06-18
|
* py: Implement divmod for mpz bignum.Damien George2015-06-13
|
* py: Add MP_BINARY_OP_DIVMOD to simplify and consolidate divmod builtin.Damien George2015-06-13
|
* py: Implement second arg for math.log (optional value for base).Damien George2015-06-13
|
* py: Rebuild port if mpconfigport.mk changed (if any).Paul Sokolovsky2015-06-11
| | | | | | | | mpconfigport.mk contains configuration options which affect the way MicroPython is linked. In this regard, it's "stronger" configuration dependency than even mpconfigport.h, so if we rebuild everything on mpconfigport.h change, we certianly should of that on mpconfigport.mk change too.
* py: Support unicode (utf-8 encoded) identifiers in Python source.Damien George2015-06-09
| | | | Enabled simply by making the identifier lexing code 8-bit clean.
* py: Fallback to stack alloca for Python-stack if heap alloc fails.Damien George2015-06-08
| | | | | | If heap allocation for the Python-stack of a function fails then we may as well allocate the Python-stack on the C stack. This will allow to run more code without using the heap.
* unix: Make micropython -m <module> work for frozen modules.Paul Sokolovsky2015-06-06
| | | | | This requires some special handling, which was previosuly applied only to the main code path.
* py: Expose KeyboardInterrupt in builtins module.Damien George2015-06-05
|
* unix: Allow to cat a script into stdin from the command line.Damien George2015-06-04
| | | | See issue #1306.
* py: Implement native multiply operation in viper emitter.Damien George2015-06-04
|
* py: Implement implicit cast to obj for viper load/store index/value.Damien George2015-06-04
| | | | | | | This allows to do "ar[i]" and "ar[i] = val" in viper when ar is a Python object and i and/or val are native viper types (eg ints). Patch also includes tests for this feature.
* py: Add stack check to mp_iternext, since it can be called recursively.Damien George2015-06-03
| | | | | | Eg, builtin map can map over a map, etc, and call iternext deeply. Addresses issue #1294.
* frozenmod: Include header with function prototypes.Paul Sokolovsky2015-05-31
|
* py: Wrap qstr defs in quotes to protect from C preprocessor.Damien George2015-05-30
| | | | | | | | | This patch converts Q(abc) to "Q(abc)" to protect the abc from the C preprocessor, then converts back after the preprocessor is finished. So now we can safely put includes in mpconfig(port).h, and also preprocess qstrdefsport.h (latter is now done also in this patch). Addresses issue #1252.
* py/parsenum.c: Rename "raise" func to "raise_exc" to avoid name clash.Damien George2015-05-30
| | | | "raise" is a common word that was found to exist in a vendor's stdlib.
* py: Add further autodetection of endianess in mpconfig.h.Damien George2015-05-30
| | | | This patch was needed for gcc 4.4.
* py: Get makeqstrdata.py and makeversionhdr.py running under Python 2.6.Damien George2015-05-30
| | | | | These scripts should run under as wide a range of Python versions as possible.
* py: Remove unnecessary extra handling of padding of nan/inf.Damien George2015-05-28
| | | | | | | C's printf will pad nan/inf differently to CPython. Our implementation originally conformed to C, now it conforms to CPython's way. Tests for this are also added in this patch.
* py: Reduce size of mp_printf by eliminating unnecessary code.Damien George2015-05-28
| | | | Saves around 120 bytes on Thumb2 archs.
* py: Make makeversionhdr.py extract version from docs/conf.py if no git.Damien George2015-05-25
| | | | Addresses issue #1285.
* stmhal: Implement sys.std{in,out,err}.buffer, for raw byte mode.Damien George2015-05-24
| | | | It's configurable and only enabled for stmhal port.
* py: Remove hexdigest QSTR since the method has been removed as well.Daniel Campora2015-05-21
|
* py: Minor improvement to unichar_isxdigitDave Hylands2015-05-20
| | | | | | This drops the size of unicode_isxdigit from 0x1e + 0x02 filler to 0x14 bytes (so net code reduction of 12 bytes) and will make unicode_is_xdigit perform slightly faster.
* extmod: Add ubinascii.unhexlifyDave Hylands2015-05-20
| | | | This also pulls out hex_digit from py/lexer.c and makes unichar_hex_digit
* py: Implement mp_format_float for doubles and use where appropriatestijn2015-05-17
| | | | | | | This allows using (almost) the same code for printing floats everywhere, removes the dependency on sprintf and uses just snprintf and applies an msvc-specific fix for snprintf in a single place so nan/inf are now printed correctly.
* py/binary: Make return type of mp_binary_get_size size_t instead of int.Kaspar Schleiser2015-05-17
| | | | Fixes sign-compare warning.
* py/objobject: Don't make locals_dict if there's nothing to go in it.Kaspar Schleiser2015-05-17
|
* py: Change _mp_obj_fun_builtin_t.fun to function pointer.Kaspar Schleiser2015-05-17
| | | | | ISO C forbids conversion between function pointers and void*, gcc -pedantic triggers a warning.
* py: Clean up declarations of str type/funcs that are also in unicode.Damien George2015-05-17
| | | | | Background: trying to make an amalgamation of all the code gave some errors with redefined types and inconsistent use of static.
* py: Fix printing of complex number when imaginary part is nanstijn2015-05-13
|
* py: Add mp_obj_get_int_truncated and use it where appropriate.Damien George2015-05-12
| | | | | | mp_obj_get_int_truncated will raise a TypeError if the argument is not an integral type. Use mp_obj_int_get_truncated only when you know the argument is a small or big int.
* py: Convert hash API to use MP_UNARY_OP_HASH instead of ad-hoc function.Damien George2015-05-12
| | | | | | | | | | | | | | Hashing is now done using mp_unary_op function with MP_UNARY_OP_HASH as the operator argument. Hashing for int, str and bytes still go via fast-path in mp_unary_op since they are the most common objects which need to be hashed. This lead to quite a bit of code cleanup, and should be more efficient if anything. It saves 176 bytes code space on Thumb2, and 360 bytes on x86. The only loss is that the error message "unhashable type" is now the more generic "unsupported type for __hash__".
* vm: Properly handle StopIteration raised in user instance iterator.Paul Sokolovsky2015-05-11
| | | | I.e. in bytecode Python functions.
* objgenerator: Can optimize StopIteration to STOP_ITERATION only if arg is None.Paul Sokolovsky2015-05-11
| | | | | | Unfortunately, MP_OBJ_STOP_ITERATION doesn't have means to pass an associated value, so we can't optimize StopIteration exception with (non-None) argument to MP_OBJ_STOP_ITERATION.
* objgenerator: If generator yielded STOP_ITERATION value, it's stopped.Paul Sokolovsky2015-05-11
| | | | | MP_OBJ_STOP_ITERATION is equivalent of raising StopIteration, except mp_vm_return_kind_t for it is "yield".
* vm: Null pointer test when checking for StopIteration optimizations.Paul Sokolovsky2015-05-10
| | | | | | | When generator raises exception, it is automatically terminated (by setting its code_state.ip to 0), which interferes with this check. Triggered in particular by CPython's test_pep380.py.
* runtime: Add TODO for mp_resume() on handling .close().Paul Sokolovsky2015-05-10
| | | | | | | | | | Exceptions in .close() should be ignored (dumped to sys.stderr, not propagated), but in uPy, they are propagated. Fix would require nlr-wrapping .close() call, which is expensive. Bu on the other hand, .close() is not called often, so maybe that's not too bad (depends, if it's finally called and that causes stack overflow, there's nothing good in that). And yet on another hand, .close() can be implemented to catch exceptions on its side, and that should be the right choice.
* py: iternext() may not return MP_OBJ_NULL, only MP_OBJ_STOP_ITERATION.Paul Sokolovsky2015-05-10
| | | | | Testing for incorrect value led to premature termination of generator containing yield from for such iterator (e.g. "yield from [1, 2]").
* emitnative: Revamp ARM codegen compile after full-arg support refactors.Paul Sokolovsky2015-05-08
| | | | | | The code was apparently broken after 9988618e0e0f5c319e31b135d993e22efb593093 "py: Implement full func arg passing for native emitter.". This attempts to propagate those changes to ARM emitter.
* unix-cpy: Fix adjustment of stack size when leaving exception handler.Damien George2015-05-06
| | | | Also remove __debug__ from one of the bytecode tests.
* py: Fix naming of function arguments when function is a closure.Damien George2015-05-06
| | | | Addresses issue #1226.
* mkrules.mk: Add comment why dependency parsing regex was tweaked.Paul Sokolovsky2015-05-06
| | | | (Windows compatibility.)
* Adjust sed regex that processes dependency file from compilerAri Suutari2015-05-06
| | | | | so that resulting file is correct also on windows systems (ie. with file names containing drive letter).
* py: Remove LOAD_CONST_ELLIPSIS bytecode, use LOAD_CONST_OBJ instead.Damien George2015-05-05
| | | | | Ellipsis constant is rarely used so no point having an extra bytecode for it.
* obj: Handle user instance hash based on Python adhoc rules.Paul Sokolovsky2015-05-05
| | | | | | User instances are hashable by default (using __hash__ inherited from "object"). But if __eq__ is defined and __hash__ not defined in particular class, instance is not hashable.
* objsingleton: New home for Ellipsis and NotImplemented.Paul Sokolovsky2015-05-05
| | | | | | | Having NotImplemented as MP_OBJ_SENTINEL turned out to be problematic (it needs to be checked for in a lot of places, otherwise it'll crash as would pass MP_OBJ_IS_OBJ()), so made a proper singleton value like Ellipsis, both of them sharing the same type.
* modbuiltins: Add NotImplemented builtin constant.Paul Sokolovsky2015-05-04
| | | | | | | | | | | | From https://docs.python.org/3/library/constants.html#NotImplemented : "Special value which should be returned by the binary special methods (e.g. __eq__(), __lt__(), __add__(), __rsub__(), etc.) to indicate that the operation is not implemented with respect to the other type; may be returned by the in-place binary special methods (e.g. __imul__(), __iand__(), etc.) for the same purpose. Its truth value is true." Some people however appear to abuse it to mean "no value" when None is a legitimate value (don't do that).