Python: bpy_prop_array does not support full slicing syntax #105943

Open
opened 2023-03-21 03:30:31 +01:00 by Colin Basnett · 1 comment
Member

System Information
Operating system: Windows 11
Graphics card: NVIDIA RTX 3060 Ti

Blender Version
Broken: 3.6.0
Worked: Never

Short description of error

I am unable to use the full slicing syntax on a bpy_prop_array type.

For example, I am trying to read the pixels of an image, like so:

image = bpy.data.images['my_image']
pixels = image.pixels[3::4]
print(pixels)

Here the start is 3, the stop is None and the step is 4. This works for regular lists etc., but this code produces the following error:

Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
TypeError: slice indices must be integers or None or have an __index__ method

Exact steps for others to reproduce the error
See the attached .blend file.

**System Information** Operating system: Windows 11 Graphics card: NVIDIA RTX 3060 Ti **Blender Version** Broken: 3.6.0 Worked: Never **Short description of error** I am unable to use the full slicing syntax on a `bpy_prop_array` type. For example, I am trying to read the pixels of an image, like so: ``` image = bpy.data.images['my_image'] pixels = image.pixels[3::4] print(pixels) ``` Here the `start` is `3`, the `stop` is `None` and the `step` is 4. This works for regular lists etc., but this code produces the following error: ``` Traceback (most recent call last): File "<blender_console>", line 1, in <module> TypeError: slice indices must be integers or None or have an __index__ method ``` **Exact steps for others to reproduce the error** See the attached .blend file.
Colin Basnett added the
Priority
Normal
Status
Needs Triage
Type
Report
labels 2023-03-21 03:30:32 +01:00
Colin Basnett added this to the Python API project 2023-03-21 03:32:43 +01:00
Pratik Borhade removed this from the Python API project 2023-03-21 06:53:57 +01:00
Pratik Borhade added the
Module
Python API
label 2023-03-21 06:55:28 +01:00
Campbell Barton added
Type
To Do
Status
Confirmed
and removed
Type
Report
Status
Needs Triage
labels 2023-03-21 10:06:22 +01:00
Campbell Barton added this to the Python API project 2023-03-21 10:25:05 +01:00

Note that this is not a mistake in the code, support for this was never added, for many of Blender's internal API's the step value isn't so useful (collections of objects for e.g.). Pixel access (numeric arrays) in general - would be useful to support this feature.

Note that this is not a mistake in the code, support for this was never added, for many of Blender's internal API's the step value isn't so useful (collections of objects for e.g.). Pixel access (numeric arrays) in general - would be useful to support this feature.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
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
Asset Browser Project
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
2 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#105943
No description provided.