As we move towards using Python 3, I have encountered a problem related to the MetaArrays. Although not related to the graphics portion of pyqtgraph, MetaArrays are part of pyqtgraph. I suspect they are not widely used, but they are used extensively in acq4 (a separate project that depends on pyqtgraph).
MetaArrays written in Python 2 or Python 3 are readable in Python 2. However, neither seems to be readable in Python 3. This seems to be related to the difference between strings and bytes in the two when interpreting part of the data.
The specific error (test script of minimal working version is attached; see the code for usage) is:
user: sandbox $ python test_ma.py read 2
Running under Python 3: 3.6.5
Traceback (most recent call last):
File "test_ma.py", line 57, in <module>
mdata = ma.MetaArray(file=fn)
File "/Users/pbmanis/Desktop/Python/pyqtgraph/pyqtgraph/metaarray/MetaArray.py", line 135, in __init__
self.readFile(file, **kwargs)
File "/Users/pbmanis/Desktop/Python/pyqtgraph/pyqtgraph/metaarray/MetaArray.py", line 752, in readFile
meta = MetaArray._readMeta(fd)
File "/Users/pbmanis/Desktop/Python/pyqtgraph/pyqtgraph/metaarray/MetaArray.py", line 777, in _readMeta
meta += line
TypeError: must be str, not bytes
user: sandbox $ python test_ma.py read 3
Running under Python 3: 3.6.5
Traceback (most recent call last):
File "test_ma.py", line 57, in <module>
mdata = ma.MetaArray(file=fn)
File "/Users/pbmanis/Desktop/Python/pyqtgraph/pyqtgraph/metaarray/MetaArray.py", line 135, in __init__
self.readFile(file, **kwargs)
File "/Users/pbmanis/Desktop/Python/pyqtgraph/pyqtgraph/metaarray/MetaArray.py", line 752, in readFile
meta = MetaArray._readMeta(fd)
File "/Users/pbmanis/Desktop/Python/pyqtgraph/pyqtgraph/metaarray/MetaArray.py", line 777, in _readMeta
meta += line
TypeError: must be str, not bytes
Whereas in Python 2 we can read or write python 2 or 3 files just fine.
I have tried to clean this up to be agnostic with respect to python versions, but without success. I suspect there is a simple way to do this, but I haven't found it yet.