• Kirill Smelkov's avatar
    golang_str: Revert adding buffer interface to ustr · 9ef32517
    Kirill Smelkov authored
    Testing this change on upcoming gpython/py3 with str patched to be ustr
    revealed compatibility breakage against several places in standard
    library. One example of such a breakage is os.listdir, which after
    doing PyObject_CheckBuffer decides to return bytes instead of unicode in
    the result:
    
        https://github.com/python/cpython/blob/v3.11.9-9-g1b0e63c81b5/Modules/posixmodule.c#L4194-L4195
    
    which makes e.g. pytest to fail to work with
    
        $ gpython -m pytest -vsx
        ...
          File ".../lib/python3.11/pathlib.py", line 370, in _select_from
            if self.match(name):
               ^^^^^^^^^^^^^^^^
        TypeError: cannot use a string pattern on a bytes-like object
    
    This was immediately-seen breakage even without trying to run ERP5 on
    top of gpy3. So in general adding buffer interface to ustr is believed to
    break too much compatibility with standard unicode on py3 that we
    decided against it.
    
    -> Revert adding buffer interface to ustr.
    
    This effectively reverts 8a240b5b (golang_str: Fix ustr to provide
    buffer interface, like bstr already does), but leaves added/updated
    tests and comments there about why making memoryview(ustr) turned out to
    be not a good idea.
    9ef32517
golang_str_test.py 116 KB