Commit Graph

723 Commits

Author SHA1 Message Date
Damien George
a5190a7dac py: Fix typing of viper locals; allow default types in annotation. 2014-08-15 22:39:08 +01:00
Damien George
2ac4af6946 py: Allow viper to have type annotations.
Viper functions can now be annotated with the type of their arguments
and return value.  Eg:

@micropython.viper
def f(x:int) -> int:
    return x + 1
2014-08-15 16:45:41 +01:00
Damien George
9b7a8ee8f1 py: Fix mult by negative number of tuple, list, str, bytes.
Multiplication of a tuple, list, str or bytes now yields an empty
sequence (instead of crashing).  Addresses issue #799

Also added ability to mult bytes on LHS by integer.
2014-08-13 13:22:24 +01:00
Damien George
1ddd844815 extmod: Finish rename of zlib to zlibd; enable zlibd on stmhal. 2014-08-12 23:23:53 +01:00
Paul Sokolovsky
5073d3da07 tests: Add test for zlibd module. 2014-08-13 00:26:26 +03:00
Damien George
bb91f1195a py: Improve range: add len, subscr, proper print.
Can now index ranges with integers and slices, and reverse ranges
(although reversing is not very efficient).

Not sure how useful this stuff is, but gets us closer to having all of
Python's builtins.
2014-08-12 19:41:18 +01:00
Damien George
4c03b3a899 py: Implement builtin reversed() function.
reversed function now implemented, and works for tuple, list, str, bytes
and user objects with __len__ and __getitem__.

Renamed mp_builtin_len to mp_obj_len to make it publically available (eg
for reversed).
2014-08-12 18:33:40 +01:00
Paul Sokolovsky
9749b2fb0d objstr: Make sure that bytes are indexed as bytes, not as unicode.
Fixes #795.
2014-08-11 22:38:00 +03:00
Paul Sokolovsky
5f930337bc objarray: Implement equality testing between arrays and other buffers. 2014-08-10 16:22:57 +03:00
Damien George
b92e7533d3 tests, pyb: Update pin test. 2014-08-08 22:38:58 +01:00
Paul Sokolovsky
d0f5e61ab5 py: Implement __file__ attribute for modules. 2014-07-28 21:21:59 +03:00
Paul Sokolovsky
512465bc66 tests: Add testcase for read by length past EOF.
Currently broken for unicode input streams.
2014-07-22 00:11:37 +03:00
Damien George
1694bc733d py: Add stream reading of n unicode chars; unicode support by default.
With unicode enabled, this patch allows reading a fixed number of
characters from text-mode streams; eg file.read(5) will read 5 unicode
chars, which can made of more than 5 bytes.

For an ASCII stream (ie no chars > 127) it only needs to do 1 read.  If
there are lots of non-ASCII chars in a stream, then it needs multiple
reads of the underlying object.

Adds a new test for this case.  Enables unicode support by default on
unix and stmhal ports.
2014-07-19 18:34:04 +01:00
Paul Sokolovsky
a1760a56ff test: Add run-tests-exp.sh, script to run testsuite with only sh dependency.
This script uses expected test results as generated by run-tests --write-exp,
and requires only standard unix shell funtionality (no bash). It is useful
to run testsuite on embedded systems, where there's no CPython and Bash.
2014-07-13 18:49:56 +03:00
Paul Sokolovsky
2cf381081a run-tests: Add option to write CPython's test results to .exp files.
Mostly to run testsuite on targets which doesn't have CPython.
2014-07-12 16:34:51 +03:00
Paul Sokolovsky
2097c8b1e1 moductypes: Add symbolic constants to specify bitfield position/length. 2014-07-11 00:06:36 +03:00
Paul Sokolovsky
8215847b4d moductypes: Foreign data interface module, roughly based on ctype ideas.
But much smaller and memory-efficient. Uses Python builtin data structures
(dict, tuple, int) to describe structure layout.
2014-07-09 19:28:24 +03:00
Damien George
539681fffd tests: Rename test scripts, changing - to _ for consistency.
From now on, all new tests must use underscore.

Addresses issue #727.
2014-07-05 06:14:29 +01:00
Damien George
0182385ab0 py: Automatically ake __new__ a staticmethod.
Addresses issue #622.
2014-07-05 05:55:00 +01:00
Damien George
41736f8201 tests: Write output in byte mode, not text mode.
This enables testing unicode and non-unicode implementations.
2014-06-28 10:29:12 +01:00
Damien George
b3a50f0f3e Merge branch 'master' into unicode
Conflicts:
	py/mpconfig.h
2014-06-28 10:27:15 +01:00
Paul Sokolovsky
8993fb6cf0 py: Add protection against printing too nested or recursive data structures.
With a test which cannot be automatically validated so far.
2014-06-28 02:25:04 +03:00
Paul Sokolovsky
ed07d035d5 tests: Add basic test for unicode file i/o. 2014-06-27 00:04:20 +03:00
Paul Sokolovsky
63143c94ce tests: Test for explicit start/end args to str methods for unicode. 2014-06-27 00:04:20 +03:00
Paul Sokolovsky
b1949e4c09 tests: Add tests for unicode find()/rfind()/index(). 2014-06-27 00:04:19 +03:00
Paul Sokolovsky
17994d1bd3 tests: Add test for unicode string iteration. 2014-06-27 00:04:19 +03:00
Chris Angelico
1e3781bc35 tests: Add unicode test. 2014-06-27 00:04:17 +03:00
Paul Sokolovsky
16ac4962ae tests: Add test for catching infinite function recursion.
Put into misc/ to not complicate life for builds with check disabled.
2014-06-27 00:03:56 +03:00
Paul Sokolovsky
7a2f166949 modstruct: Fix alignment handling issues.
Also, factor out mp_binary_get_int() function.
2014-06-25 23:34:44 +03:00
Paul Sokolovsky
f605172d2b tests/float/: Skip tests if "math" module is not available. 2014-06-20 18:00:23 +03:00
Paul Sokolovsky
74c710187c bench: Three ways to process a byte buffer. 2014-06-19 22:27:13 +03:00
Paul Sokolovsky
59ced651b5 bench: Add test for map() vs inplace operations in array-likes.
map() is 5 times slower. That's mostly because of inefficiency of creating
containers from iterables of unknown length (like map()).
2014-06-19 22:19:24 +03:00
Paul Sokolovsky
17db096505 bench: Add tests for constructing various containers from iterator.
Both "bound" (like, length known) and "unbound" (length unknown) are tested.
All of list, tuple, bytes, bytesarray offer approximately the same
performance, with "unbound" case being 30 times slower.
2014-06-19 21:44:33 +03:00
Paul Sokolovsky
e53d2197e4 bench: Add test for function call overhead.
For a trivial operation, calling a function is 5 times slower than doing
operation inline.
2014-06-19 20:49:03 +03:00
Paul Sokolovsky
2ec38a17d4 objstr: Be 8-bit clean even for repr().
This will allow roughly the same behavior as Python3 for non-ASCII strings,
for example, print("<phrase in non-Latin script>".split()) will print list
of words, not weird hex dump (like Python2 behaves). (Of course, that it
will print list of words, if there're "words" in that phrase at all, separated
by ASCII-compatible whitespace; that surely won't apply to every human
language in existence).
2014-06-14 01:21:13 +03:00
Paul Sokolovsky
fbdf2f1d63 py: Rename builtin "io" to "_io".
Functionality we provide in builtin io module is fairly minimal. Some
code, including CPython stdlib, depends on more functionality. So, there's
a choice to either implement it in C, or move it _io, and let implement other
functionality in Python. 2nd choice is pursued. This setup matches CPython
too (_io is builtin, io is Python-level).
2014-06-12 01:22:25 +03:00
Paul Sokolovsky
f4bf065dac tests: Add testcases for "complicated" args to generator functions. 2014-06-11 20:43:47 +03:00
Damien George
58cbb4d661 py: Implement __contains__ special method. 2014-06-10 23:07:56 +01:00
Paul Sokolovsky
195de3247b objtype: Fix passing of class param to inherited classmethods.
This is getting more and more tangled, but that's old news.
2014-06-08 22:28:44 +03:00
Damien George
4297fed1c3 tests: Run 'micropython' tests on pyboard. 2014-06-08 13:46:03 +01:00
Damien George
9e951498b2 tests: Add more tests for default keyword-only args. 2014-06-08 12:58:32 +01:00
Damien George
c06427c019 tests: Fix default arg test. 2014-06-08 00:12:32 +01:00
Paul Sokolovsky
b4efac14cd py: Make sure getattr() works with non-interned strings (by interning them). 2014-06-08 01:15:06 +03:00
Damien George
f0778a7ccb py: Implement default keyword only args.
Should finish addressing issue #524.
2014-06-07 22:01:00 +01:00
Paul Sokolovsky
b56a53dfd6 Merge pull request #667 from Rosuav/testfixes
A couple of small fixes to run-tests
2014-06-06 22:23:23 +03:00
Dave Hylands
b69f9fa31f Fix str.modulo when precision is specified. 2014-06-05 23:09:02 -07:00
Chris Angelico
047db2299c Turn the Travis CI test skipping mechanism into something more generic 2014-06-06 07:51:01 +10:00
Chris Angelico
88b11b50e5 Figure out the test_name before using it (significant only to Travis skips) 2014-06-06 07:51:01 +10:00
Damien George
d4c2bddd0c py: Raise TypeError when trying to format non-int with %x,%o,%X.
This behaviour follows Python 3.5 standard (in 3.4 it's a
DeprecationWarning which we'd rather make a TypeError).
2014-06-05 19:44:54 +01:00
Chris Angelico
daf973ae00 Change comments (mainly URLs) to no longer specifically say Python 3.3 2014-06-06 03:51:03 +10:00
Damien George
c074cd38c3 Merge pull request #663 from Rosuav/floatpercentx
Remove tests that fail under CPython 3.5
2014-06-05 18:39:08 +01:00
Paul Sokolovsky
75ce9256b2 objstr: Implement "%(key)s" % {} formatting for strings and dicts.
Also, make sure that args to "*" format specifiers are bounds-checked
properly and don't lead for segfaults in case of mismatch.
2014-06-05 20:06:15 +03:00
Chris Angelico
7a6e09635a Remove tests that fail under CPython 3.5
See http://bugs.python.org/issue19995 for rationale. As micropython currently
aims for Python 3.3 compatibility I have not changed behaviour, but this
change allows the test suite to be run against a newer Python without having
spurious failures.
2014-06-05 22:34:11 +10:00
Damien George
bcb6ca4d5e py: Implement full behaviour of dict.update(), and dict().
Add keyword args to dict.update(), and ability to take a dictionary as
argument.

dict() class constructor can now use dict.update() directly.

This patch loses fast path for dict(other_dict), but is that really
needed?  Any anyway, this idiom will now re-hash the dictionary, so is
arguably more memory efficient.

Addresses issue #647.
2014-06-03 12:53:44 +01:00
Damien George
4d659f566f tests: Add feature test for when heap allocation is disabled. 2014-05-31 18:33:16 +01:00
Damien George
a053e37b2c tests: Change --test_dirs to --test-dirs. 2014-05-31 18:11:01 +01:00
Damien George
e7412ab37b Merge pull request #632 from stinos/tests-dir-argument
tests: Add argument to allow specifying which directories to test
2014-05-31 18:11:03 +01:00
Damien George
5b5562c1d1 py: Fix stack underflow with optimised for loop. 2014-05-31 17:59:11 +01:00
Damien George
049a01d148 tests: Add another test for break-from-for-loop. 2014-05-31 16:56:15 +01:00
Kim Bauters
a3f4b83018 add methods isspace(), isalpha(), isdigit(), isupper() and islower() to str 2014-05-31 07:30:57 +01:00
Paul Sokolovsky
ccd0e0afcd tests: Add test for break in for.
For #635 / 25c84643b6.
2014-05-31 00:43:41 +03:00
Paul Sokolovsky
8827682b35 objstr: *strip(): If nothing is stripped, don't create dup string. 2014-05-30 03:15:17 +03:00
Paul Sokolovsky
bcdffe53c6 objstr: *strip(): Fix handling of one-char subject strings. 2014-05-30 03:15:17 +03:00
Damien George
f55cf10101 py: Implement bignum '&' with negatives on lhs and rhs.
Needs proper coverage testing.  Doesn't implement -ve & -ve.
Addresses issue #611.
2014-05-29 15:01:49 +01:00
stijn
8ac3b578e5 tests: Add argument to allow specifying which directories to test 2014-05-28 14:33:30 +02:00
Paul Sokolovsky
d07bf029b7 tests: Add small testcase for 3-arg slices. 2014-05-26 02:02:47 +03:00
Paul Sokolovsky
5fd5af98d0 objlist: Implement support for arbitrary (3-arg) slices. 2014-05-25 22:12:56 +03:00
Paul Sokolovsky
2705f4c782 objlist: Implement growing slice assignment.
This means that complete slice operations are supported for lists (but not
for bytearray's and array.array's).
2014-05-25 02:36:12 +03:00
Paul Sokolovsky
d098c6bf85 objstr: Implement .endswith(). 2014-05-24 22:46:51 +03:00
Paul Sokolovsky
806ea1f6ca py: Initial attempts to actually allow implementing __new__ in Python.
Caveat is that __new__ should recurse to base class __new__, and ultimately,
object.__new__ is what handles instance allocation.
2014-05-22 00:32:00 +03:00
Paul Sokolovsky
a8408a8abe objtype: super: Fall back to "object" lookup as last resort.
Also, define object.__init__() (semantically empty, purely CPython compat
measure). Addresses #520.
2014-05-21 22:27:03 +03:00
Damien George
0fd01683c6 Merge pull request #607 from Anton-2/osx-clang
Allow compilation of unix port under clang on OS X
2014-05-21 19:51:05 +01:00
Paul Sokolovsky
66ab571cca tests: Update subclass-native2.py for __new__/__init__ refactor.
Now case of subclassing tuple works, and list is broken, see comments.
2014-05-19 21:56:07 +03:00
Paul Sokolovsky
c18ef2a9dd objstr: startswith(): Accept optional "start" arg. 2014-05-15 21:33:18 +03:00
Paul Sokolovsky
70328e419a py: Implement more complete bytes comparison handling. 2014-05-15 20:58:40 +03:00
Paul Sokolovsky
ad3baec12f sequence: Fix yet another case of improper sequence comparison.
This time, in mp_seq_cmp_bytes(). How many more cases are still lurking?
2014-05-15 19:09:06 +03:00
Paul Sokolovsky
2a27365854 objstr.c: Partial implementation of .rsplit().
sep=None is TODO.
2014-05-14 02:42:20 +03:00
Paul Sokolovsky
7074f25768 tests/int-long.py: Try to expose issue with recent "&" optimization. 2014-05-13 08:24:54 +03:00
Damien George
561e425903 py: Fix bug in mpz_and function.
Addresses issue #610.
2014-05-12 23:27:29 +01:00
Paul Sokolovsky
df94b717b4 modstruct: Implement count specifier for strings (e.g. "100s").
Infra for counts of other types is there, need last mile to be implemented.
2014-05-12 23:45:50 +03:00
Antonin ENFRUN
1b901c320b tests: create result file for test/basics/memoryerror.py .
On Mac OS "python3 test/basics/memoryerror.py" never runs out of memory, the process is frozen by the os before.
2014-05-12 00:13:10 +02:00
Paul Sokolovsky
5ebd5f0f19 objstr: Slice indexing: support bytes properly. 2014-05-11 21:22:59 +03:00
Paul Sokolovsky
bfb8819c0c objstr: Make .split() support bytes. 2014-05-11 21:17:28 +03:00
Paul Sokolovsky
5e5d69b35e objstr: Make .join() support bytes. 2014-05-11 21:13:01 +03:00
Paul Sokolovsky
ff30666c69 py: Add basic implementation of hasattr() function. 2014-05-11 20:51:30 +03:00
Damien George
1d34e32431 py: frozenset() creates an empty frozenset. 2014-05-11 18:28:48 +01:00
Damien George
c3dcb590b8 Merge pull request #603 from stinos/windows-tests-newline
tests: Fix handling of newlines from expected output files on windows
2014-05-11 15:03:57 +01:00
Paul Sokolovsky
eea0118654 py: Give up and make mp_obj_str_get_data() deal with bytes too.
This is not fully correct re: error handling, because we should check that
that types are used consistently (only str's or only bytes), but magically
makes lot of functions support bytes.
2014-05-11 13:51:24 +03:00
stijn
a4dbc73e8a tests: Fix handling of newlines from expected output files 2014-05-11 12:45:02 +02:00
Paul Sokolovsky
b2d4fc06fc objstr: Make *strip() accept bytes. 2014-05-11 13:17:29 +03:00
Paul Sokolovsky
ce6c10172b tests: Really fix import. 2014-05-11 03:45:42 +03:00
Paul Sokolovsky
b4acd028b6 tests: Fix import. 2014-05-11 03:40:32 +03:00
Paul Sokolovsky
ea9708092e objtuple: Go out of the way to support comparison of subclasses.
Two things are handled here: allow to compare native subtypes of tuple,
e.g. namedtuple (TODO: should compare type too, currently compared
duck-typedly by content). Secondly, allow user sunclasses of tuples
(and its subtypes) be compared either. "Magic" I did previously in
objtype.c covers only one argument (lhs is many), so we're in trouble
when lhs is native type - there's no other option besides handling
rhs in special manner. Fortunately, this patch outlines approach with
fast path for native types.
2014-05-11 03:33:19 +03:00
Paul Sokolovsky
9511f60f01 py: Don't try to "bind" types store as attributes of objects.
This was hit when trying to make urlparse.py from stdlib run. Took
quite some time to debug.

TODO: Reconsile bound method creation process better, maybe callable is
to generic type to bind at all?
2014-05-11 03:33:19 +03:00
Paul Sokolovsky
69f3eb2c96 objstr: Make .[r]partition() work with bytes. 2014-05-11 03:33:19 +03:00
Paul Sokolovsky
3f8d34ca83 objlist: Support list slice deletion. 2014-05-10 23:03:30 +03:00
Paul Sokolovsky
94d8246272 objlist: Implement non-growing slice assignment.
Slice value to assign can be only a list so far too.
2014-05-10 22:24:31 +03:00
Paul Sokolovsky
1a7403bb74 objtype: Implement ->getiter() method for instances.
Includes support for native bases.
2014-05-10 21:26:08 +03:00
Paul Sokolovsky
7067d69bcc objnamedtuple: Support iteration. 2014-05-10 21:26:07 +03:00
Paul Sokolovsky
6913521911 objstr: Implement .lower() and .upper(). 2014-05-10 19:49:07 +03:00
Paul Sokolovsky
37b0f33545 objset: Add frozenset tests, skippable if frozenset not available. 2014-05-10 16:56:21 +03:00
Paul Sokolovsky
43d4a6fa31 run-tests: Add support for skipping tests.
MicrpPython test should print single "SKIP" line for test to be skipped.
2014-05-10 16:56:21 +03:00
Paul Sokolovsky
d86020ac4f objtype: Don't treat inheritance from "object" as from native type.
"object" type in MicroPython currently doesn't implement any methods, and
hopefully, we'll try to stay like that for as long as possible. Even if we
have to add something eventually, look up from there might be handled in
adhoc manner, as last resort (that's not compliant with Python3 MRO, but
we're already non-compliant). Hence: 1) no need to spend type trying to
lookup anything in object; 2) no need to allocate subobject when explicitly
inheriting from object; 3) and having multiple bases inheriting from object
is not a case of incompatible multiple inheritance.
2014-05-10 16:56:20 +03:00
Damien George
04b7cc4df0 stmhal: Fix setting of RTC: was BCD now BIN encoded.
Addresses issue #592.
2014-05-10 11:56:58 +01:00
Paul Sokolovsky
6e8085b425 py: Fix base "detection" for int('0<hexdigit>', 16). 2014-05-10 04:45:15 +03:00
Paul Sokolovsky
7b0f9a7d9b bytes: Implement comparison and other binary operations.
Should support everything supported by strings.
2014-05-10 04:45:02 +03:00
Damien George
ffae48d750 py, compiler: Add basic support for A=const(123).
You can now do:

    X = const(123)
    Y = const(456 + X)

and the compiler will replace X and Y with their values.

See discussion in issue #266 and issue #573.
2014-05-08 15:58:39 +00:00
Damien George
d509ac25f9 py: Fix stack access in thumb native emitter. 2014-05-07 23:27:45 +01:00
Paul Sokolovsky
69cbec4afb tests/bench: Add testcase for positional/kwargs to enumerate().
Inspired by discussion in #577. So, in this case of builtin function,
passing args by keyword has less than 1% overhead.
2014-05-07 22:34:06 +03:00
Paul Sokolovsky
2a05f05f44 tests/bench: Add tests for various ways to pass function args.
Passing 3 args with keywords is for example 50% slower than via positional
args.
2014-05-07 22:34:04 +03:00
Paul Sokolovsky
1695151267 tests/bench: Add variation on loop_count/while_down_ne test. 2014-05-07 22:34:04 +03:00
Paul Sokolovsky
6638ea9ca3 tests/bench: Add testcases for lookup in 5-el instance and namedtuple.
... and we have not that bad mapping type after all - lookup time is ~ the
same as in one-attr instance. My namedtuple implementation on the other
hand degrades awfully.

So, need to rework it. First observation is that named tuple fields are
accessed as attributes, so all names are interned at the program start.
Then, really should store field array as qstr[], and do quick 32/64 bit
scan thru it.
2014-05-07 22:34:00 +03:00
Paul Sokolovsky
52b25293e2 tests/bench: Time namedtuple field access.
That's higher than instance field access - behold the power of hashing.
2014-05-07 22:33:37 +03:00
Damien George
9102af6afb tests: Add a test for native code on pyboard. 2014-05-07 18:55:31 +01:00
Damien George
c4ccb078a5 tests: Add inline assembler test for pyboard. 2014-05-07 18:31:14 +01:00
Damien George
491cbd6a7c py: Add keyword arg support to enumerate constructor.
Need to have a policy as to how far we go adding keyword support to
built ins.  It's nice to have, and gets better CPython compatibility,
but hurts the micro nature of uPy.

Addresses issue #577.
2014-05-06 16:38:54 +00:00
Paul Sokolovsky
f01fa458d8 tests/bench/var: Add tests for class/instance var access.
Also compared with method abstraction for accessing instance vars -
it's more than 3 times slower than accessing var directly.
2014-05-05 02:17:13 +03:00
Paul Sokolovsky
aaff82afe5 tests: Add framework for comparative benchmarking.
Motivation is optimizing handling of various constructs as well as
understanding which constructs are more efficient in MicroPython.
More info: http://forum.micropython.org/viewtopic.php?f=3&t=77

Results are wildly unexpected. For example, "optimization" of range
iteration into while loop makes it twice as slow. Generally, the more
bytecodes, the slower the code.
2014-05-05 01:24:16 +03:00
Damien George
cda363a036 tests, pyb: Add 'import pyb' when needed. 2014-05-04 12:40:51 +01:00
Damien George
d5f5b2f766 py, stream: Implement readlines for a stream. 2014-05-03 22:01:32 +01:00
Damien George
41f768f3f3 tests: Add a suite of tests specifically for the pyboard.
In tests/pyb is now a suite of tests that tests the pyb module on the
pyboard.  They include expected output files because we can't run
CPython on the pyboard to compare against.

run-tests script has now been updated to allow pyboard tests to be run.
Just pass the option --pyboard.  This runs all basic, float and pyb
tests.  Note that float/math-fun.py currently fails because not all math
functions are implemented in stmhal/.
2014-05-03 16:43:27 +01:00
Paul Sokolovsky
e276753b45 tests: Add testcases for catching user Exception subclasses. 2014-05-02 02:31:30 +03:00
Paul Sokolovsky
d8351ca8a0 objtype: .print() Exception instances in adhoc way.
This is ugly, just as expected.
2014-05-02 02:00:47 +03:00
Andrew Scheller
37067666ee Fix the builtin min() and max() functions (and add tests).
Fixes #539
2014-05-01 21:21:43 +01:00
Paul Sokolovsky
c963310123 tests: Add test for calling inherited native method on subclass. 2014-04-30 02:17:45 +03:00
Paul Sokolovsky
5a12137c3e tests: Add test for accessing attribute of inherited native type. 2014-04-29 20:31:13 +03:00
Paul Sokolovsky
4f46c441ef tests: Add basic tests for subclassing native types and using special methods.
Even of these, some features do not yet work as expected.
2014-04-29 20:31:13 +03:00
Damien George
186e463a9e py: Fix bug in map lookup of interned string vs non-interned.
Had choice of either interning or forcing full equality comparison, and
chose latter.  See comments in mp_map_lookup.

Addresses issue #523.
2014-04-28 12:11:57 +01:00
Damien George
2827d62e8b py: Implement keyword-only args.
Implements 'def f(*, a)' and 'def f(*a, b)', but not default
keyword-only args, eg 'def f(*, a=1)'.

Partially addresses issue #524.
2014-04-27 15:50:52 +01:00
Paul Sokolovsky
cb9dc086a3 modio: Implement io.StringIO class. 2014-04-26 20:26:14 +03:00
Paul Sokolovsky
881078403e objstr: Implement .lstrip() & .rstrip().
Share code with .strip(). TODO: optimize .rstrip().
2014-04-26 06:20:08 +03:00
Paul Sokolovsky
755565d2cb py: Support instance __call__ method. 2014-04-25 21:17:42 +03:00
Paul Sokolovsky
efc36f0cea test/class-super: Expose super() breakage. 2014-04-19 21:54:06 +03:00
Paul Sokolovsky
d6e12723ed objarray: Implement slice subscription. 2014-04-19 20:06:57 +03:00
Paul Sokolovsky
6204460461 modstruct: Initial implementation of struct.pack(). 2014-04-19 03:22:08 +03:00
Paul Sokolovsky
83eba5dec5 sequence: Fix glaring bug in sequence comparison. 2014-04-18 21:42:54 +03:00
Damien George
559d8239ca tests: Move gen_context to import tests, because it relies on import. 2014-04-17 23:21:52 +01:00
Paul Sokolovsky
b7e90ea078 objgenerator: Generator must execute in its defining lexical context.
I.e. with its own globals. So, just as for functions, we need to switch
globals when resuming a generator.
2014-04-17 20:27:00 +03:00
Damien George
91d0ab9b0f Merge pull request #504 from lurch/patch-4
Allow the uPy used by run-tests to be overridden
2014-04-17 17:20:26 +01:00
Damien George
5cd0b2227f tests: Split out those tests requiring float and import.
Tests in basics (which should probably be renamed to core) should not
rely on float, or import any non-built-in files.  This way these tests
can be run when those features are not available.

All test in basics now pass on the pyboard using stmhal port, except for
string-repr which has some issues with character hex printing.
2014-04-17 16:21:43 +01:00
Andrew Scheller
5709453ca7 Changed the envvar name to MICROPY_MICROPYTHON
As discussed in #504
2014-04-17 01:22:45 +01:00
Damien George
7447e80f3d tests: Remove print('flush') from 2 tests, since stmhal now works.
Fixing the USB problem on stmhal now gets these 2 tests working.
2014-04-17 00:14:05 +01:00
Andrew Scheller
6ca17bcfb6 Stupid typo 2014-04-16 21:17:28 +01:00
Andrew Scheller
c297ca3327 Allow the uPy used by run-tests to be overridden
with MICROPY_MP_PY envvar, in an analogous way to MICROPY_CPYTHON3 envvar.

(the reason for this will be made clearer by a later PR)
2014-04-16 20:24:16 +01:00
Andrew Scheller
83852d3215 fix README to match contents of run-tests 2014-04-16 20:14:38 +01:00
Andrew Scheller
1b997d5244 run-tests can now skip certain tests when run under Travis CI
See the `skip_travis_tests` variable. Fixes #495
(also tidied up usage of os.path.basename() function)
2014-04-16 03:28:40 +01:00
Damien George
897fe0c0d0 py: Add builtin functions bin and oct, and some tests for them. 2014-04-15 22:03:55 +01:00
Damien George
256b319d56 tests: Disable memoryerror.py test, since it fails on travis.
Would be good to test this, but need to find a way to optionally not
running it when on travis.
2014-04-15 12:30:30 +01:00
Damien George
48aaa27c6a travis: Diff output, hopefully this works. 2014-04-15 12:20:22 +01:00
Damien George
e8ecca21ff travis: More tests output debugging. 2014-04-15 11:56:57 +01:00
Damien George
35443610b1 travis: More tests debugging. 2014-04-15 11:38:30 +01:00
Damien George
45b4cc77dd travis: Debugging failing tests. 2014-04-15 11:25:36 +01:00
Paul Sokolovsky
75ffcaeace py: Implement __delitem__ method for classes. 2014-04-15 01:30:25 +03:00
Damien George
e2a48b66c2 tests: Add property test. 2014-04-13 19:00:27 +01:00
Damien George
4417478d0f tests: Make tests pass on pyboard. 2014-04-13 17:46:30 +01:00
Damien George
b636d024d2 Make pyboard.py have its own exception; update run-tests for pyboard. 2014-04-13 13:48:33 +01:00
Damien George
f95c68e536 Merge pull request #473 from pfalcon/list-extend-iter
objlist: Make .extend accept arbitrary iterable.
2014-04-13 12:46:34 +01:00
Paul Sokolovsky
48fdaad824 py: Rename collections module to _collections.
We're not going to implement all the plethora of types in there in C.
Funnily, CPython implements defaultdict in C, and namedtuple in Python.
2014-04-13 10:24:00 +03:00
Paul Sokolovsky
aa6666c45e objlist: Make .extend accept arbitrary iterable. 2014-04-13 03:21:31 +03:00
Damien George
6ce4277551 py: Make all LOAD_FAST ops check for unbound local.
This is necessary to catch all cases where locals are referenced before
assignment.  We still keep the _0, _1, _2 versions of LOAD_FAST to help
reduced the byte code size in RAM.

Addresses issue #457.
2014-04-12 18:20:40 +01:00
Damien George
c2803db010 tests: Add some bytecode tests. 2014-04-12 18:00:32 +01:00
Paul Sokolovsky
a5afc9009f builtinimport: Implement relative imports. 2014-04-12 18:25:17 +03:00
Paul Sokolovsky
2ff3d9d0b2 builtinimport: Set __path__ attribute ASAP as it's clear we have a package.
This helps with handling "recursive" imports in sane manner, for example
when foo/__init__.py has something like "from foo import submod".
2014-04-12 02:55:18 +03:00
Damien George
8f19317540 py: Remove useless implementations of NOT_EQUAL in binary_op's.
I'm pretty sure these are never reached, since NOT_EQUAL is always
converted into EQUAL in mp_binary_op.  No one should call
type.binary_op directly, they should always go through mp_binary_op
(or mp_obj_is_equal).
2014-04-12 00:20:39 +01:00
Paul Sokolovsky
af620abcb5 py: Implement "from pkg import mod" variant of import. 2014-04-12 00:39:55 +03:00
Damien George
0e3329a6b8 py, compiler: Allow lambda's to yield. 2014-04-11 13:10:21 +00:00
Damien George
0288cf020e py: Implement compiling of *-expr within parenthesis. 2014-04-11 11:53:00 +00:00
Damien George
686afc5c0a py: Check that sequence has 2 elements for dict iterable constructor. 2014-04-11 09:13:30 +01:00
Paul Sokolovsky
be019ce063 objdict: Implement construction from iterable of pairs.
Pairs are limited to tuples so far.
2014-04-11 07:01:15 +03:00
Paul Sokolovsky
12a04392b9 objdict: Implement __getitem__ method. 2014-04-11 05:24:44 +03:00
Paul Sokolovsky
0c43cf9154 modstruct: Basic implementation of native struct alignment and types. 2014-04-11 03:59:16 +03:00
Paul Sokolovsky
6582d64d01 modstruct: Refactor to support both LE and BE packed structs. 2014-04-11 03:58:49 +03:00
Damien George
f31b6ff334 tests: Add test for multi-comparison. 2014-04-10 17:29:51 +00:00
Paul Sokolovsky
978607aeff objfun: Fix default arguments filling loop, was broken in presense of kwargs. 2014-04-10 05:39:38 +03:00
Paul Sokolovsky
e9db840480 py: Start implementing "struct" module.
Only calcsize() and unpack() functions provided so far, for little-endian
byte order. Format strings don't support repition spec (like "2b3i").

Unfortunately, dealing with all the various binary type sizes and alignments
will lead to quite a bloated "binary" helper functions  - if optimizing for
speed. Need to think if using dynamic parametrized algos makes more sense.
2014-04-10 03:58:03 +03:00
Damien George
038fd52faa Merge branch 'str-index' of github.com:xbe/micropython into xbe-str-index 2014-04-09 20:44:37 +01:00
Damien George
a157e4caba py: str.join can now take arbitrary iterable as argument. 2014-04-09 19:17:53 +01:00
Damien George
13d6739cc7 py: Generators can have their locals closed over. 2014-04-09 19:01:45 +01:00
Damien George
2bf7c09222 py: Properly implement deletion of locals and derefs, and detect errors.
Needed to reinstate 2 delete opcodes, to specifically check that a local
is not deleted twice.
2014-04-09 15:26:46 +01:00
Paul Sokolovsky
a985b4593d objint: Implement int.from_bytes() class method and .to_bytes() method.
These two are apprerently the most concise and efficient way to convert
int to/from bytes in Python. The alternatives are struct and array modules,
but methods using them are more verbose in Python code and less efficient
in memory/cycles.
2014-04-09 01:07:37 +03:00
Damien George
2b0091983f tests: Oops: fix del-attr. 2014-04-08 23:02:24 +01:00
Damien George
f4c9b33abf py: Remove DELETE_SUBSCR opcode, combine with STORE_SUBSCR.
This makes the runtime and object APIs more consistent.  mp_store_subscr
functionality now moved into objects (ie list and dict store_item).
2014-04-08 21:32:29 +01:00
Paul Sokolovsky
4dcb605ac4 py: Make bytearray a proper type. 2014-04-08 22:11:40 +03:00
xbe
3d9a39e211 py: Implement str.[r]index() and add tests for them. 2014-04-08 11:51:41 -07:00
Damien George
134c10e776 Merge branch 'master' of github.com:micropython/micropython 2014-04-08 18:29:50 +01:00
Damien George
495d781a36 py: implement UNPACK_EX byte code (for: a, *b, c = d) 2014-04-08 17:51:47 +01:00
Paul Sokolovsky
b9cf3d3730 bytearray: Support bytearray(int) constructor.
To create bytearray of given length.
2014-04-08 19:08:34 +03:00
Andrew Scheller
12968fb6b2 Display \r and \t escape codes in string repr 2014-04-08 02:42:50 +01:00
Dave Hylands
c4029e5079 Add string formatting support for longlong and mpz. 2014-04-07 11:38:45 -07:00
Damien George
1422865c99 Merge pull request #445 from lurch/test-sorted-sets
Modify set tests to print sorted sets directly
2014-04-07 13:15:33 +01:00
Andrew Scheller
1ff6011abc Modify set tests to print sorted sets directly
instead of creating temporary lists and sorting those in-place
2014-04-07 05:00:03 +01:00
Andrew Scheller
a1a9ab2b2c Add tests for sorted() function
and check that sorted(list) produces same output as list.sort()
2014-04-07 04:41:54 +01:00
Paul Sokolovsky
4d2238d2ce tests: Fix more tests which depend on order of elements in set. 2014-04-07 03:08:46 +03:00
Paul Sokolovsky
bd6f3d31d2 tests: Fix few tests which depend on order of elements in set. 2014-04-07 02:54:16 +03:00
Damien George
07e24a6294 tests: Fix tests with sets to print sorted set. 2014-04-07 00:42:09 +01:00
Damien George
ff715429ea py: Fix str.replace for case when arg 0 or 1 is empty string. 2014-04-07 00:39:13 +01:00
Paul Sokolovsky
b4dea46d8b tests: Fix few tests which depend on order of elements in dict.
With dict being unordered of course.
2014-04-06 21:31:42 +03:00
Paul Sokolovsky
e2adff3608 tests/dict2.py: Add combined test for dict(dict) and dict equality. 2014-04-06 21:31:42 +03:00
Damien George
cdd96dff2c py: Implement more features in native emitter.
On x64, native emitter now passes 70 of the tests.
2014-04-06 12:58:40 +01:00
Damien George
deed087e2c py: str.split: handle non-default separator. 2014-04-06 11:11:15 +01:00
Damien George
2a037408af tests: Add test to check issue #429. 2014-04-05 18:17:51 +01:00
Damien George
327a3e2faa Merge pull request #435 from dhylands/str-modulo-float
Allow floating point arguments with %d,i,u,o,x,X formats
2014-04-05 18:10:11 +01:00
Damien George
23419a2f8a Merge pull request #433 from pfalcon/getattr-3arg
py: Support 3-arg getattr() builtin (with default value).
2014-04-05 18:00:04 +01:00
Damien George
95004e5114 py: Fix delete operation on map/dict and set objects.
Hash table can now be completely full (ie now NULL entry) before a
resize is triggered.  Use sentinel value to indicate delete entry in the
table.
2014-04-05 17:17:19 +01:00
Dave Hylands
f81a49e464 Allow floating point arguments with %d,i,u,o,x,X formats 2014-04-05 08:26:51 -07:00
Damien George
b6ec51bbf0 tests: Add test for dict delete. It fails. 2014-04-05 13:26:00 +01:00
Paul Sokolovsky
bfb7d6a26d py: Support 3-arg getattr() builtin (with default value). 2014-04-05 13:34:02 +03:00
Paul Sokolovsky
438d504e27 objtype: Add equality test for type types. 2014-04-05 13:10:56 +03:00
Paul Sokolovsky
91cbe6033a py: Allow types to be hashable.
Quite natural to have d[int] = handle_int .
2014-04-05 12:51:58 +03:00
Paul Sokolovsky
a7752a4540 run-tests: Elaborate python3 command override capabilities. 2014-04-04 17:28:34 +03:00
Damien George
9b1599c663 Merge pull request #422 from dhylands/str-modulo
Str modulo
2014-04-04 12:37:52 +01:00
Damien George
28390340e5 tests: Make rge-sm.py use less memory (integration step increased).
In addition to memory allocation failure, other problem was that 10**17
was overflowing.  Now passes.
2014-04-04 11:15:54 +00:00
Damien George
6902eeda25 py: Add m_malloc_fail function to handle memory allocation error.
A malloc/realloc fail now throws MemoryError.
2014-04-04 10:52:59 +00:00
Paul Sokolovsky
072cf022e0 tests/file-with: Add testcase which failed for @dpgeorge.
Works on x86.
2014-04-04 12:15:39 +03:00
Dave Hylands
6756a37a77 Implements most of str.modulo
The alternate form for floating point doesn't work yet.
The %(name)s form doesn't work yet.
2014-04-03 23:55:02 -07:00
Damien George
4b34c76fd6 Changes to get unix/ port compiling on Cygwin. 2014-04-03 23:51:16 +01:00
Damien George
2309369291 tests: Allow to run tests on pyboard.
To run the tests on the pyboard you need to set the "test_on_pyboard"
variable to "True", and also have tools/pyboard.py available for import
(easiest is to symlink to it).
2014-04-03 22:44:51 +01:00
Paul Sokolovsky
34e1199b3a run-tests: Allow to override python3 command to use via environment var. 2014-04-03 22:09:12 +03:00
Paul Sokolovsky
c61ce96590 unix file: Implement context manager protocol (for "with" statement). 2014-04-03 22:09:05 +03:00
Damien George
c322c5f07f py: Fix regress for printing of floats and #if.
Also change formating modifier in test script (it still passes with
original format though).
2014-04-02 20:04:15 +01:00
Paul Sokolovsky
ad1bac63f7 tests/string-format: Add test for formatting ints with float format.
Fail currently.
2014-04-02 20:41:34 +03:00
Damien George
929a675a3d Change test scripts to use python3; bytecode tests use python3.4.
I upgraded to Python 3.4.0, so needed to make these changes.  Hopefully
the tests still run with Python 3.3.x (the scripts use python3 so are
agnostic as to the subversion).

Bytecode tests are tightly coupled to the Python version, and now some
fail against Python 3.4.
2014-04-02 15:31:39 +01:00
Damien George
10e21b9770 Add more tests. 2014-04-02 14:23:04 +01:00
Damien George
93b7faa29a py: Factor out static/class method unwrapping code; add tests. 2014-04-02 14:13:26 +01:00
Damien George
e4c834fc1e Add a test. 2014-04-02 13:32:37 +01:00
Damien George
4881566874 py: Add support for sep and end keywords in print. 2014-04-02 10:34:44 +01:00
Damien George
084ef373fb py: Fix math.{ceil,floor,trunc} to return int. 2014-04-01 21:21:50 +01:00
Dave Hylands
7adc2e0431 Turn off full tests in string-format.py
Add some basic coverage tests
2014-04-01 08:10:02 -07:00
Paul Sokolovsky
51413c8cb6 tests: Add test for implicit float to int conversion (not allowed!) 2014-04-01 13:50:16 +03:00
Dave Hylands
baf6f14deb Enhance str.format support
This adds support for almost everything (the comma isn't currently
supported).

The "unspecified" type with floats also doesn't behave exactly like
python.

Tested under unix with float and double
Spot tested on stmhal
2014-04-01 01:17:33 -07:00
Damien George
e44d26ae0c py: Implement __getattr__.
It's not completely satisfactory, because a failed call to __getattr__
should not raise an exception.

__setattr__ could be implemented, but it would slow down all stores to a
user created object.  Need to implement some caching system.
2014-03-31 22:57:56 +01:00
Paul Sokolovsky
4db727afea objstr: Very basic implementation of % string formatting operator. 2014-03-31 21:20:52 +03:00
Damien George
18a6eb9e13 Merge branch 'master' of github.com:micropython/micropython 2014-03-31 18:03:52 +01:00
Damien George
3ff2d03891 py: Fix bug in optimised for .. range.
Don't store final, failing value to the loop variable.  This fix also
makes for .. range a bit more efficient, as it uses less store/load
pairs for the loop variable.
2014-03-31 18:02:22 +01:00
Paul Sokolovsky
183faa3b13 tests: Add testcase for multiple inheritance. 2014-03-31 19:46:35 +03:00
Paul Sokolovsky
6ded55a61f py: Properly implement divide-by-zero handling.
"1/0" is sacred idiom, the shortest way to break program execution
(sys.exit() is too long).
2014-03-31 02:23:57 +03:00
Damien George
0aa4379543 Merge pull request #399 from pfalcon/gen-defargs
objgenerator: Handle default args to generator functions.
2014-03-30 21:51:49 +01:00
Paul Sokolovsky
f7eaf605c0 py: Fix "TypeError: 'iterator' object is not iterable", doh. 2014-03-30 23:37:24 +03:00
Paul Sokolovsky
f39d3b93da py: Implement support for generalized generator protocol.
Iterators and ducktype objects can now be arguments of yield from.
2014-03-30 23:30:16 +03:00
Damien George
230fec77d7 py: Implement positional and keyword args via * and **.
Extends previous implementation with * for function calls to * and **
for both function and method calls.
2014-03-30 21:21:24 +01:00
Paul Sokolovsky
7fafb28f6d objgenerator: Handle default args to generator functions.
Addresses #397.
2014-03-30 20:25:19 +03:00
Paul Sokolovsky
55ca075cab vm: Implement CALL_FUNCTION_VAR opcode (foo(*(1, 2, 3))). 2014-03-30 17:47:16 +03:00
Damien George
010043caaf Add "tracing" to try-reraise2.py test. It now fails. 2014-03-30 00:39:15 +00:00
Paul Sokolovsky
0c904df8e6 vm: Save current active exception on opening new try block.
Required to reraise correct exceptions in except block, regardless if more
try blocks with active exceptions happen in the same except block.

P.S. This "automagic reraise" appears to be quite wasteful feature of Python
- we need to save pending exception just in case it *might* be reraised.
Instead, programmer could explcitly capture exception to a variable using
"except ... as var", and reraise that. So, consider disabling argless raise
support as an optimization.
2014-03-30 01:01:35 +02:00
Paul Sokolovsky
d109676ec0 py: Reraising exception possible only in except block. 2014-03-29 23:18:59 +02:00
Damien George
21a07dc50f Merge pull request #389 from pfalcon/with-statement
With statement implementation
2014-03-29 14:00:03 +00:00
Damien George
da51a399cf Merge pull request #383 from pfalcon/yield-from
Implement "yield from"
2014-03-29 12:18:14 +00:00
Damien George
75f71584a6 tests: Remove unimplemented exceptions from testing. 2014-03-29 11:43:00 +00:00
Paul Sokolovsky
e7286ef2c7 tests: Add "with" statement testcases. 2014-03-29 04:39:31 +02:00
Paul Sokolovsky
3c2b2acd8c tests: Add testcases for yield from. 2014-03-28 02:50:56 +02:00
Damien George
d6f9434091 Merge pull request #381 from pfalcon/closure-defargs
py: Support closures with default args.
2014-03-26 23:09:14 +00:00
Paul Sokolovsky
e9137b94f2 py: Implement getattr() builtin. 2014-03-27 00:11:36 +02:00
Paul Sokolovsky
2447a5b582 py: Support closures with default args. 2014-03-26 23:17:44 +02:00
Damien George
66eaf84b8c py: Replace mp_const_stop_iteration object with MP_OBJ_NULL. 2014-03-26 19:27:58 +00:00
Damien George
688e220d26 Merge pull request #379 from pfalcon/reraise
vm: Implement raise statement w/o args (reraising last exception).
2014-03-26 18:59:15 +00:00
Damien George
752ba554cc Merge branch 'gen-close-ret-val' of github.com:pfalcon/micropython into pfalcon-gen-close-ret-val 2014-03-26 18:46:06 +00:00
Paul Sokolovsky
c403076ef8 vm: Implement raise statement w/o args (reraising last exception). 2014-03-26 17:32:02 +02:00
Paul Sokolovsky
962b1cd1b1 objgenerator: Implement return with value and .close() method.
Return with value gets converted to StopIteration(value). Implementation
keeps optimizing against creating of possibly unneeded exception objects,
so there're considerable refactoring to implement these features.
2014-03-26 15:40:58 +02:00
Damien George
681d0a9ca7 Merge pull request #370 from xbe/str-rfind
py/objstr.c: Implement str.rfind() and add tests for it, refactor find_subbytes().
2014-03-25 15:51:15 +00:00
Damien George
ffb5cfc8d8 py: Removed some unnecessary exception objects.
They still exist in commented-out form in objexcept.c if they are ever
needed.
2014-03-25 14:29:40 +00:00
Paul Sokolovsky
9512e9e817 objexcept: Add "args" exception attribute, as well as StopIteration.value. 2014-03-25 01:42:01 +02:00
Paul Sokolovsky
7f8b31345b rt_load_method(): Add missing qstr_str() when getting type name. 2014-03-25 01:39:10 +02:00
xbe
17a5a83fb4 Implement str.rfind() and add tests for it. 2014-03-24 01:00:00 -07:00
Paul Sokolovsky
f909034400 py: Implement support for "except Exception as var" clause.
For this, needed to implement DELETE_NAME bytecode (because var bound
in except clause is automatically deleted at its end).
http://docs.python.org/3/reference/compound_stmts.html#except :
"When an exception has been assigned using as target, it is cleared at
the end of the except clause."
2014-03-23 22:00:04 +02:00
Paul Sokolovsky
fd232c3ef7 run-tests: Dump output of failing tests to files again.
This was a long-standing regression from converting script from sh to python.
2014-03-23 01:58:07 +02:00
Damien George
a6d53188b7 Merge pull request #359 from rjdowdall/master
Fixed some math functions and added more exceptions.
2014-03-22 20:26:17 +00:00
Rachel Dowdall
56402796d8 Fixed floor division on mp ints and small ints. Added a floordivide test case. 2014-03-22 20:19:24 +00:00
Rachel Dowdall
cde8631f15 Fixed modulo operator on ints and mp ints to agree with python. Added intdivmod.c and tests/basics/modulo.py. 2014-03-22 17:29:27 +00:00
Paul Sokolovsky
48caa09a9d objgenerator: Implement .throw() method to throw exceptions into generator. 2014-03-22 17:55:42 +02:00
Paul Sokolovsky
61fd20f168 objgenerator: Implement throwing exceptions out of generator. 2014-03-22 17:55:42 +02:00
Paul Sokolovsky
c0abc28aa1 objgenerator: Keep exception stack within generator object, like value stack.
This is required to properly handle exceptions across yields.
2014-03-22 17:55:42 +02:00
Rachel Dowdall
721c55dced Added exception hierarchy except for OSError and UnicodeError (requires arguments). Comment out the errors that aren't needed if memory becomes an issue. 2014-03-22 15:28:16 +00:00
Rachel Dowdall
249b9c761d Fixed broken math functions that return bool and added some more. 2014-03-22 14:39:33 +00:00
Paul Sokolovsky
1ecea7c753 py: Make 'bytes' be a proper type, support standard constructor args. 2014-03-22 00:07:04 +02:00
Paul Sokolovsky
42901554db objint_longlong: Add regression test for improper inplace op implementation. 2014-03-22 00:04:04 +02:00
Damien George
e3e7c2bafb Merge pull request #351 from xbe/str-partition
Implement str.partition and add tests for it.
2014-03-21 20:19:30 +00:00
xbe
4504ea8007 Implement str.rpartition and add tests for it. 2014-03-21 02:58:09 -07:00
xbe
613a8e3edf Implement str.partition and add tests for it. 2014-03-21 02:57:18 -07:00
Damien George
1609f85582 Rename test so that it doesn't clash with Python math module. 2014-03-20 23:41:04 +00:00
Rachel Dowdall
5a14a1d690 Added various simple functions to math module. 2014-03-20 21:26:51 +00:00
Damien George
2d7ff07175 py: Add mpz modulo operation. 2014-03-20 16:28:41 +00:00
Paul Sokolovsky
51bbf6a006 Implement support for __str__ and __repr__ special methods in classes. 2014-03-16 15:18:22 +02:00
Damien George
536dde254b py: In string.count, handle case of zero-length needle. 2014-03-13 22:07:55 +00:00
xbe
c5d70ba48b Fix issues in str.count implementation.
See pull request #343.
2014-03-13 00:33:07 -07:00
xbe
9e1e8cd642 Implement str.count and add tests for it.
Also modify mp_get_index to accept:
1. Indices that are or evaluate to a boolean.
2. Slice indices.
Add tests for these two cases.
2014-03-12 22:57:16 -07:00
Damien George
b068b21742 Add more tests for multi-precision integers. 2014-03-12 15:39:51 +00:00
Damien George
25f5a30e73 py: Fix overriding of default arguments.
Addresses issue #327.
2014-03-03 23:25:08 +00:00
Paul Sokolovsky
e74f52b76c namedtuple: Inherit unary/binary ops from tuple base class. 2014-03-03 11:42:53 +08:00
Paul Sokolovsky
d08fd68664 Add basic collections.namedtuple implementation. 2014-03-03 11:42:53 +08:00
Damien George
06201ff3d6 py: Implement bit-shift and not operations for mpz.
Implement not, shl and shr in mpz library.  Add function to create mpzs
on the stack, used for memory efficiency when rhs is a small int.
Factor out code to parse base-prefix of number into a dedicated function.
2014-03-01 19:50:50 +00:00
Paul Sokolovsky
135002a086 Add basic super() test. 2014-02-22 20:25:05 +02:00
Paul Sokolovsky
56e5ef203b parse: Refactor parse node encoding to support full range of small ints.
Based on suggestion by @dpgeorge at
https://github.com/micropython/micropython/pull/313
2014-02-22 16:39:45 +02:00
Paul Sokolovsky
fb7f94392d import: Implement "from pkg.mod import sym" syntax properly.
http://docs.python.org/3.3/library/functions.html#__import__ :
"When the name variable is of the form package.module, normally, the
top-level package (the name up till the first dot) is returned, not
the module named by name. However, when a non-empty fromlist argument
is given, the module named by name is returned."
2014-02-20 00:37:12 +02:00
Paul Sokolovsky
ac2e28c654 Support passing positional args as keywords to bytecode functions.
For this, record argument names along with each bytecode function. The code
still includes extensive debug logging support so far.
2014-02-16 18:36:33 +02:00
Paul Sokolovsky
1b694c082e Rename fun-kwargs.py -> fun-kwvarargs.py to free up slot for simple kw test. 2014-02-16 15:55:06 +02:00
Paul Sokolovsky
91ba7a54c5 builtinimport: Get the basic (and only basic) package imports work. 2014-02-16 02:55:46 +02:00
Damien George
e5d371b545 py: Pass keyword arguments to byte code. 2014-02-16 00:17:42 +00:00
Damien George
2e482cdb7b py: Implement *vargs support.
Addresses issue #295.
2014-02-16 00:01:29 +00:00
Damien George
c8f78bc280 py: VM never throws an exception, instead returns a status and value.
Addresses issue #290, and hopefully sets up things to allow generators
throwing exceptions, etc.
2014-02-15 22:55:00 +00:00
Paul Sokolovsky
8ac72b9d00 Add testcase for failing namespace switch throwing exception from a module.
Issue #290. This currently fails, to draw attention to the issue.
2014-02-15 12:44:29 +02:00