Skip to content

Use of deprecated fromstring binary mode crashes with numpy 2.3.0+ #21418

@onitake

Description

@onitake

Cura Version

main

Operating System

Debian Linux sid

Printer

N/A

Reproduction steps

  1. Run Cura with a system-installed copy of numpy that is at least version 2.3.0
  2. Load a project, slice and open the preview

Actual results

Cura stops rendering the UI, and the following message is printed on the terminal:

  2026-02-20 21:31:49,148 - DEBUG - [MainThread] UM.View.GL.ShaderProgram.load [61]: Loading [/usr/lib/cura/plugins/SimulationView/simulationview_composite.shader]...
  2026-02-20 21:31:49,195 - DEBUG - [JobQueueWorker [3]] CuraEngineBackend.ProcessSlicedLayersJob.run [74]: Processing new layer for build plate 0...
  2026-02-20 21:31:49,280 - ERROR - [JobQueueWorker [3]] UM.JobQueue.run [135]: Exception: Job <CuraEngineBackend.ProcessSlicedLayersJob.ProcessSlicedLayersJob object at 0x7f779f15fa10> caused an exception on worker JobQueueWorker [3]
  2026-02-20 21:31:49,281 - ERROR - [JobQueueWorker [3]] UM.JobQueue.run [135]: Traceback (most recent call last):
  2026-02-20 21:31:49,281 - ERROR - [JobQueueWorker [3]] UM.JobQueue.run [135]:   File "/usr/lib/python3/dist-packages/UM/JobQueue.py", line 133, in run
  2026-02-20 21:31:49,282 - ERROR - [JobQueueWorker [3]] UM.JobQueue.run [135]:     job.run()
  2026-02-20 21:31:49,282 - ERROR - [JobQueueWorker [3]] UM.JobQueue.run [135]:     ~~~~~~~^^
  2026-02-20 21:31:49,282 - ERROR - [JobQueueWorker [3]] UM.JobQueue.run [135]:   File "/usr/lib/cura/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py", line 143, in run
  2026-02-20 21:31:49,283 - ERROR - [JobQueueWorker [3]] UM.JobQueue.run [135]:     line_types = numpy.fromstring(polygon.line_type, dtype = "u1")  # Convert bytearray to numpy array
  2026-02-20 21:31:49,283 - ERROR - [JobQueueWorker [3]] UM.JobQueue.run [135]: ValueError: The binary mode of fromstring is removed, use frombuffer instead
  beginResetModel called on OutputDevicesModel(0x2c490720) without calling endResetModel first
  endResetModel called on OutputDevicesModel(0x2c490720) without calling beginResetModel first

Expected results

No ValueError is generated.

Add your .zip and screenshots here ⬇️

This issue was reported on the Debian bug tracker: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1121290#15

We're still on Cura 5.0.0, but the issue hasn't been fixed in the main branch: https://github.com/Ultimaker/Cura/blob/main/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py#L143

References from the numpy documentation:
The deprecation has been present since numpy 1.14: https://numpy.org/doc/stable/reference/generated/numpy.fromstring.html
And it started generating ValueErrors in 2.3.0: https://numpy.org/doc/stable/release/2.3.0-notes.html#expired-deprecations

A fix should be relatively trivial, and it should also work fine with older numpy versions:

Replace all lines that use fromstring like this:

                line_types = numpy.fromstring(polygon.line_type, dtype = "u1")  # Convert bytearray to numpy array

with:

                line_types = numpy.frombuffer(polygon.line_type, dtype = "u1")  # Convert bytearray to numpy array

The same issue exists in https://github.com/Ultimaker/Cura/blob/main/plugins/3MFReader/ThreeMFReader.py#L140 and https://github.com/Ultimaker/Uranium/blob/main/UM/View/GL/OpenGL.py#L296

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: ImprovementImprovement to existing functionality.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions