Commit Graph

916 Commits

Author SHA1 Message Date
Paul Sokolovsky
5bf6eba845 tests/open_plus: Add tests for "r+", "w+" open modes. 2016-02-06 21:59:54 +02:00
Doug Currie
2e2e15cec2 py/mpz: Complete implementation of mpz_{and,or,xor} for negative args.
For these 3 bitwise operations there are now fast functions for
positive-only arguments, and general functions for arbitrary sign
arguments (the fast functions are the existing implementation).

By default the fast functions are not used (to save space) and instead
the general functions are used for all operations.

Enable MICROPY_OPT_MPZ_BITWISE to use the fast functions for positive
arguments.
2016-02-03 22:13:39 +00:00
pohmelie
e3a29de1dc py/objstr: For str.format, add nested/computed fields support.
Eg: '{:{}}'.format(123, '>20')

@pohmelie was the original author of this patch, but @dpgeorge made
significant changes to reduce code size and improve efficiency.
2016-02-02 16:25:24 +00:00
Damien George
93bb7dffd2 py/vm: Fix popping of exception block in UNWIND_JUMP opcode.
Fixes issue #1812.
2016-02-01 16:07:21 +00:00
Damien George
9e677114e4 py/mpprint: Fix sign extension when printf'ing %u, %x and %X. 2016-02-01 15:08:42 +00:00
Damien George
ef5f2669dc tests: For pyboard, add test for I2C error handling and recovery. 2016-01-30 00:06:04 +00:00
Damien George
3cfb15cf4d tests: Update pyboard LED test. 2016-01-29 23:12:59 +00:00
Damien George
8f54c08691 py/inlineasm: Add ability to specify return type of asm_thumb funcs.
Supported return types are: object, bool, int, uint.

For example:

@micropython.asm_thumb
def foo(r0, r1) -> uint:
    add(r0, r0, r1)
2016-01-27 14:27:10 +00:00
Damien George
ac11e89fa3 tests: For urandom test, use sys.exit() instead of sys.exit(1). 2016-01-26 21:57:02 +00:00
Damien George
0ae97f531d tests: Add some tests for urandom module. 2016-01-26 15:27:00 +00:00
Dave Hylands
a17755ee8b py: Add ustruct.pack_into and unpack_from 2016-01-19 12:25:28 +00:00
chrysn
f8ba2eca80 builtin property: accept keyword arguments
this allows python code to use property(lambda:..., doc=...) idiom.

named versions for the fget, fset and fdel arguments are left out in the
interest of saving space; they are rarely used and easy to enable when
actually needed.

a test case is included.
2016-01-14 21:15:18 +02:00
stijn
dea585f8ae tests: Remove builtin_dict test
This is essentially a duplicate of obj_dict.py
2016-01-14 21:10:59 +02:00
Dave Hylands
66d0c1052a extmod: Fix uctypes size calculation for bitfields 2016-01-10 23:31:26 +02:00
Damien George
3b936a5f4c tests: Fix math_fun_special test so it passes with single prec float. 2016-01-08 17:58:02 +00:00
Damien George
b1fa907d56 tests: Allow float tests to run when MATH_SPECIAL_FUNCTIONS is disabled. 2016-01-08 14:27:21 +00:00
Damien George
ea8be373a9 py/inlinethumb: Remove 30-bit restriction on movwt instruction.
movwt can now move a full 32-bit constant into a register.
2016-01-07 16:34:11 +00:00
Damien George
22b2265053 py/parse: Improve constant folding to operate on small and big ints.
Constant folding in the parser can now operate on big ints, whatever
their representation.  This is now possible because the parser can create
parse nodes holding arbitrary objects.  For the case of small ints the
folding is still efficient in RAM because the folded small int is stored
inplace in the parse node.

Adds 48 bytes to code size on Thumb2 architecture.  Helps reduce heap
usage because more constants can be computed at compile time, leading to
a smaller parse tree, and most importantly means that the constants don't
have to be computed at runtime (perhaps more than once).  Parser will now
be a little slower when folding due to calls to runtime to do the
arithmetic.
2016-01-07 14:40:35 +00:00
Damien George
d4df8f4925 py/objstr: In str.format, handle case of no format spec for string arg.
Handles, eg, "{:>20}".format("foo"), where there is no explicit spec for
the type of the argument.
2016-01-04 13:13:39 +00:00
Paul Sokolovsky
ee7b8f32e3 tests/object_dict.py: Add test for obj.__dict__ . 2016-01-03 20:51:36 +02:00
stijn
3c014a67ea py: Implement __dict__ for instances.
Note that even though wrapped in MICROPY_CPYTHON_COMPAT, it is not
fully compatible because the modifications to the dictionary do not
propagate to the actual instance members.
2016-01-03 20:51:26 +02:00
Dave Hylands
7281d95aee py: Make dir report instance members 2016-01-03 20:37:18 +02:00
Antonin ENFRUN
b50030b1d0 tests/uctypes: Test item assignment for scalar arrays. 2016-01-03 20:32:51 +02:00
Damien George
e5ce5e2a43 tests: Skip class_bind_self.py for native emitter. 2015-12-26 13:06:50 +00:00
Damien George
78913211a9 py: Be more restrictive binding self when looking up instance attrs.
When looking up and extracting an attribute of an instance, some
attributes must bind self as the first argument to make a working method
call.  Previously to this patch, any attribute that was callable had self
bound as the first argument.  But Python specs require the check to be
more restrictive, and only functions, closures and generators should have
self bound as the first argument

Addresses issue #1675.
2015-12-26 12:41:31 +00:00
Damien George
7ce8860b6b tests: Skip try-finally test for native emitter. 2015-12-24 12:49:31 +00:00
Damien George
8047340d75 py: Handle case of return within the finally block of try-finally.
Addresses issue #1636.
2015-12-24 12:47:39 +00:00
Damien George
117158fcd5 tests: Add tests for stream IO errors. 2015-12-23 22:37:02 +00:00
Paul Sokolovsky
664bc44f30 tests: Add tests for %-formatting of bytes.
This requires CPython3.5, to not require switching to it, just use .exp
file.
2015-12-20 16:54:34 +02:00
Michael Buesch
17298af61e py/modmath: Add domain error checking to sqrt, log, log2, log10.
These functions will raise 'ValueError: math domain error' on invalid
input.
2015-12-12 15:12:54 +00:00
Damien George
29e9db0c58 py: Fix compiler to handle lambdas used as default arguments.
Addresses issue #1709.
2015-12-12 13:42:51 +00:00
Paul Sokolovsky
a6eff059b9 unix: Rename "_os" module to "uos" for consistency with baremetal ports. 2015-12-12 00:04:35 +02:00
Damien George
de2a2e296b tests: Add test for "not" of a user defined class. 2015-12-10 22:21:57 +00:00
Henrik Sölver
e242b1785f py/emitinlinethumb: Add support for MRS instruction.
Only IPSR and BASEPRI special registers supported at the moment, but easy
to extend in the future.
2015-12-10 17:32:54 +00:00
Dave Hylands
5a4a2b1db3 extmod: Add test which demonstrates LITTLE_ENDIAN packing failure 2015-12-09 21:43:28 +02:00
Damien George
3ff259a262 py: Fix calling of parent classmethod from instance of subclass.
Addresses issue #1697.
2015-12-09 17:30:01 +00:00
Damien George
0891cf7d2d tests: Disable for_range.py test for native emitter (it requires yield). 2015-12-08 21:39:21 +00:00
Damien George
33ac0fd09f py: Don't try to optimise for+range when args are not simple expressions.
Addresses issue #1693.
2015-12-08 21:05:14 +00:00
Paul Sokolovsky
55995869e5 tests/builtin_minmax: Make compatible with @native codegen. 2015-12-07 19:32:48 +02:00
Paul Sokolovsky
36c6d2fa7d tests/builtin_minmax: Add testcase for lazy iterable (generator). 2015-12-07 18:59:18 +02:00
pohmelie
e23d5a64cf tests: Add min/max "default" agrument test 2015-12-07 18:56:25 +02:00
Paul Sokolovsky
cbc489dff5 tests: Actuall add feature check for complex type being available. 2015-12-06 15:13:26 +02:00
Paul Sokolovsky
eed2f36ae2 tests/run-tests: Allow to skip complex tests if it's not compiled in. 2015-12-06 14:57:31 +02:00
Paul Sokolovsky
54a1d9ecb7 tests/extra_coverage: Update for sys.modules addition. 2015-12-05 00:13:29 +02:00
Damien George
7a99639cff py: Fix function calls that have positional and a star-arg-with-iterator.
Addresses issue #1678.
2015-12-03 17:59:49 +00:00
Damien George
0d9b450701 stmhal: Make uart.write() function correctly for timeout=0.
In non-blocking mode (timeout=0), uart.write() can now transmit all of its
data without raising an exception.  uart.read() also works correctly in
this mode.

As part of this patch, timout_char now has a minimum value which is long
enough to transfer 1 character.

Addresses issue #1533.
2015-11-30 17:29:52 +00:00
Ryan Shaw
f99491cbf7 stmhal: uart.any() function now returns number of bytes available. 2015-11-30 13:07:20 +00:00
Paul Sokolovsky
ff8c4188f4 tests/run-tests: Improve robustness of REPL tests.
Unconditionally wait for MicroPython banner. On overloaded systems, when
using emulators, etc. initial executable startup may take more than 20ms.
2015-11-24 19:52:30 +02:00
Damien George
9a56912ad1 py/compile: Do proper checking of * and ** in function definition.
This patch checks that there is only one *, and that ** is last in the
arg list.
2015-11-23 16:50:42 +00:00
Damien George
0e3f29cc99 py: Check that second argument to hasattr is actually a string.
Fixes issue #1623.
2015-11-23 15:57:00 +00:00