Currently, the progress argument of compress_multiple is checked with PyFunction_Check.
Most of the time, it is fine. But there are cases where this check fails (e.g. partial, or compiled function with Python compiler like SCons).
I guess that any callable would be good for pyminizip right? So why not checking the progress object with PyCallable_Check which has the same signature than PyFunction_Check
int PyFunction_Check(PyObject *o)
Return true if o is a function object (has type PyFunction_Type). The parameter must not be NULL.
vs
int PyCallable_Check(PyObject *o)
Determine if the object o is callable. Return 1 if the object is callable and 0 otherwise. This function always succeeds.
Environment
Python 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)]
Example when passing a compiled function
Type of progress is <class 'compiled_function'>
Exception while creating archive 20230913-203728.zip: progress must be function or None
Traceback (most recent call last):
File "zipper.py", line 54, in compress
pyminizip.compress_multiple(
ValueError: progress must be function or None
Example when passing a partial
Type of progress is <class 'functools.partial'>
Exception while creating archive 20230913-204749.zip: progress must be function or None
Traceback (most recent call last):
File "zipper.py", line 52, in compress
pyminizip.compress_multiple(
ValueError: progress must be function or None
Hi!
Currently, the
progress
argument ofcompress_multiple
is checked withPyFunction_Check
.Most of the time, it is fine. But there are cases where this check fails (e.g.
partial
, or compiled function with Python compiler likeSCons
).I guess that any callable would be good for pyminizip right? So why not checking the
progress
object withPyCallable_Check
which has the same signature thanPyFunction_Check
vs
Environment
Python 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)]
Example when passing a compiled function
Example when passing a partial