Fails to compile on Python 3.11b3 due to opaque PyFrameObject #99277

Closed
opened 2022-06-29 18:56:59 +02:00 by Ben Beasley · 16 comments

System Information
Operating system: Fedora Rawhide (development)
Graphics card: N/A

Blender Version
Broken: 3.2.0
Worked: N/A

Short description of error

Blender fails to compile with Python 3.11b3 because:

  • The fields of PyFrameObject are now opaque (defined in an internal header); the function PyFrame_GetCode should be used to get the code object from the frame object.
  • Similarly, the function PyThreadState_GetFrame should be used to get the frame object from the thread state.
[ 52%] Generating buildinfo.h_fake, buildinfo.h
/builddir/build/BUILD/blender-3.2.0/source/blender/python/generic/py_capi_utils.c: In function 'PyC_FileAndNum':
/builddir/build/BUILD/blender-3.2.0/source/blender/python/generic/py_capi_utils.c:652:38: error: 'PyThreadState' {aka 'struct _ts'} has no member named 'frame'; did you mean 'cframe'?
  652 |   if (!(frame = PyThreadState_GET()->frame)) {
      |                                      ^~~~~
      |                                      cframe
/builddir/build/BUILD/blender-3.2.0/source/blender/python/generic/py_capi_utils.c:658:41: error: invalid use of incomplete typedef 'PyFrameObject' {aka 'struct _frame'}
  658 |     *r_filename = PyUnicode_AsUTF8(frame->f_code->co_filename);
      |                                         ^~
cd /builddir/build/BUILD/blender-3.2.0/redhat-linux-build/source/creator && /usr/bin/cmake -DSOURCE_DIR=/builddir/build/BUILD/blender-3.2.0 -DBUILD_DATE= -DBUILD_TIME= -P /builddir/build/BUILD/blender-3.2.0/build_files/cmake/buildinfo.cmake

Exact steps for others to reproduce the error

Build Blender normally, but with Python 3.11b3.

Additional details

I proposed the following fix for a similar issue in USD: https://github.com/PixarAnimationStudios/USD/pull/1928

**System Information** Operating system: Fedora Rawhide (development) Graphics card: N/A **Blender Version** Broken: 3.2.0 Worked: N/A **Short description of error** Blender fails to compile with Python 3.11b3 because: - The fields of PyFrameObject are now opaque (defined in an internal header); the function [PyFrame_GetCode](https://docs.python.org/3/c-api/reflection.html?highlight=pyframe_getcode#c.PyFrame_GetCode) should be used to get the code object from the frame object. - Similarly, the function [PyThreadState_GetFrame](https://docs.python.org/3/c-api/init.html?highlight=pythreadstate#c.PyThreadState_GetFrame) should be used to get the frame object from the thread state. ``` [ 52%] Generating buildinfo.h_fake, buildinfo.h /builddir/build/BUILD/blender-3.2.0/source/blender/python/generic/py_capi_utils.c: In function 'PyC_FileAndNum': /builddir/build/BUILD/blender-3.2.0/source/blender/python/generic/py_capi_utils.c:652:38: error: 'PyThreadState' {aka 'struct _ts'} has no member named 'frame'; did you mean 'cframe'? 652 | if (!(frame = PyThreadState_GET()->frame)) { | ^~~~~ | cframe /builddir/build/BUILD/blender-3.2.0/source/blender/python/generic/py_capi_utils.c:658:41: error: invalid use of incomplete typedef 'PyFrameObject' {aka 'struct _frame'} 658 | *r_filename = PyUnicode_AsUTF8(frame->f_code->co_filename); | ^~ cd /builddir/build/BUILD/blender-3.2.0/redhat-linux-build/source/creator && /usr/bin/cmake -DSOURCE_DIR=/builddir/build/BUILD/blender-3.2.0 -DBUILD_DATE= -DBUILD_TIME= -P /builddir/build/BUILD/blender-3.2.0/build_files/cmake/buildinfo.cmake ``` **Exact steps for others to reproduce the error** Build Blender normally, but with Python 3.11b3. **Additional details** I proposed the following fix for a similar issue in USD: https://github.com/PixarAnimationStudios/USD/pull/1928
Author

Added subscriber: @music

Added subscriber: @music
Author

While working on a patch for these errors, I found an additional error:

/builddir/build/BUILD/blender-3.2.0/source/blender/python/intern/bpy_driver.c: In function 'bpy_driver_secure_bytecode_validate':
/builddir/build/BUILD/blender-3.2.0/source/blender/python/intern/bpy_driver.c:386:36: error: 'PyCodeObject' has no member named 'co_code'
  386 |     PyBytes_AsStringAndSize(py_code->co_code, (char **)&codestr, &code_len);
      |                                    ^~

In Python 3.11 (https://docs.python.org/3.11/whatsnew/3.11.html#id6), “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.” This link also has further information on the PyThreadState and PyFrameObject changes.

While working on a patch for these errors, I found an additional error: ``` /builddir/build/BUILD/blender-3.2.0/source/blender/python/intern/bpy_driver.c: In function 'bpy_driver_secure_bytecode_validate': /builddir/build/BUILD/blender-3.2.0/source/blender/python/intern/bpy_driver.c:386:36: error: 'PyCodeObject' has no member named 'co_code' 386 | PyBytes_AsStringAndSize(py_code->co_code, (char **)&codestr, &code_len); | ^~ ``` In Python 3.11 (https://docs.python.org/3.11/whatsnew/3.11.html#id6), “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.” This link also has further information on the PyThreadState and PyFrameObject changes.
Member

Added subscriber: @PratikPB2123

Added subscriber: @PratikPB2123
Member

Changed status from 'Needs Triage' to: 'Archived'

Changed status from 'Needs Triage' to: 'Archived'
Member

Hi, thanks for opening a report. But tracker is not usually used for build related questions. See What not to report here
You can reach out to devs in [#blender-builds ]] channel for such questions. Or you can open a topic on [ https:*devtalk.blender.org/c/blender/building-blender/11 | devtalk

Hi, thanks for opening a report. But tracker is not usually used for build related questions. See [What not to report here ](https://developer.blender.org/maniphest/task/edit/form/1/) You can reach out to devs in [#blender-builds ]] channel for such questions. Or you can open a topic on [[ https:*devtalk.blender.org/c/blender/building-blender/11 | devtalk ](https:*blender.chat/channel/blender-builds)
Author

Thanks for your response, but I’m a little confused. I’m not asking for build support, but reporting a set of CPython API changes that will require code changes in Blender in order to support the upcoming Python 3.11 release. I’m working on the necessary patch. It doesn’t seem like a chat channel is the right venue for that.

Thanks for your response, but I’m a little confused. I’m not asking for build support, but reporting a set of CPython API changes that will require code changes in Blender in order to support the upcoming Python 3.11 release. I’m working on the necessary patch. It doesn’t seem like a chat channel is the right venue for that.
Member

Changed status from 'Archived' to: 'Needs Triage'

Changed status from 'Archived' to: 'Needs Triage'

Added subscribers: @ideasman42, @mano-wii

Added subscribers: @ideasman42, @mano-wii

Changed status from 'Needs Triage' to: 'Archived'

Changed status from 'Needs Triage' to: 'Archived'

Build issues are off-topic on the bug tracker as explained by the submission form .

What not to report here
For feature requests, feedback, questions or issues building Blender, see communication channels .

Please ask about this on [blender.chat ]] or [ https:*devtalk.blender.org/c/blender | DevTalk .
You can also propose a patch in the session Submit Code .

I suggest contacting @ideasman42 to propose early support for Python 3.11.

(This task can be reopened as To Do if approved by the developers)

Build issues are off-topic on the bug tracker as explained by the [submission form ](https://developer.blender.org/maniphest/task/edit/form/1/). > **What not to report here** > For feature requests, feedback, questions or issues building Blender, see [communication channels ](https://wiki.blender.org/wiki/Communication/Contact#User_Feedback_and_Requests). Please ask about this on [blender.chat ]] or [[ https:*devtalk.blender.org/c/blender | DevTalk ](https:*blender.chat/channel/blender-coders). You can also propose a patch in the session [Submit Code ](https://developer.blender.org/differential/diff/create/). I suggest contacting @ideasman42 to propose early support for Python 3.11. (This task can be reopened as `To Do` if approved by the developers)

Changed status from 'Archived' to: 'Confirmed'

Changed status from 'Archived' to: 'Confirmed'
Campbell Barton self-assigned this 2022-07-04 13:16:45 +02:00

Recently I looked into supporting Python 3.11, but it needs some careful consideration based on changes to allowed op-codes considered safe for evaluation of PyDrivers. It should be finished in the next day or so.

Recently I looked into supporting Python 3.11, but it needs some careful consideration based on changes to allowed op-codes considered safe for evaluation of PyDrivers. It should be finished in the next day or so.
Contributor

Added subscriber: @scurest

Added subscriber: @scurest

This issue was referenced by 780c0ea097

This issue was referenced by 780c0ea097444c3be60314dffd203c099720badb

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Author

Thank you!

Thank you!
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
6 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#99277
No description provided.