Skip to content

Commit 3634afb

Browse files
authored
Fix createMeshFromBytes() typecheck to correctly detect byte array parameter (#82)
1 parent 56b3352 commit 3634afb

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tesseract_python/swig/tesseract_geometry_python.i

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,11 @@ class OcTree {};
203203

204204
%include "tesseract_geometry/mesh_parser.h"
205205
%pybuffer_binary(const uint8_t* bytes, size_t bytes_len);
206+
// %pybuffer_binary does not automatically create a typecheck
207+
%typemap(typecheck) (const uint8_t* bytes, size_t bytes_len) {
208+
// Check if the input is a Python bytes or bytearray object
209+
$1 = PyBytes_Check($input) || PyByteArray_Check($input);
210+
}
206211
%template(createMeshFromResource) tesseract_geometry::createMeshFromResource<tesseract_geometry::Mesh>;
207212
%template(createSDFMeshFromResource) tesseract_geometry::createMeshFromResource<tesseract_geometry::SDFMesh>;
208213
%template(createConvexMeshFromResource) tesseract_geometry::createMeshFromResource<tesseract_geometry::ConvexMesh>;

0 commit comments

Comments
 (0)