QuantLib-SWIG
QuantLib-SWIG copied to clipboard
__eq__ Method Fails for QuantLib.Date with None Comparison
Description:
I recently updated QuantLib from version 1.32 to 1.35, and noticed that a comparison in my code suddenly broke. The issue suggests that the eq method for QuantLib.Date may not be working as expected.
Steps to Reproduce:
Here's a minimal reproducible example:
import QuantLib as ql
ql_date = ql.Date(1, 1, 2021)
is_false = ql_date == None
Expected Behavior: The comparison ql_date == None should return False, indicating that the ql_date is not equal to None, as None is not a valid Date object.
Actual Behavior: Instead, the code raises the following error:
ValueError: invalid null reference in method 'Date___eq__', argument 2 of type 'Date const &'
Thanks for posting! It might take a while before we look at your issue, so don't worry if there seems to be no feedback. We'll get to it.
Hi—it turns out this changed with release 1.34 due to upgrading to SWIG 4.2 (which was necessary to enable Python stable API). I've opened an issue with the SWIG people (https://github.com/swig/swig/issues/2987) to see if that's an intentional change.
In the meantime, if you want to compare with None explicitly, the idiomatic if date is None works.
Fixed on the SWIG side. We'll have to wait for the next SWIG release.
Moving the issue to the QuantLib-SWIG repo.
Thanks for posting! It might take a while before we look at your issue, so don't worry if there seems to be no feedback. We'll get to it.
This issue was automatically marked as stale because it has been open 60 days with no activity. Remove stale label or comment, or this will be closed in two weeks.
Fixed in SWIG 4.3, which will be used to produce the wheels for next release.