Commit 47c27b03 authored by Carlos Ramos Carreño's avatar Carlos Ramos Carreño

Make Cython allow Python 3 `str`.

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`.
parent d365ee80
......@@ -19,6 +19,7 @@
# See https://www.nexedi.com/licensing for rationale and options.
# cython: language_level=2
# cython: c_string_encoding=utf8
# distutils: language=c++
# Package _wcfs provides Python-wrappers for C++ wcfs client package.
......
......@@ -19,6 +19,7 @@
# See https://www.nexedi.com/licensing for rationale and options.
# cython: language_level=2
# cython: c_string_type=str, c_string_encoding=utf8
# cython: auto_pickle=False
# distutils: language=c++
......
......@@ -18,6 +18,7 @@
# See https://www.nexedi.com/licensing for rationale and options.
# cython: language_level=2
# cython: c_string_type=str, c_string_encoding=utf8
# distutils: language=c++
"""Module wcfs_test.pyx complements wcfs_test.py with things that cannot be
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment