v0.4.9
Implement dynamic string structs to reflect CPython implementation:
- PyASCIIObject
- PyCompactUnicodeObject
- PyUnicodeObject
Added some macros to py_unicode
These should exactly match their C equivalents when possible
- PyUnicode_DATA
- PyUnicode_IS_COMPACT_ASCII
- PyUnicode_UTF8_LENGTH
- PyUnicode_WSTR_LENGTH
- _PyUnicode_COMPACT_DATA
- _PyUnicode_HAS_UTF8_MEMORY
- _PyUnicode_HAS_WSTR_MEMORY
- _PyUnicode_NONCOMPACT_DATA
- _PyUnicode_UTF8
- _PyUnicode_UTF8_LENGTH
Added MutableSequence
methods for StrView:
__delitem__
(index / slice)__setitem__
(index / slice)- append
- clear
- extend
- insert
- pop
- remove
- reverse
These new methods will not require an unsafe context normally as they check the allocated memory bounds before any resize operation. If resizing will be beyond allocated memory, an
UnsafeError
is raised.
An unsafe context can be entered to bypass this allocated memory check.
Fixes:
- ViewStr will now dynamically use one of
PyASCIIObject
,PyCompactUnicodeObject
, orPyUnicodeObject
structs. Previously the single usage ofPyUnicodeObject
could cause out of bounds memory access. - PyASCIIObject and subtypes now use a
mem_size
that is logically equivalent to the C implementation ofstr.__sizeof__
, and should match in all cases.
Full Changelog: v0.4.8...v0.4.9