Python binding: Avoid using globals in Base.__del__()
@martinweismann 已经在做这个了。
开始于 2026年2月23日。
评估
这个 Issue 还没有评估数据。
描述
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.
- 主要语言
- Go
- 星标
- 54
- 派生
- 26
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Autodesk/AutomaticComponentToolkit 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 45/100
Autodesk/AutomaticComponentToolkit#213 · 1 条评论 · 2 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 35/100
Autodesk/AutomaticComponentToolkit#188 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 20/100
Autodesk/AutomaticComponentToolkit#183 · 1 条评论 ·
-
Autodesk/AutomaticComponentToolkit#162 · 1 个 reaction · 已指派 2 人 ·
-
难度 4/5 3-5 天 新手友好度 35/100
查看 Autodesk/AutomaticComponentToolkit 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 70/100
-
acceptance-tests phase-coding schema-coverage testing triaged
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100