Python QuantLib==1.3.4 issues DeprecationWarning on import
Here is a demonstration in the interactive shell, running python 3.12 with QuantLib version 1.34. When I use QuantLib version 1.33, these warnings are not issued:
C:\>python -Walways
Python 3.12.0 (tags/v3.12.0:0fb18b0, Oct 2 2023, 13:03:39) [MSC v.1935 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import QuantLib
<frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute
<frozen importlib._bootstrap>:488: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute
<frozen importlib._bootstrap>:488: DeprecationWarning: builtin type swigvarlink has no __module__ attribute
>>>
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.
Thanks! This needs to be fixed in SWIG. It seems to be a known issue: https://github.com/swig/swig/issues/2881.
This only happens with the -Walways, right?
Yes, DeprecationWarning is ignored by python's default warning filter, so I used the -Walways to make it print out. I first noticed the warnings in pytest logs for some code that uses QuantLib.
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.
This issue was automatically closed because it has been stalled for two weeks with no further activity.
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.
swig/swig#2881 is now fixed.
Thanks!
I'm also getting these warnings (during pytest runs) on:
- Python 3.13
- QuantLib 1.40
The wrappers for QuantLib 1.40 were generated with SWIG 3.3, which was still the latest version at that time. The recently released SWIG 4.4 fixed the issue; it will be used for QuantLib 1.41.
Fantastic, thanks Luigi :)