Calliing irssi.settings_add_str with string args will result in error.
For example:
running this snippet
irssi.settings_add_str("misc", "transformer_model", "gpt-3.5-turbo")
will result in this:
TypeError: a bytes-like object is required, not 'str'
doing something like below will "bypass" the problem:
irssi.settings_add_str(bytes("misc", encoding="utf-8"), bytes("transformer_model", encoding="utf-8"), bytes("gpt-3.5-turbo", encoding="utf-8"))
(not saying this is acceptable, just providing context)
For this specific case, looking at the source code the answer is obvious:
https://github.com/irssi-import/irssi-python/blob/py3/src/objects/pyscript-object.c#L414
PyArg_ParseTupleAndKeywords is being called with a yyy format string which according to here means it expects a byte-like object and not string.
I'm assuming there was a change in python's C API a while back which causes this issue now.
Currently there 147 instances of PyArg_ParseTupleAndKeywords being called in irrsi-python. most of them have y in their format. i will have to look at each and every one of them on a case by case basis and see whether a change is required for newer python versions.
This problem should be present in a lot more places is what I'm saying essentially.
As for the fix, I should first read this thoroughly and then find out when the "supposed change" happened in python's C API to decide whether we want to be backwards compatible with that specific python version or not. But that's a technicality of adding in pragmas. The proposed change will be to use another format string so that the functions actually accept string, decided on a case by case basis.
(the issue is present in python 3.10, the docs im linking to here are for 3.11, havent looked at any other python version yet)
Calliing irssi.settings_add_str with string args will result in error.
For example:
running this snippet
will result in this:
doing something like below will "bypass" the problem:
(not saying this is acceptable, just providing context)
For this specific case, looking at the source code the answer is obvious:
https://github.com/irssi-import/irssi-python/blob/py3/src/objects/pyscript-object.c#L414
PyArg_ParseTupleAndKeywordsis being called with ayyyformat string which according to here means it expects a byte-like object and not string.I'm assuming there was a change in python's C API a while back which causes this issue now.
Currently there 147 instances of
PyArg_ParseTupleAndKeywordsbeing called in irrsi-python. most of them haveyin their format. i will have to look at each and every one of them on a case by case basis and see whether a change is required for newer python versions.This problem should be present in a lot more places is what I'm saying essentially.
As for the fix, I should first read this thoroughly and then find out when the "supposed change" happened in python's C API to decide whether we want to be backwards compatible with that specific python version or not. But that's a technicality of adding in pragmas. The proposed change will be to use another format string so that the functions actually accept string, decided on a case by case basis.
(the issue is present in python 3.10, the docs im linking to here are for 3.11, havent looked at any other python version yet)