Regression: bpy.utils.register_class() "can't run in readonly state" error when run from Text Editor #112461

Closed
opened 2023-09-17 02:54:05 +02:00 by Thomas Barlow · 7 comments
Member

System Information
Operating system: Windows-10-10.0.19045-SP0 64 Bits
Graphics card: NVIDIA GeForce GTX 1070 Ti/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 536.40

Blender Version
Broken: version: 4.0.0 Alpha, branch: main, commit date: 2023-09-10 22:17, hash: fca8df9415b1
Worked: 4.0.0 Alpha, branch: main, commit date: 2023-09-01 21:43, hash de09bdb510a0

Short description of error
Running bpy.utils.register_class() from the Text Editor raises RuntimeError: register_class(...): can't run in readonly state 'TestOp'.

Running from the Python Console instead has no issues.

Exact steps for others to reproduce the error
Run in the Text Editor (or use and run one of the many Python Templates in the Text Editor that also use bpy.utils.register_class()):

import bpy

class TestOp(bpy.types.Operator):
    bl_label = "Test Op"
    bl_idname = "test.op"

    def execute(self, context):
        return {'CANCELLED'}

bpy.utils.register_class(TestOp)
**System Information** Operating system: Windows-10-10.0.19045-SP0 64 Bits Graphics card: NVIDIA GeForce GTX 1070 Ti/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 536.40 **Blender Version** Broken: version: 4.0.0 Alpha, branch: main, commit date: 2023-09-10 22:17, hash: `fca8df9415b1` Worked: 4.0.0 Alpha, branch: main, commit date: 2023-09-01 21:43, hash `de09bdb510a0` **Short description of error** Running `bpy.utils.register_class()` from the Text Editor raises `RuntimeError: register_class(...): can't run in readonly state 'TestOp'`. Running from the Python Console instead has no issues. **Exact steps for others to reproduce the error** Run in the Text Editor (or use and run one of the many Python Templates in the Text Editor that also use `bpy.utils.register_class()`): ```py import bpy class TestOp(bpy.types.Operator): bl_label = "Test Op" bl_idname = "test.op" def execute(self, context): return {'CANCELLED'} bpy.utils.register_class(TestOp) ```
Thomas Barlow added the
Priority
Normal
Type
Report
Status
Needs Triage
labels 2023-09-17 02:54:06 +02:00
Iliya Katushenock changed title from bpy.utils.register_class() "can't run in readonly state" error when run from Text Editor to Regression: bpy.utils.register_class() "can't run in readonly state" error when run from Text Editor 2023-09-17 10:30:13 +02:00

I can not reproduce this.

I can not reproduce this.
Iliya Katushenock added the
Interest
Python API
label 2023-09-17 10:32:22 +02:00
Author
Member

Hmm, now I can't reproduce it either. I've tried retracing my steps from the console log last night, I just did a few FBX exports with different material setups and imports to see what the exported results looked like, but no luck there either.

Hmm, now I can't reproduce it either. I've tried retracing my steps from the console log last night, I just did a few FBX exports with different material setups and imports to see what the exported results looked like, but no luck there either.
YimingWu added
Status
Needs Information from User
and removed
Status
Needs Triage
labels 2023-09-18 05:05:49 +02:00
Member

Hi, Any updates?

Hi, Any updates?
Author
Member

It hasn't occurred since and I couldn't see anything clearly wrong from the relevant C code. Maybe it was an unlucky hardware bitflip.

It hasn't occurred since and I couldn't see anything clearly wrong from the relevant C code. Maybe it was an unlucky hardware bitflip.
Member

Thanks, I think we can close this report for now. If you find anything relevant, feel free to reopen 🙂

Thanks, I think we can close this report for now. If you find anything relevant, feel free to reopen 🙂
Blender Bot added
Status
Archived
and removed
Status
Needs Information from User
labels 2023-10-23 11:04:28 +02:00

I've experienced this today using 4.1 last nights build. Every installed addon's unregister function threw the can't run in read only mode.

I've experienced this today using 4.1 last nights build. Every installed addon's unregister function threw the can't run in read only mode.

I had this same error and found that a modal operator was started by an addon, the operator returned {'RUNNING_MODAL'}, but then never finished. So the modal operator was "stuck" running forever, until I quit Blender. While it is running, no classes can be registered with Blender through bpy.utils.register_class.

I don't completely understand why it got stuck because one way to exit the modal operator was to cancel the render. But I hit ESC, started a new render, etc. and nothing would end the modal operator. I don't know if the tenacity of the modality is related to this issue (112461), or just a bug in the addon code.

I almost had a consistent repro working to post here, went out for a walk, came back and now it won't repro at all... Entirely frustrating!

I had this same error and found that a modal operator was started by an addon, the operator returned `{'RUNNING_MODAL'}`, but then never finished. So the modal operator was "stuck" running forever, until I quit Blender. While it is running, no classes can be registered with Blender through `bpy.utils.register_class`. I don't completely understand why it got stuck because one way to exit the modal operator was to cancel the render. But I hit `ESC`, started a new render, etc. and nothing would end the modal operator. I don't know if the tenacity of the modality is related to this issue (112461), or just a bug in the addon code. I almost had a consistent repro working to post here, went out for a walk, came back and now it won't repro at all... Entirely frustrating!
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
5 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#112461
No description provided.