QuantLib-SWIG icon indicating copy to clipboard operation
QuantLib-SWIG copied to clipboard

Python QuantLib==1.3.4 issues DeprecationWarning on import

Open cdcadman opened this issue 1 year ago • 11 comments

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
>>>

cdcadman avatar May 13 '24 13:05 cdcadman

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.

boring-cyborg[bot] avatar May 13 '24 13:05 boring-cyborg[bot]

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?

lballabio avatar May 15 '24 15:05 lballabio

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.

cdcadman avatar May 15 '24 18:05 cdcadman

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.

github-actions[bot] avatar Jul 15 '24 02:07 github-actions[bot]

This issue was automatically closed because it has been stalled for two weeks with no further activity.

github-actions[bot] avatar Jul 30 '24 02:07 github-actions[bot]

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.

github-actions[bot] avatar Oct 28 '24 02:10 github-actions[bot]

swig/swig#2881 is now fixed.

wsfulton avatar May 23 '25 14:05 wsfulton

Thanks!

lballabio avatar May 23 '25 15:05 lballabio

I'm also getting these warnings (during pytest runs) on:

  • Python 3.13
  • QuantLib 1.40

avhz avatar Nov 20 '25 10:11 avhz

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.

lballabio avatar Nov 20 '25 10:11 lballabio

Fantastic, thanks Luigi :)

avhz avatar Nov 20 '25 10:11 avhz