bpy.extras.object_data_add not callable in a python script when "context.space_data" is None #72338

Closed
opened 2019-12-10 16:17:07 +01:00 by Frank Bessou · 3 comments

System Information
Operating system: Debian GNU/Linux 10 (buster)
Graphics card: NA

Blender Version
Broken: 2.80, 2.81 (since)
Worked: 2.79

Short description of error

When calling this function in a python script and the the context's space_data is None, an "AttributeError" is raised.

This is the case when running the script with blender -P <script-name>.

All the other functions which are using the space_data in scripts/modules/bpy_extras/object_utils.py first check for space_data existence before testing it's type. So it would be consistent to add it here too.

Exact steps for others to reproduce the error

Running blender -b -P object_data_add_bug.py fails with the following traceback :

Traceback (most recent call last):
  File "<pwd>/object_data_add_bug.py", line 4, in <module>                                         
    object_data_add(bpy.context, None, None)
  File "<blender-dir>/2.81/scripts/modules/bpy_extras/object_utils.py", line 134, in object_data_add
    if space_data.type == 'VIEW_3D':
AttributeError: 'NoneType' object has no attribute 'type'

Blender quit

object_data_add_bug.py

**System Information** Operating system: Debian GNU/Linux 10 (buster) Graphics card: NA **Blender Version** Broken: 2.80, 2.81 (since) Worked: 2.79 **Short description of error** When calling this function in a python script and the the context's `space_data` is `None`, an "AttributeError" is raised. This is the case when running the script with `blender -P <script-name>`. All the other functions which are using the `space_data` in `scripts/modules/bpy_extras/object_utils.py` first check for `space_data` existence before testing it's type. So it would be consistent to add it here too. **Exact steps for others to reproduce the error** Running `blender -b -P object_data_add_bug.py` fails with the following traceback : ``` Traceback (most recent call last): File "<pwd>/object_data_add_bug.py", line 4, in <module> object_data_add(bpy.context, None, None) File "<blender-dir>/2.81/scripts/modules/bpy_extras/object_utils.py", line 134, in object_data_add if space_data.type == 'VIEW_3D': AttributeError: 'NoneType' object has no attribute 'type' Blender quit ``` [object_data_add_bug.py](https://archive.blender.org/developer/F8205614/object_data_add_bug.py)
Author

Added subscriber: @FrankBessou

Added subscriber: @FrankBessou
Frank Bessou changed title from Add a check on "context.space_data" `bpy.extras.object_data_add` not callable in a python script when "context.space_data" is None to `bpy.extras.object_data_add` not callable in a python script when "context.space_data" is None 2019-12-10 16:27:00 +01:00
Author

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Frank Bessou self-assigned this 2019-12-11 18:17:58 +01:00
Author

Solved by f52d60a21d.

Solved by f52d60a21d.
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
1 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#72338
No description provided.