Commit Graph

546 Commits

Author SHA1 Message Date
Damien George
af43565322 tests: Add tests for things that are not already tested.
The aim here is to improve coverage of the code.
2015-03-12 22:48:45 +00:00
Peter D. Gray
b2a237d337 py: Add support for start/stop/step attributes of builtin range object. 2015-03-11 20:02:06 +00:00
Damien George
086a7616dd tests: Add tests for boundmeth; and bignum cmp, unary, float, error. 2015-03-03 16:45:39 +00:00
Damien George
f2a889564b tests: Add basics test for gc module. 2015-03-02 18:30:17 +00:00
Damien George
fe3da09fa0 tests: Use range as iterable instead of list comprehension.
So that navite emitter passes (comprehensions use yield which is not yet
supported by native emitter).
2015-03-02 17:55:55 +00:00
Damien George
24ffb8e876 tests: Add tests for builtins: all, any, sum, abs. 2015-03-02 17:21:10 +00:00
Damien George
2af921fb51 tests: Add tests for op special meths, ubinascii, complex. 2015-03-02 12:47:44 +00:00
Paul Sokolovsky
992284be39 tests: Add test for array slice assignment. 2015-02-27 22:17:24 +02:00
Damien George
ed8b4da0db tests: Remove obsolete test; don't use fp in micropython/ tests. 2015-02-15 01:57:39 +00:00
Damien George
f6532bb9e0 py: Simplify and remove redundant code for __iter__ method lookup. 2015-02-15 01:10:13 +00:00
stijn
c1832fd206 py: Add setattr builtin. 2015-02-14 23:35:00 +00:00
Damien George
48244044a2 py: Allow subclass of native object to delegate to the native buffer_p.
Addresses issue #1109.
2015-02-09 15:08:00 +00:00
Paul Sokolovsky
194117a066 objstr: Fix bytes creation from array of long ints. 2015-02-09 12:11:49 +08:00
Damien George
7d414a1b52 py: Parse big-int/float/imag constants directly in parser.
Previous to this patch, a big-int, float or imag constant was interned
(made into a qstr) and then parsed at runtime to create an object each
time it was needed.  This is wasteful in RAM and not efficient.  Now,
these constants are parsed straight away in the parser and turned into
objects.  This allows constants with large numbers of digits (so
addresses issue #1103) and takes us a step closer to #722.
2015-02-08 01:57:40 +00:00
Damien George
744e767458 py: Make list.sort keep stack usage within O(log(N)) bound.
Also fix list.sort so it works with user-defined types, and parse the
keyword arguments properly.

Addresses issue #338.
2015-02-02 15:14:22 +00:00
Damien George
32bade19d9 py: Convert CR to LF and CR LF to LF in lexer.
Only noticeable difference is how newlines are encoded in triple-quoted
strings.  The behaviour now matches CPython3.
2015-01-30 00:27:46 +00:00
Damien George
92ab95f215 tests: Add some tests to improve coverage. 2015-01-29 14:56:09 +00:00
Damien George
12c66be2b8 tests: Add some tests to improve coverage.
Used gcov to find some parts of vm.c, runtime.c, obj.c that were not
covered by any tests.  Still need to use gcov more thoroughly.
2015-01-29 00:44:11 +00:00
Paul Sokolovsky
57aebe1714 tests: Add testcase for bytes() on values in range 128-255. 2015-01-28 22:29:51 +02:00
Damien George
a9dc9b8f6d py: Fix comparison of minus-zero long int. 2015-01-27 17:47:38 +00:00
Damien George
962a5d50c9 py: Implement __reversed__ slot.
Addresses issue #1073.
2015-01-21 00:19:42 +00:00
Damien George
1e1779eacf py: Reluctantly add an extra pass to bytecode compiler.
Bytecode also needs a pass to compute the stack size.  This is because
the state size of the bytecode function is encoded as a variable uint,
so we must know the value of this uint before we encode it (otherwise
the size of the generated code changes from one pass to the next).

Having an entire pass for this seems wasteful (in time).  Alternative is
to allocate fixed space for the state size (would need 3-4 bytes to be
general, when 1 byte is usually sufficient) which uses a bit of extra
RAM per bytecode function, and makes the code less elegant in places
where this uint is encoded/decoded.

So, for now, opt for an extra pass.
2015-01-14 00:20:28 +00:00
Damien George
4c81ba8015 py: Never intern data of large string/bytes object; add relevant tests.
Previously to this patch all constant string/bytes objects were
interned by the compiler, and this lead to crashes when the qstr was too
long (noticeable now that qstr length storage defaults to 1 byte).

With this patch, long string/bytes objects are never interned, and are
referenced directly as constant objects within generated code using
load_const_obj.
2015-01-13 16:21:23 +00:00
Damien George
c38dc3ccc7 py: Implement fallback for equality check for all types.
Return "not equal" for objects that don't implement equality check.
This is as per Python specs.
2015-01-11 15:13:18 +00:00
Damien George
c33ecb83ba tests: Add test for when instance member overrides class member. 2015-01-08 17:48:44 +00:00
Damien George
19b3fea6a8 tests: Separate out test cases that rely on float support to float/ dir. 2015-01-08 15:41:37 +00:00
Paul Sokolovsky
343ca1e63a objarray: Make sure that longint works as bytearray size. 2015-01-04 17:19:16 +02:00
Paul Sokolovsky
c114496641 objstr: Implement kwargs support for str.format(). 2015-01-04 00:26:31 +02:00
stijn
021dc44009 py: Allow keyword arguments for namedtuple 2015-01-01 14:53:23 +02:00
stijn
12340147b0 py: Use sequence of strings for named tuple initialization
- remove single string initialization style
- take list of strings instead
- store list in the type for fast lookup
2015-01-01 14:53:23 +02:00
Damien George
e0ac194f4f py: Fix rshift and not of zero/one edge cases in mpz.
Addresses issue #1027.
2014-12-31 19:35:01 +00:00
Damien George
c55a4d82cf py: Make bytes objs work with more str methods; add tests. 2014-12-24 20:28:30 +00:00
Damien George
e181c0dc07 py: Fix optimised for-loop compiler so it follows proper semantics.
You can now assign to the range end variable and the for-loop still
works correctly.  This fully addresses issue #565.

Also fixed a bug with the stack not being fully popped when breaking out
of an optimised for-loop (and it's actually impossible to write a test
for this case!).
2014-12-12 17:19:56 +00:00
Damien George
5fba93a26b tests: Add test for semantics of for-loop that optimisation can break. 2014-12-11 17:40:41 +00:00
Damien George
78d702c300 py: Allow builtins to be overridden.
This patch adds a configuration option (MICROPY_CAN_OVERRIDE_BUILTINS)
which, when enabled, allows to override all names within the builtins
module.  A builtins override dict is created the first time the user
assigns to a name in the builtins model, and then that dict is searched
first on subsequent lookups.  Note that this implementation doesn't
allow deleting of names.

This patch also does some refactoring of builtins code, creating the
modbuiltins.c file.

Addresses issue #959.
2014-12-09 16:19:48 +00:00
Damien George
be6d8be91e py: Rename mp_obj_int_get to mp_obj_int_get_truncated; fix struct.pack.
mp_obj_int_get_truncated is used as a "fast path" int accessor that
doesn't check for overflow and returns the int truncated to the machine
word size, ie mp_int_t.

Use mp_obj_int_get_truncated to fix struct.pack when packing maximum word
sized values.

Addresses issues #779 and #998.
2014-12-05 23:13:52 +00:00
Damien George
32ef3a3517 py: Allow bytes/bytearray/array to be init'd by buffer protocol objects.
Behaviour of array initialisation is subtly different for bytes,
bytearray and array.array when argument has buffer protocol.  This patch
gets us CPython conformant (except we allow initialisation of
array.array by buffer with length not a multiple of typecode).
2014-12-04 15:46:14 +00:00
Damien George
b2e731177e py: Implement +, += and .extend for bytearray and array objs.
Addresses issue #994.
2014-11-30 00:00:55 +00:00
Damien George
7288403b9b tests: Split out float test from builtin_round.py. 2014-11-29 14:47:54 +00:00
Damien George
4df85e49d4 tests: Add test for hash of user defined class. 2014-11-15 18:30:01 +00:00
Damien George
a65c03c6c0 py: Allow +, in, and compare ops between bytes and bytearray/array.
Eg b"123" + bytearray(2) now works.  This patch actually decreases code
size while adding functionality: 32-bit unix down by 128 bytes, stmhal
down by 84 bytes.
2014-11-05 16:30:34 +00:00
Damien George
0344fa1ddf py: Fix builtin callable so it checks user-defined instances correctly.
Addresses issue #953.
2014-11-03 16:09:39 +00:00
Paul Sokolovsky
039887a0ac py: Fix bug with right-shifting small ints by large amounts.
Undefined behavior in C, needs explicit check.
2014-11-02 02:41:30 +02:00
Damien George
1559a97810 py: Add builtin round function.
Addresses issue #934.
2014-10-31 11:28:50 +00:00
Paul Sokolovsky
e62a0fe367 objstr: Allow to convert any buffer proto object to str.
Original motivation is to support converting bytearrays, but easier to just
support buffer protocol at all.
2014-10-31 00:03:53 +02:00
Damien George
b2f19b8d34 tests: Get builtin_compile to skin properly on pyboard. 2014-10-26 15:38:28 +00:00
Damien George
de3c806965 py: Fix memoryview referencing so it retains ptr to original buffer.
This way, if original parent object is GC'd, the memoryview still points
to the underlying buffer data so that buffer is not GC'd.
2014-10-26 13:20:50 +00:00
Damien George
627852019b tests: Add test for compile builtin. 2014-10-25 22:07:25 +01:00
Damien George
dd4f4530ab py: Add builtin memoryview object (mostly using array code). 2014-10-23 13:34:35 +01:00
Damien George
e72be1b999 py: Fix smallint modulo with negative arguments.
Addresses issue #927.
2014-10-22 23:05:50 +01:00
Damien George
e7a478204a py: Remove unused and unneeded SystemError exception.
It's purpose is for internal errors that are not catastrophic (ie not as
bad as RuntimeError).  Since we don't use it, we don't need it.
2014-10-22 19:42:55 +01:00
Damien George
391db8669b py: Add more compiler optimisations for constant if/while conditions. 2014-10-17 17:57:33 +00:00
Damien George
9870fdd4b0 tests: Add test for nested while with exc and break. 2014-10-17 17:28:25 +00:00
Paul Sokolovsky
067ae1269d objclosure: Fix printing of generator closures.
The code previously assumed that only functions can be closed over.
2014-10-16 00:14:01 +03:00
Damien George
a91ac2011f py: Make compiler return a proper exception on SyntaxError. 2014-10-05 19:01:34 +01:00
Damien George
8b03d944e2 py: Remove IOError since it's deprecated; use OSError instead.
In CPython IOError (and EnvironmentError) is deprecated and aliased to
OSError.  All modules that used to raise IOError now raise OSError (or a
derived exception).

In Micro Python we never used IOError (except 1 place, incorrectly) and
so don't need to keep it.

See http://legacy.python.org/dev/peps/pep-3151/ for background.
2014-09-30 13:59:30 +00:00
Damien George
2234c3f23d tests: Add test for exception matching of a tuple of exceptions. 2014-09-25 15:49:26 +01:00
Damien George
d6230f62c7 py: Make native emitter handle multi-compare and not/is not/not in ops. 2014-09-23 14:15:45 +00:00
Damien George
96e20c600f tests: Fix uctypes tests to run on 64bit arch; enable more native tests. 2014-09-23 14:15:45 +00:00
Damien George
9a21d2e070 py: Make mpz able to use 16 bits per digit; and 32 on 64-bit arch.
Previously, mpz was restricted to using at most 15 bits in each digit,
where a digit was a uint16_t.

With this patch, mpz can use all 16 bits in the uint16_t (improvement
to mpn_div was required).  This gives small inprovements in speed and
RAM usage.  It also yields savings in ROM code size because all of the
digit masking operations become no-ops.

Also, mpz can now use a uint32_t as the digit type, and hence use 32
bits per digit.  This will give decent improvements in mpz speed on
64-bit machines.

Test for big integer division added.
2014-09-06 17:15:34 +01:00
Damien George
02d95d7ce9 py: Fix 2 bugs in native emitter: jump_or_pop and stack settling.
Addresses issue #838.
2014-08-29 20:05:32 +01:00
Dave Hylands
b7f7c655ed Make int(b'123') work properly. 2014-08-26 19:15:04 -07:00
Damien George
779794a680 py: Add dispatch for user defined ==, >, <=, >=.
Addresses issue #827.
2014-08-26 09:31:26 +01:00
Damien George
7310fd469a py: Consolidate min/max functions into one, and add key= argument.
Addresses issue #811.
2014-08-24 19:14:09 +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
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
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
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
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
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
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
Dave Hylands
b69f9fa31f Fix str.modulo when precision is specified. 2014-06-05 23:09:02 -07:00
Chris Angelico
daf973ae00 Change comments (mainly URLs) to no longer specifically say Python 3.3 2014-06-06 03:51:03 +10: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
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
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
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
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
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
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
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
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
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
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
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
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
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