It could be that all we need is to build gnubg against python3 for it to work.
C On Thu, 24 Feb 2022 at 00.58, Philippe Michel <philippe.mich...@free.fr> wrote: > On Sun, Feb 20, 2022 at 10:38:32PM +0100, Jim Segrave wrote: > > I need to look at this in depth- on my host the default python is 2.75 > > (even thouogh nowadays I almost always use python3) and it does what it > > used to. > > > > I really don't remember how the Python integration works, athough I once > > used it quite heavily to build databases of matches. I'm sure it's > solvable > > > > > > On 20/02/2022 16:20, Rose Menninger wrote: > > > Hi. Thanks for your reply. > > > Unfortunately I forgot to mention that cube-info is supposed to be a > dictionary and type(gnubg.cubeinfo()) also returns class ‘dict’. > > > > > > So, if I try to convert it using “bytes” function (as you mentioned), > i will get an error from bytes function like this: > > > TypeError: encoding without a string argument > > I don't think you want to "convert the dictionary to bytes". > > cube-info is something like: > > {'cube': 1, 'cubeowner': -1, 'move': 1, 'matchto': 0, 'score': (0, 0), > 'crawford': 0, 'jacoby': 1, 'beavers': 0, 'gammonprice': ((0.0, 0.0), > (0.0, 0.0)), 'bgv': 0} > > In python 2, the identifiers like 'cube' are ascii bytes strings and > that is what the methods taking such dictionaries as argument expect. > > In python 3, the same code that creates a dictionary from a list of C > variables makes the identifiers utf-8 strings (u'cube', implicitely), > but the methods still expect ascii strings, causing the error you get: > "TypeError: expected bytes, str found", str being an utf-8 string > > I'm not very familiar with python and what would be considered standard > in python 3 vs. python 2, but I would guess that what needs to be done > (when built with python 3) is for the methods to accept utf strings as > identifiers rather than create the dictionaries using byte strings. > >