| Commit message (Collapse) | Author | Age |
|
|
|
|
|
|
| |
Now you can assign to the range variable within the for loop and it will
still work.
Partially addresses issue #565.
|
| |
|
|
|
|
| |
It's used by stmhal, but not unix.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
| |
The function is modeled after traceback.print_exception(), but unbloated,
and put into existing module to save overhead on adding another module.
Compliant traceback.print_exception() is intended to be implemented in
micropython-lib in terms of sys.print_exception().
This change required refactoring mp_obj_print_exception() to take pfenv_t
interface arguments.
Addresses #751.
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
| |
mp_lexer_t type is exposed, mp_token_t type is removed, and simple lexer
functions (like checking current token kind) are now inlined.
This saves 784 bytes ROM on 32-bit unix, 348 bytes on stmhal, and 460
bytes on bare-arm. It also saves a tiny bit of RAM since mp_lexer_t
is a bit smaller. Also will run a bit more efficiently.
|
|
|
|
|
|
|
| |
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).
|
|
|
|
|
| |
This makes no change to the generated code, but it's now easier to
understand since unum is not a "global" variable anymore.
|
|
|
|
| |
TODO: Merge useful functionality from modpyb too.
|
|
|
|
|
|
|
|
| |
By using the buffer protocol for these array operations, we now allow
addition of memoryview objects, and objects with "incompatible"
typecodes (in this case it just adds bytes naively). This is an
extension to CPython which seems sensible. It also reduces the code
size.
|
|
|
|
| |
Addresses issue #994.
|
|
|
|
|
| |
This is just a clean-up of the code. Generated code is exactly the
same.
|
| |
|
| |
|
|
|
|
| |
Previously, it truncated pointer value to 32 bits on 64-bit systems.
|
|
|
|
|
|
|
| |
Before, __repl_print__() used libc printf(), while print() used uPy streams
and own printf() implementation. This led to subtle, but confusing
differences in output when just doing "foo" vs "print(foo)" on interactive
prompt.
|
|
|
|
|
| |
Useful when need to call kw-receiving functions without any keywords
from C, etc.
|
| |
|
| |
|
|
|
|
| |
Addresses issue #981.
|
| |
|
|
|
|
| |
Also, implement for unix port.
|
|
|
|
|
|
| |
This is more efficient, as allows to use register calling convention.
If needed, a structure pointer can be passed as argument to pass more
data.
|
| |
|
|
|
|
|
|
|
|
|
| |
Currently compilation sporadically fails, because the automatic
dependency gets created *during* the compilation of objects.
OBJ is a auperset of PY_O and the dependencies apply to all objects.
Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
|
|
|
|
|
|
|
|
| |
Going from MICROPY_ERROR_REPORTING_NORMAL to
MICROPY_ERROR_REPORTING_TERSE now saves 2020 bytes ROM for ARM Thumb2,
and 2200 bytes ROM for 32-bit x86.
This is about a 2.5% code size reduction for bare-arm.
|
| |
|
|
|
|
|
|
| |
Else the directory might not exist.
Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
|
|
|
|
|
|
|
|
| |
When compiler optimization has been turned on, gcc knows that this code
block is not going to be executed. But with -O0 it complains about
path_items being used uninitialized.
Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
|
| |
|
|
|
|
|
|
| |
This turns failing assertions to type exceptions for things like
b"123".find(...). We still don't support operations like this on bytes
objects (unlike CPython), but at least it no longer crashes.
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
For this, introduce MICROPY_MODULE_DICT_SIZE config setting.
|
|
|
|
|
|
|
|
|
|
| |
Uninitialised struct members get a default value of 0/false, so this is
not strictly needed. But it actually decreases code size because when
all members are initialised the compiler doesn't need to insert a call
to memset to clear everything. In other words, setting 1 extra member
to 0 uses less code than calling memset.
ROM savings in bytes: 32-bit unix: 100; bare-arm: 44; stmhal: 52.
|
|
|
|
| |
Addresses issue #953.
|
|
|
|
| |
Undefined behavior in C, needs explicit check.
|
|
|
|
|
|
| |
gc.enable/disable are now the same as CPython: they just control whether
automatic garbage collection is enabled or not. If disabled, you can
still allocate heap memory, and initiate a manual collection.
|
|
|
|
| |
Addresses issue #934.
|
|
|
|
|
|
| |
msvc does not treat 1L a 64bit integer hence all occurences of shifting it left or right
result in undefined behaviour since the maximum allowed shift count for 32bit ints is 31.
Forcing the correct type explicitely, stored in MPZ_LONG_1, solves this.
|
|
|
|
|
| |
Original motivation is to support converting bytearrays, but easier to just
support buffer protocol at all.
|
|
|
|
|
|
|
| |
It should be fair to say that almost in all cases where some API call
expects string, it should be also possible to pass byte string. For example,
it should be open/delete/rename file with name as bytestring. Note that
similar change was done quite a long ago to mp_obj_str_get_data().
|
|
|
|
|
|
| |
Use it like:
make CFLAGS_EXTRA='-DMP_CONFIGFILE="<mpconfigport_my.h>"'
|
| |
|
|
|
|
| |
Also, move bytecode dumps to -v -v, because they're too verbose for just -v.
|
|
|
|
|
|
|
|
| |
Support for packages as argument not implemented, but otherwise error and
exit handling should be correct. This for example will allow to do:
pip-micropython install micropython-test.pystone
micropython -m test.pystone
|
|
|
|
|
| |
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.
|