2

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 )
13
  • 1
    Are you sure that it's a bug in the library rather than a bug with how you use it?
    – user202729
    Commented Feb 18, 2021 at 5:29
  • In the former case the easiest way would be to contact the library author and tell them to fix the bug, or find a more up-to-date fork and use it, or make one yourself. Find convoluted way to suppress the output (redirect sys.stderr might work) is not a good idea.
    – user202729
    Commented Feb 18, 2021 at 5:30
  • 3
    Anyway post a minimal reproducible example for how to create the error message.
    – user202729
    Commented Feb 18, 2021 at 5:30
  • 1
    adam - zipfile doesn't allow you to write a password protected zip file - only read Commented Feb 18, 2021 at 5:33
  • 1
    Does this answer your question? How to disable Python warnings? Commented Feb 18, 2021 at 5:38

2 Answers 2

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

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

0

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

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.