Paul Sokolovsky
26fda6dc8e
objstr: 64-bit issues.
11 years ago
Paul Sokolovsky
5048df0b7c
objstr: find(), rfind(), index(): Make return value be unicode-aware.
11 years ago
Paul Sokolovsky
cdc020da4b
objstrunicode: Re-add buffer protocol back for now, required for io.StringIO.
11 years ago
Paul Sokolovsky
d215ee1dc1
py: Make MICROPY_PY_BUILTINS_STR_UNICODE=1 buildable.
11 years ago
Paul Sokolovsky
9731912ccb
py: Prune unneeded code from objstrunicode, reuse code in objstr.
11 years ago
Paul Sokolovsky
e3cfc0d33d
objstr: Refactor to work with char pointers instead of indexes.
In preparation for unicode support.
11 years ago
Paul Sokolovsky
2ec38a17d4
objstr: Be 8-bit clean even for repr().
This will allow roughly the same behavior as Python3 for non-ASCII strings,
for example, print("<phrase in non-Latin script>".split()) will print list
of words, not weird hex dump (like Python2 behaves). (Of course, that it
will print list of words, if there're "words" in that phrase at all, separated
by ASCII-compatible whitespace; that surely won't apply to every human
language in existence).
11 years ago
Paul Sokolovsky
b4efac14cd
py: Make sure getattr() works with non-interned strings (by interning them).
11 years ago
Dave Hylands
b69f9fa31f
Fix str.modulo when precision is specified.
11 years ago
Damien George
d4c2bddd0c
py: Raise TypeError when trying to format non-int with %x,%o,%X.
This behaviour follows Python 3.5 standard (in 3.4 it's a
DeprecationWarning which we'd rather make a TypeError).
11 years ago
Damien George
11de8399fe
py: Small changes to objstr.c, including a bug fix.
Some small fixed:
- Combine 'x' and 'X' cases in str format code.
- Remove trailing spaces from some lines.
- Make exception messages consistently begin with lower case (then
needed to change those in objarray and objtuple so the same
constant string data could be used).
- Fix bug with exception message having %c instead of %%c.
11 years ago
Paul Sokolovsky
75ce9256b2
objstr: Implement "%(key)s" % {} formatting for strings and dicts.
Also, make sure that args to "*" format specifiers are bounds-checked
properly and don't lead for segfaults in case of mismatch.
11 years ago
Chris Angelico
9ab8ab2117
Replace assert(0) with a self-documenting TODO string
11 years ago
Chris Angelico
4867413e69
Simplify detection of quote characters in mp_str_print_quoted.
Once a double quote has been found, the subsequent discovery of a single quote
won't change behaviour at all, so don't bother looking for one.
11 years ago
Damien George
fcc9cf63f1
py, str: Replace enum with actual function pointer.
This way, it's slightly more efficient, uses less ROM (60 bytes less
for stmhal), and doesn't require to raise exception if bad operation
given.
11 years ago
Damien George
fb510b3bf9
Rename bultins config variables to MICROPY_PY_BUILTINS_*.
This renames:
MICROPY_PY_FROZENSET -> MICROPY_PY_BUILTINS_FROZENSET
MICROPY_PY_PROPERTY -> MICROPY_PY_BUILTINS_PROPERTY
MICROPY_PY_SLICE -> MICROPY_PY_BUILTINS_SLICE
MICROPY_ENABLE_FLOAT -> MICROPY_PY_BUILTINS_FLOAT
See issue #35 for discussion.
11 years ago
Paul Sokolovsky
ae9c82d5f3
objstr: str_uni_istype(): Spurious whitespace on empty lines.
11 years ago
Paul Sokolovsky
f69b9d379c
objstr: str_uni_istype(): Codestyle.
11 years ago
Kim Bauters
a3f4b83018
add methods isspace(), isalpha(), isdigit(), isupper() and islower() to str
11 years ago
Paul Sokolovsky
8827682b35
objstr: *strip(): If nothing is stripped, don't create dup string.
11 years ago
Paul Sokolovsky
bcdffe53c6
objstr: *strip(): Fix handling of one-char subject strings.
11 years ago
Damien George
f600a6a085
py: Slightly improve efficiency of mp_obj_new_str; rename str_new.
Reorder interning logic in mp_obj_new_str, to be more efficient.
str_new is globally accessible, so should be prefixed with mp_obj_.
11 years ago
Damien George
2617eebf2f
Change const byte* to const char* where sensible.
This removes need for some casts (at least, more than it adds need
for new casts!).
11 years ago
Paul Sokolovsky
5fd5af98d0
objlist: Implement support for arbitrary (3-arg) slices.
11 years ago
Paul Sokolovsky
de4b9329f9
py: Refactor slice helpers, preparing to support arbitrary slicing.
11 years ago
Paul Sokolovsky
69d081a7cf
py: Handle case of slice start > stop in common sequence function.
11 years ago
Paul Sokolovsky
afaaf535e6
objslice: Support arbitrary objects start, stop, and step.
Older int-only encoding is not expressive enough to support arbitrary slice
assignment operations.
11 years ago
Damien George
ee3fd46f13
Rename configuration variables controling Python features.
Now of the form MICROPY_PY_*. See issue #35 .
11 years ago
Paul Sokolovsky
d098c6bf85
objstr: Implement .endswith().
11 years ago
Damien George
6ac5dced24
py: Rename MP_OBJ_NOT_SUPPORTED to MP_OBJ_NULL.
See issue #608 for justification.
11 years ago
Paul Sokolovsky
c18ef2a9dd
objstr: startswith(): Accept optional "start" arg.
11 years ago
Paul Sokolovsky
70328e419a
py: Implement more complete bytes comparison handling.
11 years ago
Paul Sokolovsky
a47b64ae2d
objstringio: Implement io.BytesIO.
Done in generalized manner, allowing any stream class to be specified as
working with bytes.
11 years ago
Paul Sokolovsky
2a27365854
objstr.c: Partial implementation of .rsplit().
sep=None is TODO.
11 years ago
Paul Sokolovsky
da9f0924ef
py, unix: Add copyright for modules I worked closely on.
11 years ago
Paul Sokolovsky
5ebd5f0f19
objstr: Slice indexing: support bytes properly.
11 years ago
Paul Sokolovsky
bfb8819c0c
objstr: Make .split() support bytes.
11 years ago
Paul Sokolovsky
5e5d69b35e
objstr: Make .join() support bytes.
11 years ago
Paul Sokolovsky
eea0118654
py: Give up and make mp_obj_str_get_data() deal with bytes too.
This is not fully correct re: error handling, because we should check that
that types are used consistently (only str's or only bytes), but magically
makes lot of functions support bytes.
11 years ago
Paul Sokolovsky
b2d4fc06fc
objstr: Make *strip() accept bytes.
11 years ago
Paul Sokolovsky
69f3eb2c96
objstr: Make .[r]partition() work with bytes.
11 years ago
Paul Sokolovsky
d915a52eb6
py: Fix prefix on few sequence helpers, was incorrectly "mp_".
11 years ago
Paul Sokolovsky
6913521911
objstr: Implement .lower() and .upper().
11 years ago
Damien George
d0a5bf34f7
py: Tidy up returning NULL which should be MP_OBJ_NOT_SUPPORTED.
11 years ago
Paul Sokolovsky
7b0f9a7d9b
bytes: Implement comparison and other binary operations.
Should support everything supported by strings.
11 years ago
Paul Sokolovsky
b473d0ae86
py: bytes(), str(): Add NotImplementedError for kwargs.
Addresses #567 .
11 years ago
Damien George
04b9147e15
Add license header to (almost) all files.
Blanket wide to all .c and .h files. Some files originating from ST are
difficult to deal with (license wise) so it was left out of those.
Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.
11 years ago
Paul Sokolovsky
f54bcbf099
py, unix: Make "mpconfig.h" be first included, as other headers depend on it.
Specifically, nlr.h does.
11 years ago
Paul Sokolovsky
e908591baa
py: Abstract no-return attribute for functions a bit.
11 years ago
Paul Sokolovsky
e14d096cb7
objstr: Optimize .rstrip() by scanning string from end.
11 years ago