python2 & python3 compatibility without needing 'builtins' module for python2#2
python2 & python3 compatibility without needing 'builtins' module for python2#2LRGH wants to merge 3 commits intobdcht:masterfrom
Conversation
|
I'd rather prefer a solution where we can still choose to rely on builtins: on ImportError you define a 'newbytes(x)' function that unpacks or packs depending on 'x'. |
|
Why do you want to hide the difference between packing and unpacking? |
|
the goal is not to hide x type, but to still allow the use of builtins module while minimising modified loc. Rather than defining only a 'newbytes' then define 2 funcs: a 'byteslist' for unpacks and a 'newbytes' for packs so that at import time we can choose which implementation (builtins or struct based) to use. |
|
But the builtins modules provides a big machinery that in the case of crysp is not needed: the use of struct.pack and struct.unpack is sufficient. Why would you want to use builtins? |
Because
import builtinsfails on default installs of python2, and it is not necessary to deal with the fact thatbytesis different from python2 to python3.