Darren Oakey
Darren Oakey

Reputation: 3594

suppress deprecation in python

so - I'm using a library pyminizip - which is the only way I've found to create a password protected zip file. When I use it I get a deprecationwarning: PY_SSIZE_T_CLEAN will be required for '#' formats.

now, I have no control over that library, no ability to fix it - nor do I seem to have an easy alternative to using it - and it works fine. So the deprecation warning adds zero value to me - but it interferes with the UI of my tool - as it appears on stdout. Is there any way to suppress it/make it go away?

the way I'm calling it is:

   import pyminizip
   pyminizip.compress_multiple( [ prod_report ], [], f"C:/temp/report{name}.zip", "Password", 9 )

Upvotes: 2

Views: 7459

Answers (2)

Nam G VU
Nam G VU

Reputation: 35364

Thanks to this answer, I just put this line on top of my starting code

import warnings ; warnings.warn = lambda *args,**kwargs: None

Upvotes: 0

mark86v1
mark86v1

Reputation: 312

import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning) 

got the answer from https://stackoverflow.com/a/879249/15213571

Upvotes: 9

Related Questions