• Carlos Ramos Carreño's avatar
    Fix `_mntpt_4zurl` to accept strings. · d365ee80
    Carlos Ramos Carreño authored
    Strings cannot be directly hashed without encoding them first, or
    an error will be raised:
    
    ```python
    ______________________________________________________________________ test_zsync_resync _______________________________________________________________________
    
        @func
        def test_zsync_resync():
            zstor = testdb.getZODBStorage()
            defer(zstor.close)
    
    >       db, zconn, wconn = _zsync_setup(zstor)
    
    wcfs/client/_wczsync_test.py:112:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    ../../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/client/_wczsync_test.py:53: in _zsync_setup
        wc = wcfs.join(zurl)
    wcfs/__init__.py:201: in join
        mntpt = _mntpt_4zurl(zurl)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    
    zurl = 'file:///srv/slapgrid/slappart66/tmp/testdb_fs.xstpbg49/1.fs'
    
        def _mntpt_4zurl(zurl):
            # normalize zurl so that even if we have e.g. two neos:// urls coming
            # with different paths to ssl keys, or with different order in the list of
            # masters, we still have them associated with the same wcfs mountpoint.
            zurl = zurl_normalize_main(zurl)
    
            m = hashlib.sha1()
    >       m.update(zurl)
    E       TypeError: Strings must be encoded before hashing
    ```
    
    We fix this error by encoding the string as UTF8 before hashing it.
    d365ee80
__init__.py 24.9 KB