• Carlos Ramos Carreño's avatar
    Make Cython allow Python 3 `str`. · 47c27b03
    Carlos Ramos Carreño authored
    Apparently, Cython by default can only convert `bytes` to C/C++ strings:
    
    ```python
    _____________________________________________________________________ test_join_autostart ______________________________________________________________________
    
        @func
        def test_join_autostart():
            zurl = testzurl
            with raises(RuntimeError, match="wcfs: join .*: server not running"):
                wcfs.join(zurl, autostart=False)
    
            assert wcfs._wcregistry == {}
            def _():
                assert wcfs._wcregistry == {}
            defer(_)
    
    >       wc = wcfs.join(zurl, autostart=True)
    
    wcfs/wcfs_test.py:164:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    wcfs/__init__.py:225: in join
        wc = WCFS(mntpt, fwcfs, wcsrv)
    ../../venvs/wendelin.core/lib/python3.9/site-packages/decorator.py:232: in fun
        return caller(func, *(extras + args), **kw)
    ../pygolang/golang/__init__.py:125: in _
        return f(*argv, **kw)
    wcfs/__init__.py:167: in __init__
        wc.mountpoint = mountpoint
    wcfs/client/_wcfs.pyx:44: in wendelin.wcfs.client._wcfs.PyWCFS.mountpoint.__set__
        def __set__(PyWCFS pywc, string v):
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    
    >   ???
    E   TypeError: expected bytes, str found
    ```
    
    We use the directives `# cython: c_string_type=str` and
    `# cython: c_string_encoding=utf8` where necessary to make it accept
    Python 3 `str`.
    47c27b03
_wcfs.pxd 5.18 KB