pyobjc
pyobjc copied to clipboard
pyobc-core fails to compile on Python 3.11.0b5
Describe the bug
Discovered in pypa/distutils#165, adding pyobjc
to the dependencies of the project caused the builds on macOS on Python 3.11 to start failing (example).
Platform information
- Python version: 3.11.0b5
- How was python installed (python.org, anaconda, homebrew, ...): python.org
- macOS version: 12.5
To Reproduce
pip install pyobjc-core
...
gcc -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/usr/local/opt/sqlite/include -I/usr/local/opt/sqlite/include -I/Users/runner/work/distutils/distutils/.tox/python/include -I/Users/runner/hostedtoolcache/Python/3.11.0-beta.5/x64/include/python3.11 -c Modules/objc/selector.m -o build/temp.macosx-10.15-x86_64-cpython-311/Modules/objc/selector.o -g -fexceptions -fno-objc-arc -Wall -Wstrict-prototypes -Wmissing-prototypes -Wformat=2 -W -Wpointer-arith -Wmissing-declarations -Wnested-externs -W -Wno-import -Wno-unknown-pragmas -Wshorten-64-to-32 -Werror -I/usr/include/ffi -fvisibility=hidden -g -O3 -flto=thin -isysroot /Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -DPyObjC_BUILD_RELEASE=1201
Modules/objc/selector.m:1496:24: error: no member named 'co_code' in 'struct PyCodeObject'; did you mean '_co_code'?
func_code->co_code, &buf, PyBUF_CONTIG_RO)
^~~~~~~
_co_code
/Users/runner/hostedtoolcache/Python/3.11.0-beta.5/x64/include/python3.11/cpython/code.h:103:21: note: '_co_code' declared here
struct PyCodeObject _PyCode_DEF(1);
^
/Users/runner/hostedtoolcache/Python/3.11.0-beta.5/x64/include/python3.11/cpython/code.h:92:15: note: expanded from macro '_PyCode_DEF'
PyObject *_co_code; /* cached co_code object/attribute */ \
^
1 error generated.
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]
Expected behavior
Package should install.
Thanks for the report. There's one other issue I want to look into (#479), but I hope to push out a release with Python 3.11 support during the weekend (assuming I don't melt in the local heatwave).
Just for your reference: "Porting to Python 3.11" section in https://docs.python.org/ja/3.11/whatsnew/3.11.html says,
PyCodeObject no longer has a co_code field. Instead, use PyObject_GetAttrString(code_object, "co_code") or PyCode_GetCode() to get the underlying bytes object. (Contributed by Brandt Bucher in [bpo-46841] and Ken Jin in [gh-92154]).
Sorry about the delay. There's a v8.6-branch branch in this repo that contains a fix for this, but I haven't managed to push out a release yet for various reasons (busy at work, too warm at home, and most recently a mild bout of COVID).
This is fixed in PyObjC 8.5.1 which is on PyPI since earlier this week.
Thank you! I hope the hardships continue to diminish.