Skip to content

fix: 2 improvements across 2 files - #5383

Open
tomaioo wants to merge 2 commits into
gwastro:masterfrom
tomaioo:improve/quality/potential-keyerror-in-fft-backend-getter
Open

fix: 2 improvements across 2 files#5383
tomaioo wants to merge 2 commits into
gwastro:masterfrom
tomaioo:improve/quality/potential-keyerror-in-fft-backend-getter

Conversation

@tomaioo

@tomaioo tomaioo commented Jul 24, 2026

Copy link
Copy Markdown

Summary

fix: 2 improvements across 2 files

Problem

Severity: High | File: pycbc/fft/backend_mkl.py:L28

The get_backend() functions in backend_mkl.py, backend_cupy.py, backend_cpu.py, and backend_cuda.py directly index into _adict using the global backend variable (e.g., _adict[mkl_backend]). If set_backend() fails to find a valid backend from the provided list, the global variable remains None, which will cause a KeyError when get_backend() is subsequently called.

Solution

Add a check in get_backend() to raise a more descriptive error if the backend is None (e.g., if mkl_backend is None: raise RuntimeError('No MKL backend available')).

Changes

  • pycbc/fft/backend_mkl.py (modified)
  • pycbc/frame/store.py (modified)

tomaioo added 2 commits July 24, 2026 11:59
- Quality: Potential KeyError in FFT backend getter functions
- Quality: Missing resource cleanup for HDF5 file handle

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
- Quality: Potential KeyError in FFT backend getter functions
- Quality: Missing resource cleanup for HDF5 file handle

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant