[chirp_devel] python2/3 MemoryMap?

Dan Smith
Sun Feb 17 15:24:18 PST 2019


> OK, I did in fact make my driver work on both py3 and the (py2) main branch. I built my image into a bytearray, then converted to bytes,
> use MemoryMap:
>        bytearraymmap = bytearray(radio._imagesize)
>        readimageinto bytearray(bytearraymmap)
>        self._mmap= memmap.MemoryMap(bytes(bytearraymmap))

You might be able to run stuff against your driver in the main branch, but you can't run the whole app, and the run_tests.py file isn't even syntax-compatible under python3:

> $ python3 tests/run_tests.py
>   File "tests/run_tests.py", line 134
>     except Exception, e:
>                     ^
> SyntaxError: invalid syntax

> This code works in both places. The py3 version will eventually need to be cleaned up to use the MemoryMapBytes, simply to avoid the
> array copy, but that's minor. We could add a stub version of MemoryMapBytes to py2 to simplify the transition.


If you meant the same driver file can work on the default and py3 branch, then sure, that's just not what I meant.

--Dan


More information about the chirp_devel mailing list