Skip to content

v0.4.9

Compare
Choose a tag to compare
@ionite34 ionite34 released this 22 Jan 08:13
· 326 commits to main since this release
0a8e342

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, or PyUnicodeObject structs. Previously the single usage of PyUnicodeObject could cause out of bounds memory access.
  • PyASCIIObject and subtypes now use a mem_size that is logically equivalent to the C implementation of str.__sizeof__, and should match in all cases.

Full Changelog: v0.4.8...v0.4.9