-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix qpy.dump()'s use_symengine when passed a truthy object (#11730)
This commit fixes an issue in the qpy dump() function's use_symengine kwarg. When a user provided a truthy value that wasn't the literal `Truth` boolean object the generated qpy payload would be corrupted. That's because the check that assigns the encoding key in the file header was unecessarily checking for the literal ``True`` object instead of a object that evaluated to true. This was causing the header to say it was using a sympy encoding, but then all the checks that were encoding the data were evaluating true and setting symengine data. This would cause a failure on reading the qpy payload when the parameter expressions were parsed as it would try to load the binary symengine encoding with the sympy parser.
- Loading branch information
Showing
3 changed files
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
9 changes: 9 additions & 0 deletions
9
releasenotes/notes/fix-qpy-use-symengine-bool-like-d17550057a58abf2.yaml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
fixes: | ||
- | | ||
Fixed an issue with the :func:`.qpy.dump` function, when the | ||
``use_symengine`` flag was set to a truthy object that evaluated to | ||
``True`` but was not actually the boolean ``True`` the generated QPY | ||
payload would be corrupt. For example, if you set ``use_symengine`` to | ||
:obj:`.HAS_SYMENGINE` which evaluates to ``True`` when cast as a bool, | ||
but isn't actually ``True``. |
This file contains 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