fix(print-and-cut): tolerate 4-axis position reports - #395
Merged
Conversation
Machine.get_current_position() returns a variable-length Pos tuple; machines with an extra rotary axis (e.g. GRBL A-axis) report four values. The wizard unpacked a fixed 3-tuple, raising ValueError and preventing the wizard from launching. Unpack only X/Y in both call sites and add regression tests. Fixes #394
Guard against spec_from_file_location returning None and consolidate module loading into a single helper so loader narrowing applies.
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.
Summary
The Print & Cut wizard crashed on launch for 4-axis machines (e.g. X/Y/Z/A with a rotary) with:
at
_update_laser_position(wizard.py:606).Machine.get_current_position()returns a variable-lengthPostuple (tuple[float | None, ...], driver.py:138). The GRBL parser keeps a 4th axis value when the firmware reports one (e.g.<Idle|MPos:-300.000,-50.000,0.000,0.000|...>), sowork_poshas four entries on such machines. The wizard assumed a fixed 3-tuple in two places and hard-unpacked it.Changes
_update_laser_position: read only X/Y via indexing with a length check instead of unpacking a 3-tuple_on_record_clicked: same fix (would have crashed identically when recording a point)tests/ui_gtk/test_print_and_cut_wizard.py) covering 3- and 4-value positions, invalid positions, and point recordingFixes #394
Testing
pytest tests/ui_gtk/test_print_and_cut_wizard.py -m uiunder xvfb: 8 passedpytest tests/machine/models/test_machine.py tests/machine/driver/grbl/test_grbl_util.py: 338 passed