Repository navigation
Conversation
johnnoG
force-pushed
the
fix-setstate-downcast
branch
from
November 8, 2026 10:16
17103dc to
3679482
Compare
Author
|
The red AppVeyor jobs are 504s from GitHub while downloading the Miniforge installer, before any test runs. The full suite and black passed on Windows and macOS (and Azure is green), and Linux never got past the download. I can re-push once that settles, or feel free to re-run it from AppVeyor. @adam-urbanczyk @jmwright could one of you review this when you have a moment? It's a one-line fix in |
Member
|
Please get rid of Claude-branded commits |
copy.copy, copy.deepcopy and pickle rebuild a Shape through __setstate__, which assigned a plain TopoDS_Shape. Every other construction path downcasts (__init__, and importBin through cast), and the copy's own methods fail on the generic type, for example deepcopy(face).geomType() and deepcopy(edge).Length(). Code that dispatches on the concrete OCP type, such as ocp_tessellate, rejects it too. A null shape is assigned as is, since downcast raises on it.
johnnoG
force-pushed
the
fix-setstate-downcast
branch
from
November 8, 2026 10:35
3679482 to
26dd75a
Compare
Author
|
@adam-urbanczyk Done, the commit and the description no longer mention Claude. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
copy.copy,copy.deepcopyandpickleall rebuild aShapethrough__setstate__(added in #1762). It reads the BREP into a plainTopoDS_Shape()and assigns it withoutdowncast, so a copiedFacewraps a genericTopoDS_Shapeinstead of aTopoDS_Face.Shape.__init__andimportBin(throughcast) both downcast, so this is the one construction path that does not.The copy's own methods then fail (measured on 2.8.0 with OCP 7.9.3; the exception types may differ on master):
Code outside CadQuery that dispatches on the concrete OCP type fails too. For example, ocp_tessellate's
to_ocpgroup([copy.deepcopy(cq.Workplane().box(1, 2, 3))])raisesValueError: Unknown type: <class 'OCP.OCP.TopoDS.TopoDS_Shape'>.This change calls
downcastin__setstate__. A null shape (for example aftershape.wrapped.Nullify()) is assigned as is, becausedowncastraises on a null shape and its round trip works today. The pickle format does not change, so old pickles still load.Not changed here:
__setstate__still does not restorelabelor a vertex'sX/Y/Z, before or after this change.Tests in
tests/test_pickle.py:test_shape_typechecks thatcopy,deepcopyand a pickle round trip keep the TopoDS type of a solid, a face, an edge and a vertex. It fails on master.test_null_shapechecks that a null shape survives a pickle round trip. It passes on master and fails if theIsNullguard is removed.