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
0c937fa25a
objobject: Fix arguments to __init__().
2014-05-21 23:10:48 +03:00
Damien George
90886807a1
Merge branch 'master' of github.com:micropython/micropython
2014-05-21 20:35:02 +01:00
Damien George
58ebde4664
Tidy up some configuration options.
...
MP_ALLOC_* -> MICROPY_ALLOC_*
MICROPY_PATH_MAX -> MICROPY_ALLOC_PATH_MAX
MICROPY_ENABLE_REPL_HELPERS -> MICROPY_HELPER_REPL
MICROPY_ENABLE_LEXER_UNIX -> MICROPY_HELPER_LEXER_UNIX
MICROPY_EXTRA_* -> MICROPY_PORT_*
See issue #35 .
2014-05-21 20:32:59 +01: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
Paul Sokolovsky
6a410789b8
objtype: super: Add stop condition for looking up in base types.
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
Damien George
6ac5dced24
py: Rename MP_OBJ_NOT_SUPPORTED to MP_OBJ_NULL.
...
See issue #608 for justification.
2014-05-21 19:42:43 +01:00
Paul Sokolovsky
053765414c
modstruct: struct_calcsize: Fix case of uninitialized var.
2014-05-20 16:34:05 +03:00
Paul Sokolovsky
9e29666bf9
py: Implement proper separation between io.FileIO and io.TextIOWrapper.
...
io.FileIO is binary I/O, ans actually optional. Default file type is
io.TextIOWrapper, which provides str results. CPython3 explicitly describes
io.TextIOWrapper as buffered I/O, but we don't have buffering support yet
anyway.
2014-05-19 21:56:07 +03:00
Paul Sokolovsky
52386cafa0
objexcept: Implement explicit __init__ method, useful for subclasses.
2014-05-19 21:56:07 +03:00
Paul Sokolovsky
13684fd60b
objtype: Separate __new__ and __init__ methods.
...
Now schedule is: for native types, we call ->make_new() C-level method, which
should perform actions of __new__ and __init__ (note that this is not
compliant, but is efficient), but for user types, __new__ and __init__ are
called as expected.
Also, make sure we convert scalar attribute value to a bound-pair tight in
mp_obj_class_lookup() method, which avoids converting it again and again in
its callers.
2014-05-19 21:56:06 +03:00
Sven Wegener
7ba0fedf13
py: Fix mp_obj_t -> mp_const_obj_t for mp_obj_int_get_checked()
...
Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
2014-05-17 11:21:12 +02:00
Paul Sokolovsky
bf27140193
py: More mp_identity usage.
2014-05-17 11:20:10 +03:00
Paul Sokolovsky
ab7bf28489
py: More const usage.
2014-05-17 11:20:10 +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
a47b64ae2d
objstringio: Implement io.BytesIO.
...
Done in generalized manner, allowing any stream class to be specified as
working with bytes.
2014-05-15 07:28:19 +03:00
Paul Sokolovsky
2a27365854
objstr.c: Partial implementation of .rsplit().
...
sep=None is TODO.
2014-05-14 02:42:20 +03:00
Damien George
51fab28e94
py: Improve mpz_and function.
...
This should now have correct (and optimal) behaviour.
2014-05-13 22:58:00 +01:00
Paul Sokolovsky
da9f0924ef
py, unix: Add copyright for modules I worked closely on.
2014-05-13 18:41:25 +03:00
Damien George
561e425903
py: Fix bug in mpz_and function.
...
Addresses issue #610 .
2014-05-12 23:27:29 +01:00
Damien George
915197a8f9
py: Remove emit_glue init and deinit. Needed only for debugging.
...
Debugging output for emit_glue now simplified so that the init and
deinit functions are no longer needed.
2014-05-12 23:11:14 +01:00
Damien George
97f9a2813e
py: Add support for __debug__ constant.
...
__debug__ now resolves to True or False. Its value needs to be set by
mp_set_debug().
TODO: call mp_set_debug in unix/ port.
TODO: optimise away "if False:" statements in compiler.
2014-05-12 23:07:34 +01:00
Damien George
96f137b24a
py: Rename BYTE_CODE to BYTECODE (this was missed in previous rename).
2014-05-12 22:35:37 +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
da1fffaa09
Fix some unused variables, and silence a clang warning about initialization override in vmentrytable.h
2014-05-12 09:06:18 +02:00
Antonin ENFRUN
6caae0bcb1
unix: Create __bss_start and _end symbols for Mach-O targets.
...
It's a hack, but can't find a cleaner way to do it.
2014-05-12 00:13:10 +02:00
Paul Sokolovsky
147c80bf7c
modstruct: Use MP_OBJ_FUN_ARGS_MAX instead of -1.
2014-05-11 22:50:27 +03: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
7e7940c39d
py: Fix __len__ special method result handling.
...
Having both MP_OBJ_NOT_SUPPORTED and MP_OBJ_NULL is arguably confusing.
2014-05-11 20:51:31 +03:00
Paul Sokolovsky
c48d6f7add
py: Don't expect that type->getiter() always returns iterator, check for NULL.
...
This is better than forcing each getiter() implementation to raise exception.
2014-05-11 20:51:31 +03:00
Paul Sokolovsky
0f570cfccf
showbc: Decode MAP_ADD.
2014-05-11 20:51:31 +03:00
Paul Sokolovsky
ff30666c69
py: Add basic implementation of hasattr() function.
2014-05-11 20:51:30 +03:00
Damien George
ee7a880d6e
py: Use mp_arg_check_num in more places.
...
Updated functions now do proper checking that n_kw==0, and are simpler
because they don't have to explicitly raise an exception. Down side is
that the error messages no longer include the function name, but that's
acceptable.
Saves order 300 text bytes on x64 and ARM.
2014-05-11 18:37:21 +01:00
Damien George
1d34e32431
py: frozenset() creates an empty frozenset.
2014-05-11 18:28:48 +01:00
Damien George
2323ef9182
py: Rename globally-accessible tuple functions, prefix with mp_obj_.
...
Likely there are other functions that should be renamed, but this is a
start.
2014-05-11 18:00:45 +01:00
Damien George
c59af52e84
py: Rename some unichar functions for consistency.
2014-05-11 17:53:11 +01:00
Damien George
89755ae67f
py: Rename MICROPY_SYS_EXIT to MICROPY_MOD_SYS_EXIT.
...
For consistency with MICROPY_MOD_SYS_STDFILES, etc.
2014-05-11 17:35:43 +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
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
285683d203
objboundmeth: If detailed reporting enabled, print object content.
...
Similar to closure and cell.
2014-05-11 02:27:42 +03:00
Paul Sokolovsky
7aca1cae34
py: Start making good use of mp_const_obj_t.
2014-05-11 02:26:42 +03:00
Paul Sokolovsky
3f8d34ca83
objlist: Support list slice deletion.
2014-05-10 23:03:30 +03:00