Fix handling of errors with newer spglib version

Summary

  • Catch SpglibCppError raised by spglib ≥ 2.7 in get_primitive_structure and normalize it to the existing ValueError, maintaining consistent behavior across spglib versions.
  • Add two parametrized mock tests covering both failure modes: None return (< 2.7) and SpglibCppError (≥ 2.7).

Background

spglib 2.7 introduced SpglibCppError (from spglib._spglib) as a new exception type for C++-level failures. Prior versions returned None on failure. The behavior will become the default in 2.8 and the None-return path will be removed in 3.0.

Merge request reports

Loading