Skip to content

What is the use of PyBobIo_FilenameConverter

Created by: siebenkopf

I have recently seen that there is a filename converter that converts a Python str into a PyBytesObject* (in py3) and into a PyStringObject* (in py2). https://github.com/bioidiap/bob.io.base/blob/master/bob/io/base/file.cpp#L70 Afterwards, the returned value is converted to char*, as here: https://github.com/bioidiap/bob.io.base/blob/master/bob/io/base/file.cpp#L119 where, once again, it has to be differentiated between py2 and py3.

However, I don't see, why we do not use the "s" variable indicator, which handles both str and unicode in py2: https://docs.python.org/2/c-api/arg.html and str (which is the same as unicode) in py3: https://docs.python.org/3.5/c-api/arg.html

char* filename = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", kwlist, &filename)) return -1;

So, do I miss something or is this converter simply useless?