• Kirill Smelkov's avatar
    golang_str: bstr/ustr .format() support · 0985c583
    Kirill Smelkov authored
    Similarly to %-formatting, let's add support for .format(). This is
    easier to do because we can leverage string.Formatting and hook into the
    process by proper subclassing. We do not need to implement parsing and
    need to only customize handling of 's' and 'r' specifiers.
    
    For testing we mostly reuse existing tests for %-formatting by amending
    them a bit to exercise both %-formatting and format-formatting at the
    same time: by converting %-format specification into corresponding
    {}-format specification and verifying formatting result for that to be
    as expected.
    
    Some explicit tests for {}-style .format() are also added.
    0985c583
_golang_str.pyx 69.1 KB