Commit Graph

9 Commits

Author SHA1 Message Date
Damien George
4e469085c1 py/objstr: Protect against creating bytes(n) with n negative.
Prior to this patch uPy (on a 32-bit arch) would have severe issues when
calling bytes(-1): such a call would call vstr_init_len(vstr, -1) which
would then +1 on the len and call vstr_init(vstr, 0), which would then
round this up and allocate a small amount of memory for the vstr.  The
bytes constructor would then attempt to zero out all this memory, thinking
it had allocated 2^32-1 bytes.
2018-02-19 16:25:30 +11:00
Damien George
dfa563c71f py/objstr: Make empty bytes object have a null-terminating byte.
Because a lot of string processing functions assume there is a null
terminating byte, so they can work in an efficient way.

Fixes issue #3334.
2017-10-04 17:59:22 +11:00
Damien George
97abe22963 tests: Add tests to exercise lexer; and some more complex number tests. 2015-04-04 23:16:22 +01:00
Damien George
26a9975fba tests: Add some more tests for bytes, bignum, string and ujson. 2015-03-14 21:20:58 +00:00
Paul Sokolovsky
57aebe1714 tests: Add testcase for bytes() on values in range 128-255. 2015-01-28 22:29:51 +02:00
Damien George
96e20c600f tests: Fix uctypes tests to run on 64bit arch; enable more native tests. 2014-09-23 14:15:45 +00:00
Paul Sokolovsky
9749b2fb0d objstr: Make sure that bytes are indexed as bytes, not as unicode.
Fixes #795.
2014-08-11 22:38:00 +03:00
Paul Sokolovsky
1ecea7c753 py: Make 'bytes' be a proper type, support standard constructor args. 2014-03-22 00:07:04 +02:00
Paul Sokolovsky
91fb1c9b13 Add basic implementation of bytes type, piggybacking on str.
This reuses as much str implementation as possible, from this we
can make them more separate as needed.
2014-01-24 22:56:26 +02:00