Commit 594ff3fa authored by Carlos Ramos Carreño's avatar Carlos Ramos Carreño Committed by Kirill Smelkov

wcfs: tests: Adapt changed modules/methods to Python 3.

Some modules and methods have changed names in Python 3.
The `thread` module has been renamed to `_thread` and the old name
gives error when run on Python 3:

```python
Traceback:
/opt/slapgrid/b0df76c24a1d2728ccf3e276f07c1790/parts/python3/lib/python3.9/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
wcfs/client/client_test.py:32: in <module>
    from wendelin.wcfs.wcfs_test import tDB, tAt, timeout, eprint
wcfs/wcfs_test.py:44: in <module>
    from thread import get_ident as gettid
E   ModuleNotFoundError: No module named 'thread'
```

In a similar vein, the `items` method of dictionaries plays the same
role as the old `iteritems`.

We use the `six` module to paper over these differences.

/reviewed-by @kirr
/reviewed-on nexedi/wendelin.core!27
parent d014045b
......@@ -41,7 +41,8 @@ from persistent.timestamp import TimeStamp
from ZODB.utils import z64, u64, p64
import sys, os, os.path, subprocess
from thread import get_ident as gettid
import six
from six.moves._thread import get_ident as gettid
from time import gmtime
from errno import EINVAL, ENOTCONN
from resource import setrlimit, getrlimit, RLIMIT_MEMLOCK
......@@ -481,7 +482,7 @@ class tDB(tWCFS):
def change(t, zf, changeDelta):
assert isinstance(zf, ZBigFile)
zfDelta = t._changed.setdefault(zf, {})
for blk, data in changeDelta.iteritems():
for blk, data in six.iteritems(changeDelta):
data = b(data)
assert len(data) <= zf.blksize
zfDelta[blk] = data
......@@ -520,7 +521,7 @@ class tDB(tWCFS):
dfile = DFile()
zconns.add(zf._p_jar)
zfh = zf.fileh_open(_use_wcfs=False)
for blk, data in zfDelta.iteritems():
for blk, data in six.iteritems(zfDelta):
dfile.ddata[blk] = data
data += b'\0'*(zf.blksize - len(data)) # trailing \0
vma = zfh.mmap(blk, 1)
......
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