Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Python binding: Avoid using globals in Base.__del__()

Open
#226 5 comments 3 reactions 3 assignees View on GitHub

@martinweismann is already working on this.

Since Feb 23, 2026.

Assessment

This issue has not been assessed yet.

Description

Running 'build123d' examples I saw errors like

Exception ignored in: <function _Base.__del__ at 0x123e68180>
Traceback (most recent call last):
  File "venv/lib/python3.13/site-packages/lib3mf/Lib3MF.py", line 57, in __del__
  File "venv/lib/python3.13/site-packages/lib3mf/Lib3MF.py", line 6832, in Release
  File "venv/lib/python3.13/site-packages/lib3mf/Lib3MF.py", line 6767, in checkError
AttributeError: 'NoneType' object has no attribute 'SUCCESS'

This is error from the "lib3mf" package, and the by "AutomaticComponentToolkit" generated file lib3mf/Autogenerated/Bindings/Python/Lib3MF.py.

This file has been generated by the Automatic Component Toolkit (ACT) version 1.8.0-alpha.

This seems to happen in some situations when the Python script terminates. The error message is most likely harmless, but it is confusing as a user to see this error message and not knowing if things went ok or not.

Looking at the code, the class Base __del__() method calls _wrapper.Release() that calls checkError(). The problem seems to be that when Python cleans up, it might remove the class ErrorCodes before it try remove the class Base, i.e. ErrorCodes is no longer defined. This is likely what gives the error above. This problem is documented at

https://docs.python.org/3.9/reference/datamodel.html#object.__del__

Could the solution be to change the __del__() call to an __exit__() call ? It makes the error message go away but I don't know if it is the right thing to do.

As this happens when terminating, another solution might be to replace the line

if errorCode != ErrorCodes.SUCCESS.value:

with

if ErrorCodes and errorCode != ErrorCodes.SUCCESS.value:

This feels more like a hack and I haven't tested this.

Dominant language
Go
Stars
54
Forks
26
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Autodesk/AutomaticComponentToolkit

All issues in Autodesk/AutomaticComponentToolkit

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.