Swig 无法将字节对象 python3 转换为 std::string

Swig unable to convert byte objectof python3 to std::string

我正在尝试使用 SWIG 将 python3 与 C++ 连接,但它不断抛出以下错误

>> ipc.sendMessage(q, b'qwe')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: in method 'sendMessage', argument 2 of type 'std::string'**

附件如下:

ipc.i 文件

%module ipc

%begin %{
    #define SWIG_PYTHON_STRICT_BYTE_CHAR
    #include "ipc.h"    
%}

%include std_string.i
%include stl.i
%include "ipc.h"

ipc.h 文件

#include<string>

extern int createQueue();
extern bool sendMessage(int, std::string);
extern std::string receiveMessage(int);
extern bool removeQueue(int);

用于构建的命令

>> swig -c++ -python ipc.i
>> g++ -fpic -c ipc.h ipc_wrap.cxx ipc.cpp -I/usr/include/python3.5
>> gcc -shared ipc_wrap.o ipc.o -o _ipc.so -lstdc++

问题出在 SWIG 3.0.8 上,并在更新到 3.0.10 后得到解决。