• Kirill Smelkov's avatar
    golang_str: Fix ustr.translate on sequence · d76d5e1a
    Kirill Smelkov authored
    NumPy uses s.translate(str) and under gpython/py3 with str patched to be
    ustr it breaks with:
    
          File ".../numpy-1.24.4-py3.9-linux-x86_64.egg/numpy/core/_string_helpers.py", line 40, in english_lower
            lowered = s.translate(LOWER_TABLE)
          File "golang/_golang_str.pyx", line 909, in golang._golang._pyustr.translate
        AttributeError: 'str' object has no attribute 'items'
    
    https://docs.python.org/3/library/stdtypes.html#str.translate documents
    translate to work on both mappings and sequences, so my usage of
    table.items() in ff24be3d (golang_str: bstr/ustr string methods) was not
    correct.
    
    -> Fix it by reworking ustr.translate to use our proxy mapping instead
    of going through all items of original table in the beginning.
    d76d5e1a
golang_str_test.py 108 KB