microsoft / microsoft/Qcodes

`dond` error in finally block

Open
#4,843 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
459
Forks
359
Avg merge
3d 6h
Merged PRs (30d)
73

Description

`finally` block in `dond` ([here](https://github.com/QCoDeS/Qcodes/blob/master/qcodes/dataset/dond/do_nd.py#L738)) relies on a parameter from try block.
This results in an `UnboundLocalError` when the exception happens before `datasavers` is assigned.

```python
try:
with _catch_interrupts() as interrupted, ExitStack() as stack, params_meas_caller as call_params_meas:
datasavers = [
stack.enter_context(group.measurement_cxt.run())
for group in measurements.groups
]
...
finally:
for datasaver in datasavers:
...
```

Contributor guide

Open the contributing guide

Research direction

Start in qcodes/dataset/dond/do_nd.py at the finally block around line 738, and trace how datasavers is assigned inside the try block. Reproduce an exception before that assignment and confirm the fix prevents UnboundLocalError while preserving the intended finally-block cleanup behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.