summaryrefslogtreecommitdiffstatshomepage
path: root/py
Commit message (Collapse)AuthorAge
* builtinimport: add the module specified by -m to sys.modules as '__main__'Delio Brignoli2016-09-20
|
* py/showbc: Make printf's go to the platform print stream.Damien George2016-09-20
| | | | | | | | | The system printf is no longer used by the core uPy code. Instead, the platform print stream or DEBUG_printf is used. Using DEBUG_printf in the showbc functions would mean that the code can't be tested by the test suite, so use the normal output instead. This patch also fixes parsing of bytecode-line-number mappings.
* py/qstr: Remove a comment.Damien George2016-09-19
| | | | qstrs are always null terminated so qstr_str will stay as part of the API.
* py/objnone: Use mp_generic_unary_op instead of custom one.Damien George2016-09-19
|
* py/vstr: Remove vstr.had_error flag and inline basic vstr functions.Damien George2016-09-19
| | | | | | | | | | | | | | | | | | The vstr.had_error flag was a relic from the very early days which assumed that the malloc functions (eg m_new, m_renew) returned NULL if they failed to allocate. But that's no longer the case: these functions will raise an exception if they fail. Since it was impossible for had_error to be set, this patch introduces no change in behaviour. An alternative option would be to change the malloc calls to the _maybe variants, which return NULL instead of raising, but then a lot of code will need to explicitly check if the vstr had an error and raise if it did. The code-size savings for this patch are, in bytes: bare-arm:188, minimal:456, unix(NDEBUG,x86-64):368, stmhal:228, esp8266:360.
* py: Combine 3 comprehension opcodes (list/dict/set) into 1.Damien George2016-09-19
| | | | | | | | | With the previous patch combining 3 emit functions into 1, it now makes sense to also combine the corresponding VM opcodes, which is what this patch does. This eliminates 2 opcodes which simplifies the VM and reduces code size, in bytes: bare-arm:44, minimal:64, unix(NDEBUG,x86-64):272, stmhal:92, esp8266:200. Profiling (with a simple script that creates many list/dict/set comprehensions) shows no measurable change in performance.
* py: Combine 3 comprehension emit functions (list/dict/set) into 1.Damien George2016-09-19
| | | | | | The 3 kinds of comprehensions are similar enough that merging their emit functions reduces code size. Decreases in code size in bytes are: bare-arm:24, minimal:96, unix(NDEBUG,x86-64):328, stmhal:80, esp8266:76.
* py: Move frozen modules rules from esp8266 port for reuse across ports.Paul Sokolovsky2016-09-17
| | | | | A port now just needs to define FROZEN_DIR var and add $(BUILD)/frozen.c to SRC_C to support frozen modules.
* py/objnone: Remove unnecessary handling of MP_UNARY_OP_BOOL.Damien George2016-09-16
| | | | | | | | | bool(None) has a fast path in mp_obj_is_true so doesn't need to be handled in none_unary_op. The only caveat is that subclassing may bypass the mp_obj_is_true function, but actually you aren't allowed to subclass classes that have singleton instances like NoneType (see https://mail.python.org/pipermail/python-dev/2002-March/020822.html for reference on this point).
* py/makeqstrdefs.py: Use python 2.6 syntax for set creation.Chris Packham2016-09-09
| | | | | | | | | | | | | | py/makeqstrdefs.py declares that it works with python 2.6 however the syntax used to initialise of a set with values was only added in python 2.7. This leads to build failures when the host system doesn't have python 2.7 or newer. Instead of using the new syntax pass a list of initial values through set() to achieve the same result. This should work for python versions from at least 2.6 onwards. Helped-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: Chris Packham <judge.packham@gmail.com>
* py/asmthumb: Flush D-cache, and invalidate I-cache on STM32F7.Antonin ENFRUN2016-09-09
| | | | | | Tested on a STM32F7DISCO at 216MHz. All tests generating code (inlineasm, native, viper) now pass, except pybnative/while.py, but that's because there is no LED(2).
* py: Add MICROPY_USE_INTERNAL_PRINTF option, defaults to enabled.Delio Brignoli2016-09-05
| | | | | | | | This new config option allows to control whether MicroPython uses its own internal printf or not (if not, an external one should be linked in). Accompanying this new option is the inclusion of lib/utils/printf.c in the core list of source files, so that ports no longer need to include it themselves.
* py/emitglue.c: provide mp_raw_code_load_file for any unix architectureChris Packham2016-09-04
| | | | Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
* py: If str/bytes hash is 0 then explicitly compute it.Damien George2016-09-02
|
* py/makeqstrdata.py: Compute the qstr hash from bytes, not characters.Damien George2016-09-02
|
* py/mpprint: Fail an assertion with unsupported format specifiers.Delio Brignoli2016-09-01
| | | | | | Arguments of an unknown type cannot be skipped and continuing to parse a format string after encountering an unknown format specifier leads to undefined behaviour. This patch helps to find use of unsupported formats.
* extmod: Add machine_spi with generic SPI C-protocol and helper methods.Damien George2016-09-01
| | | | | | | The idea is that all ports can use these helper methods and only need to provide initialisation of the SPI bus, as well as a single transfer function. The coding pattern follows the stream protocol and helper methods.
* py/mkrules.mk: Allow to override name of libmicropython.aPaul Sokolovsky2016-08-30
| | | | | Or alternatively, refer to an exact library file, not just phony target "lib".
* py/bc.h: Rename _mp_code_state to _mp_code_state_t.Damien George2016-08-27
| | | | This rename was missed in the previous patch.
* py: Rename struct mp_code_state to mp_code_state_t.Damien George2016-08-27
| | | | Also at _t to mp_exc_stack pre-declaration in struct typedef.
* py/emitglue: Use more compact mp_raise_ValueError function.Damien George2016-08-26
|
* py/modstruct: Use more compact mp_raise_ValueError function.Damien George2016-08-26
| | | | Saves a few bytes of code size.
* py/compile: Don't compile assert statements when optimisations enabled.Damien George2016-08-26
| | | | As per CPython.
* py/gc: Add MICROPY_GC_CONSERVATIVE_CLEAR option to always zero memory.Damien George2016-08-26
| | | | | | | | | There can be stray pointers in memory blocks that are not properly zero'd after allocation. This patch adds a new config option to always zero all allocated memory (via gc_alloc and gc_realloc) and hence help to eliminate stray pointers. See issue #2195.
* extmod/modubinascii: Make crc32() support configurable.Paul Sokolovsky2016-08-24
| | | | Disable by default, enable in unix port.
* py/stream.c: use mp_obj_get_type in mp_get_stream_raiseKrzysztof Blazewicz2016-08-24
| | | | | | | | | | In current state `mp_get_stream_raise` assumes that `self_in` is an object and always performs a pointer derefence which may cause a segfault. This function shall throw an exception whenever `self_in` does not implement a stream protocol, that includes qstr's and numbers. fixes #2331
* py/sequence: Allow to use bignums as indices in slice objects.Damien George2016-08-15
| | | | See issue #2264.
* py/obj.h: For obj reprs A,B,C use void* explicitly for mp_obj_t typedef.Damien George2016-08-15
| | | | | | | | | The machine_ptr_t type is long obsolete as the type of mp_obj_t is now defined by the object representation, ie by MICROPY_OBJ_REPR. So just use void* explicitly for the typedef of mp_obj_t. If a port wants to use something different then they should define a new object representation.
* py/objstr: Use mp_raise_{Type,Value}Error instead of mp_raise_msg.Damien George2016-08-14
| | | | | This patch does further refactoring using the new mp_raise_TypeError and mp_raise_ValueError functions.
* py/runtime.h: Move comment about mp_not_implemented to correct place.Damien George2016-08-14
|
* py/objtuple: In tuple_cmp_helper, use mp_check_self instead of raising.Damien George2016-08-14
| | | | | | Only tuple, namedtuple and attrtuple use the tuple_cmp_helper function, and they all have getiter=mp_obj_tuple_getiter, so the check here is only to ensure that the self object is consistent. Hence use mp_check_self.
* py: Get rid of assert() in method argument checking functions.Paul Sokolovsky2016-08-12
| | | | | | Checks for number of args removes where guaranteed by function descriptor, self checking is replaced with mp_check_self(). In few cases, exception is raised instead of assert.
* py/objdict: Get rid of asserts (remove/replace with mp_check_self()).Paul Sokolovsky2016-08-12
|
* py/runtime.h: Define mp_check_self(pred) helper macro.Paul Sokolovsky2016-08-12
| | | | | | | Indended to replace raw asserts in bunch of files. Expands to empty if MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG is defined, otehrwise by default still to assert, though a particular port may define it to something else.
* py/runtime: Factor out exception raising helpers.Paul Sokolovsky2016-08-12
| | | | | | Introduce mp_raise_msg(), mp_raise_ValueError(), mp_raise_TypeError() instead of previous pattern nlr_raise(mp_obj_new_exception_msg(...)). Save few bytes on each call, which are many.
* py/mpconfig.h: Define MP_ALWAYSINLINE for reuse.Paul Sokolovsky2016-08-07
| | | | Similar to existing MP_NOINLINE.
* py/objstr,objstrunicode: Fix inconistent #if indentation.Paul Sokolovsky2016-08-07
|
* py/objstr: Make .partition()/.rpartition() methods configurable.Paul Sokolovsky2016-08-07
| | | | Default is disabled, enabled for unix port. Saves 600 bytes on x86.
* py/mkrules.mk: Allow to add more items for "clean" target using CLEAN_EXTRA.Paul Sokolovsky2016-08-04
|
* py/py.mk: Extra switches to build "embedded" BerkeleyDB BTree lib.Paul Sokolovsky2016-07-31
|
* py/mpconfig.h: Add MICROPY_STREAMS_POSIX_API setting.Paul Sokolovsky2016-07-30
| | | | | | To filter out even prototypes of mp_stream_posix_*() functions, which require POSIX types like ssize_t & off_t, which may be not available in some ports.
* lib/embed/abort_: Implementation of abort_() function raising uPy exception.Paul Sokolovsky2016-07-30
| | | | | | | Helpful when porting existing C libraries to MicroPython. abort()ing in embedded environment isn't a good idea, so when compiling such library, -Dabort=abort_ option can be given to redirect standard abort() to this "safe" version.
* py/stream: Add adapter methods with POSIX-compatible signatures.Paul Sokolovsky2016-07-30
| | | | | Previoussly such read() and write() methods were used by modussl_axtls, move to py/stream for reuse.
* py/objstringio: Implement MP_STREAM_SEEK ioctl and add seek() method.Paul Sokolovsky2016-07-28
|
* py/objstringio: Add MP_STREAM_FLUSH ioctl and flush() method.Paul Sokolovsky2016-07-28
| | | | No-op for this object.
* py/stream: Implement generic flush() method, in terms of C-level ioctl.Paul Sokolovsky2016-07-27
|
* py/stream: Stream module works with errno's, so should include mperrno.h.Paul Sokolovsky2016-07-26
|
* py/objstrunicode: str_index_to_ptr: Implement positive indexing properly.Paul Sokolovsky2016-07-25
| | | | Order out-of-bounds check, completion check, and increment in the right way.
* py/objstrunicode: str_index_to_ptr: Should handle bytes too.Paul Sokolovsky2016-07-25
| | | | | There's single str_index_to_ptr() function, called for both bytes and unicode objects, so should handle each properly.
* py/stream.h: Remove dated comment of POSIX-specificity of EAGAIN.Paul Sokolovsky2016-07-25
| | | | We have adopted POSIX-compatible error numbers as MicroPython's native.