summaryrefslogtreecommitdiff
path: root/py
AgeCommit message (Collapse)Author
2019-02-20py/objfun: Make fun_data arg of mp_obj_new_fun_asm() a const pointer.Damien George
2019-02-20py/obj.h: Remove obsolete mp_obj_new_fun_viper() declaration.Damien George
2019-02-19py/qstr: Evaluate find_qstr only once then pass to Q_GET_HASH macro.Damien George
Q_GET_HASH may evaluate its argument more than once.
2019-02-14extmod/moduwebsocket: Refactor `websocket` to `uwebsocket`.Yonatan Goldschmidt
As mentioned in #4450, `websocket` was experimental with a single intended user, `webrepl`. Therefore, we'll make this change without a weak link `websocket` -> `uwebsocket`.
2019-02-12py/mkenv.mk: Change default PYTHON variable from "python" to "python3".Damien George
This change makes it so that python3 is required by default to build MicroPython. Python 2 can be used by specifying make PYTHON=python2. This comes about due to a recent-ish change to PEP 394 that makes the python command more optional than before (even with Python 2 installed); see https://github.com/python/peps/commit/cd59ec03c8ff1e75089d5872520cd0706774b35b#diff-1d22f7bd72cbc900670f058b1107d426 Since the command python is no longer required to be provided by a distribution we need to use either python2 or python3 as commands. And python3 seems the obvious choice.
2019-02-12py: Downcase MP_xxx_SLOT_IS_FILLED inline functions.Damien George
2019-02-12py: Downcase all MP_OBJ_IS_xxx macros to make a more consistent C API.Damien George
These macros could in principle be (inline) functions so it makes sense to have them lower case, to match the other C API functions. The remaining macros that are upper case are: - MP_OBJ_TO_PTR, MP_OBJ_FROM_PTR - MP_OBJ_NEW_SMALL_INT, MP_OBJ_SMALL_INT_VALUE - MP_OBJ_NEW_QSTR, MP_OBJ_QSTR_VALUE - MP_OBJ_FUN_MAKE_SIG - MP_DECLARE_CONST_xxx - MP_DEFINE_CONST_xxx These must remain macros because they are used when defining const data (at least, MP_OBJ_NEW_SMALL_INT is so it makes sense to have MP_OBJ_SMALL_INT_VALUE also a macro). For those macros that have been made lower case, compatibility macros are provided for the old names so that users do not need to change their code immediately.
2019-02-06py/mpconfig.h: Fix comments mentioning dangling file and variable names.Yonatan Goldschmidt
2019-02-06py/builtinhelp: Only print help re FS modules if external import enabledYonatan Goldschmidt
2019-02-06py: Update my copyright info on some files.Paul Sokolovsky
Based on git history.
2019-01-31py/warning: Support categories for warnings.Paul Sokolovsky
Python defines warnings as belonging to categories, where category is a warning type (descending from exception type). This is useful, as e.g. allows to disable warnings selectively and provide user-defined warning types. So, implement this in MicroPython, except that categories are represented just with strings. However, enough hooks are left to implement categories differently per-port (e.g. as types), without need to patch each and every usage.
2019-01-27py/compile: Swap order of pop_block/pop_except in "except as" handler.Damien George
To make the try-finally block self contained.
2019-01-27py: Add optional support for 2-argument version of built-in next().stijn
Configurable via MICROPY_PY_BUILTINS_NEXT2, disabled by default.
2019-01-27py: Remove calls to file reader functions when these are disabled.Sean Burton
If MICROPY_PERSISTENT_CODE_LOAD or MICROPY_ENABLE_COMPILER are enabled then code gets enabled that calls file reading functions which may be disabled if no readers have been implemented. To fix this, introduce a MICROPY_HAS_FILE_READER variable, which is automatically set if MICROPY_READER_POSIX or MICROPY_READER_VFS is set but can also be manually set if a custom reader is being implemented. Then disable the file reading calls if this is not set.
2019-01-26all: Bump version to 1.10.v1.10Damien George
2019-01-26py/mpconfig.h: Remove parentheses from MICROPY_VERSION_xxx macros.Damien George
Otherwise MICROPY_VERSION_STRING includes these parentheses in the string.
2019-01-25py/obj.h: Explicitly cast args to uint32_t in MP_OBJ_FUN_MAKE_SIG.Damien George
For architectures where size_t is less than 32 bits (eg 16 bits) the args must be casted to uint32_t so the left shift will work. For architectures where size_t is greater than 32 bits (eg 64 bits) this new casting will not lose any bits because the end result must anyway fit in a uint32_t.
2019-01-10py/modio: Make iobase_singleton object const so it goes in ROM.Damien George
2019-01-04py: Fix location of VM returned exception in invalid opcode and commentsDamien George
The location for a returned exception was changed to state[0] in d95947b48a30f818638c3619b92110ce6d07f5e3
2019-01-04py: Get optional VM stack overflow check compiling and working again.Damien George
Changes to the layout of the bytecode header meant that this debug code was no longer compiling. This is now fixed and a new compile-time option is introduced, MICROPY_DEBUG_VM_STACK_OVERFLOW, to turn on this feature (which is disabled by default). This option is needed because more than one file needs to cooperate to make this check work.
2018-12-27py/runtime: Unlock the GIL in mp_deinit function.Damien George
This mirrors what is done in mp_init. Some RTOSs require this symmetry to get back to a clean state (when doing a soft reset, for example).
2018-12-22py/mpconfig: Move MICROPY_VERSION macros to static ones in mpconfig.h.Damien George
It's more robust to have the version defined statically in a header file, rather than dynamically generating it via git using a git tag. In case git doesn't exist, or a different source control tool is used, it's important to still have the uPy version number available.
2018-12-20py/gc: Adjust gc_alloc() signature to be able to accept multiple flags.Paul Sokolovsky
The older "bool has_finaliser" gets recast as GC_ALLOC_FLAG_HAS_FINALISER=1 so this is a backwards compatible change to the signature. Since bool gets implicitly converted to 1 this patch doesn't include conversion of all calls.
2018-12-20py/objarray: Introduce "memview_offset" alias for "free" field of objectPaul Sokolovsky
Both mp_type_array and mp_type_memoryview use the same object structure, mp_obj_array_t, but for the case of memoryview, some fields, e.g. "free", have different meaning. As the "free" field is also a bitfield, assume that (anonymous) union can't be used here (for the concerns of possible compatibility issues with wide array of toolchains), and just add a field alias using a #define. As it's a define, it should be a selective identifier, so use verbose "memview_offset" to avoid any clashes.
2018-12-15py/qstr: Put a lower bound on new qstr pool allocation.Damien George
2018-12-13py/bc: Fix calculation of opcode size for opcodes with map caching.Damien George
All 4 opcodes that can have caching bytes also have qstrs, so the test for them must go in the qstr part of the code. The reason this incorrect calculation of the opcode size did not lead to a bug is because the caching byte is at the end of the opcode (byte, qstr, qstr, cache) and is always 0x00 when saving/loading, so was just treated as a single byte no-op opcode. Hence these opcodes were being saved/loaded/decoded correctly. Thanks to @malinah for finding the problem and providing the initial patch.
2018-12-13py/objdict: Make .fromkeys() method configurable.Paul Sokolovsky
On by default, turned off for minimal/bare-arm. Saves 144 bytes on x86.
2018-12-10py/objexcept: Make sure mp_obj_new_exception_msg doesn't copy/format msgDamien George
mp_obj_new_exception_msg() assumes that the message passed to it is in ROM and so can use its data directly to create the string object for the argument of the exception, saving RAM. At the same time, this approach also makes sure that there is no attempt to format the message with printf, which could lead to faults if the message contained % characters. Fixes issue #3004.
2018-12-10py/objexcept: Use macros to make offsets in emergency exc buf clearer.Damien George
2018-12-10extmod/moductypes: Add aliases for native C types.Paul Sokolovsky
SHORT, INT, LONG, LONGLONG, and unsigned (U*) variants are being defined. This is done at compile using GCC-style predefined macros like __SIZEOF_INT__. If the compiler doesn't have such defines, no such types will be defined.
2018-12-07py/obj: Add support for __int__ special method.Paul Sokolovsky
Based on the discussion, this special method is available unconditionally, as converting to int is a common operation.
2018-12-06py/objboundmeth: Support loading generic attrs from the method.Damien George
Instead of assuming that the method is a bytecode object, and only supporting load of __name__, make the operation generic by delegating the load to the method object itself. Saves a bit of code size and fixes the case of attempting to load __name__ on a native method, see issue #4028.
2018-12-04py: Add option to reduce GC stack integer size to save RAM.Ayke van Laethem
A new option MICROPY_GC_STACK_ENTRY_TYPE is added to select a custom type instead of size_t for the gc_stack array items. This can be beneficial for small devices, especially those that are low on memory anyway. If a device has 1MB or less of heap (and 16-byte GC blocks) then this type can be uint16_t, saving 128 bytes of RAM.
2018-12-04py/py.mk: Fix broken Gmane URL.Craig Younkins
2018-11-26py/unicode: Fix check for valid utf8 being stricter about contn chars.Damien George
2018-11-01py/runtime: Fix qstr assumptions when handling "import *".Paul Sokolovsky
There was an assumption that all names in a module dict are qstr's. However, they can be dynamically generated (by assigning to globals()), and in case of a long name, it won't be a qstr. Handle this situation properly, including taking care of not creating superfluous qstr's for names starting with "_" (which aren't imported by "import *").
2018-10-28py/scope: Optimise scope_find_or_add_id to not need "added" arg.Damien George
Taking the address of a local variable is mildly expensive, in code size and stack usage. So optimise scope_find_or_add_id() to not need to take a pointer to the "added" variable, and instead take the kind to use for newly added identifiers.
2018-10-28py/compile: Remove unneeded variable from global/nonlocal stmt helpers.Damien George
2018-10-28py/compile: Fix case of eager implicit conversion of local to nonlocal.Damien George
This ensures that implicit variables are only converted to implicit closed-over variables (nonlocals) at the very end of the function scope. If variables are closed-over when first used (read from, as was done prior to this commit) then this can be incorrect because the variable may be assigned to later on in the function which means they are just a plain local, not closed over. Fixes issue #4272.
2018-10-27py/py.mk: When building axtls use -Wno-all to prevent all warnings.Damien George
Building axtls gives a lot of warnings with -Wall enabled, and explicitly disabling all of them cannot be done in a way compatible with gcc and clang, and likely other compilers. So just use -Wno-all to prevent all of the extra warnings (in addition to the necessary -Wno-unused-parameter, -Wno-uninitialized, -Wno-sign-compare and -Wno-old-style-definition). Fixes issue #4182.
2018-10-23py/objmodule: Implement PEP 562's __getattr__ for modules.Paul m. p. P
Configurable via MICROPY_MODULE_GETATTR, disabled by default. Among other things __getattr__ for modules can help to build lazy loading / code unloading at runtime.
2018-10-22py/objstr: Make str.count() method configurable.Paul Sokolovsky
Configurable via MICROPY_PY_BUILTINS_STR_COUNT. Default is enabled. Disabled for bare-arm, minimal, unix-minimal and zephyr ports. Disabling it saves 408 bytes on x86.
2018-10-18py/objtype: Remove comment about catching exc from user __getattr__.Damien George
Any exception raised in a user __getattr__ should be propagated out. A test is added to verify these semantics.
2018-10-15py/emitnative: Put None/False/True in global native const table.Damien George
So these constant objects can be loaded by dereferencing the REG_FUN_TABLE pointer instead of loading immediate values. This reduces the size of generated native code (when such constants are used), and means that pointers to these constants are no longer stored in the assembly code.
2018-10-15py/emitnative: Push internal None rather than const obj where possible.Damien George
This shifts the work of loading the constant None object on to load_reg_stack_imm(), making the handling of None more centralised.
2018-10-15py/emitnative: Simplify viper mode handling in emit_native_import_name.Damien George
2018-10-15py/emitnative: Consolidate use of stacked immediate values to one func.Damien George
This commit adds the helper function load_reg_stack_imm() which deals with constant immediate values and converting them to Python objects if needed.
2018-10-13py/emitnative: Remove unused ptr argument from ASM_CALL_IND macro.Damien George
2018-10-13py/asmthumb: Remove unused fun_ptr arg from asm_thumb_bl_ind function.Damien George
2018-10-13py/asmarm: Simplify asm_arm_bl_ind to only load via index, not literal.Damien George
The maximum index into mp_fun_table is currently less than 1024 and should stay that way to keep things efficient for all architectures, so there is no need to handle loading the pointer directly via a literal in this function.