Paul Sokolovsky
37379a2974
py/objstr: startswith, endswith: Check arg to be a string.
...
Otherwise, it will silently get incorrect result on other values types,
including CPython tuple form like "foo.png".endswith(("png", "jpg"))
(which MicroPython doesn't support for unbloatedness).
2017-08-29 00:06:21 +03:00
Paul Sokolovsky
e3383e9352
py/stream: seek: Consistently handle negative offset for SEEK_SET.
...
Per POSIX, this is EINVAL, so raises OSError(EINVAL).
2017-08-20 22:02:41 +03:00
Alex Robbins
c89254fd0f
extmod/modubinascii: Rewrite mod_binascii_a2b_base64.
...
This implementation ignores invalid characters in the input. This allows
it to decode the output of b2a_base64, and also mimics the behavior of
CPython.
2017-08-17 09:25:51 +03:00
Damien George
025e5f2b33
py/binary: Change internal bytearray typecode from 0 to 1.
...
The value of 0 can't be used because otherwise mp_binary_get_size will let
a null byte through as the type code (intepreted as byterray). This can
lead to invalid type-specifier strings being let through without an error
in the struct module, and even buffer overruns.
2017-08-17 16:19:35 +10:00
Eric Poulsen
d5191edf7f
extmod/modussl_mbedtls.c: Add ussl.getpeercert() method.
...
Behaviour is as per CPython but only the binary form is implemented here.
A test is included.
2017-08-16 15:01:00 +10:00
Bas van Sisseren
a14ce77b28
py/binary.c: Fix bug when packing big-endian 'Q' values.
...
Without bugfix:
struct.pack('>Q', 16)
b'\x00\x00\x00\x10\x00\x00\x00\x00'
With bugfix:
struct.pack('>Q', 16)
b'\x00\x00\x00\x00\x00\x00\x00\x10'
2017-08-15 11:33:43 +10:00
Paul Sokolovsky
bfc2092dc5
py/modsys: Initial implementation of sys.getsizeof().
...
Implemented as a new MP_UNARY_OP. This patch adds support lists, dicts and
instances.
2017-08-11 09:43:07 +03:00
Damien George
3d25d9c7d9
py/objstr: Raise an exception for wrong type on RHS of str binary op.
...
The main case to catch is invalid types for the containment operator, of
the form str.__contains__(non-str).
2017-08-09 21:25:48 +10:00
Damien George
eb2784e8a2
py/objtuple: Allow to use inplace-multiplication operator on tuples.
2017-08-09 21:20:42 +10:00
Alexander Steffen
55f33240f3
all: Use the name MicroPython consistently in comments
...
There were several different spellings of MicroPython present in comments,
when there should be only one.
2017-07-31 18:35:40 +10:00
Damien George
04552ff71b
py: Implement raising a big-int to a negative power.
...
Before this patch raising a big-int to a negative power would just return
0. Now it returns a floating-point number with the correct value.
2017-07-25 11:49:22 +10:00
Tom Collins
6cfe737597
tests/basics/builtin_exec: Test various globals/locals args to exec().
2017-07-21 15:17:33 +10:00
Damien George
6c1b7e008d
tests: Rename exec1.py to builtin_exec.py.
2017-07-21 15:11:24 +10:00
Paul Sokolovsky
4368ae3142
extmod/modussl_axtls: Allow to close ssl stream multiple times.
...
Make sure that 2nd close has no effect and operations on closed streams
are handled properly.
2017-07-20 00:20:53 +03:00
Damien George
761e4c7ff6
all: Remove trailing spaces, per coding conventions.
2017-07-19 13:12:10 +10:00
Paul Sokolovsky
ad3abcd324
tests/cpydiff: Add case for str.ljust/rjust.
2017-07-09 15:04:26 +03:00
Paul Sokolovsky
0c5369a1f0
tests/cpydiff/: Improve wording, add more workarounds.
2017-07-09 14:33:55 +03:00
Paul Sokolovsky
5f65ad8c96
tests/cpydiff/core_class_supermultiple: Same cause as core_class_mro.
2017-07-09 13:47:23 +03:00
Paul Sokolovsky
c5efb8159f
tests/cpydiff/core_arguments: Move under Functions subsection.
...
This is the last "orphan" case.
2017-07-09 13:36:28 +03:00
Paul Sokolovsky
b2979023ac
tests/cpydiff/core_class_mro: Move under Classes, add workaround.
2017-07-09 13:32:17 +03:00
Damien George
f69ab79ec8
py/objgenerator: Allow to hash generators and generator instances.
...
Adds nothing to the code size, since it uses existing empty slots in the
type structures.
2017-07-07 11:47:38 +10:00
Paul Sokolovsky
ed52955c6b
tests/cpydiff/modules_deque: Elaborate workaround.
2017-07-05 23:03:37 +03:00
Krzysztof Blazewicz
7feb7301b2
tests/basics: Add tests for arithmetic operators precedence.
2017-07-05 15:51:03 +10:00
Damien George
6b8b56f859
py/modmath: Check for zero division in log with 2 args.
2017-07-04 02:15:11 +10:00
Damien George
b86c65d31c
extmod/modubinascii: Add check for empty buffer passed to hexlify.
...
Previous to this patch hexlify(b'', b':') would lead to a bad crash due to
the computed length of the result being -1=0xffffffff.
2017-07-03 14:52:00 +10:00