lcm-proj / lcm

Lightweight Communications and Marshalling
GNU Lesser General Public License v2.1
944 stars 385 forks source link

Fix compatibility with Python 3.11 #376

Closed cho-m closed 1 year ago

cho-m commented 1 year ago

While trying to migrate Homebrew formula to Python 3.11, I hit the following error:

/tmp/lcm-20221118-59422-1wlr2mm/lcm-1.4.0/lcm-python/module.c:46:34: error: expression is not assignable
    Py_TYPE(&pylcmeventlog_type) = &PyType_Type;
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
/tmp/lcm-20221118-59422-1wlr2mm/lcm-1.4.0/lcm-python/module.c:47:26: error: expression is not assignable
    Py_TYPE(&pylcm_type) = &PyType_Type;
    ~~~~~~~~~~~~~~~~~~~~ ^
/tmp/lcm-20221118-59422-1wlr2mm/lcm-1.4.0/lcm-python/module.c:48:39: error: expression is not assignable
    Py_TYPE(&pylcm_subscription_type) = &PyType_Type;
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
3 errors generated.
make[2]: *** [lcm-python/CMakeFiles/lcm-python.dir/module.c.o] Error 1

Added a fix used by other projects like: