diff --git a/src/pybuffer.jl b/src/pybuffer.jl index ea076e1f..5a25805b 100644 --- a/src/pybuffer.jl +++ b/src/pybuffer.jl @@ -42,13 +42,13 @@ end Release the reference to buffer `o` N.b. As per https://docs.python.org/3/c-api/buffer.html#c.PyBuffer_Release, It is an error to call this function on a PyBuffer that was not obtained via -the python c-api function `PyObject_GetBuffer(), unless o.obj is a PyPtr(C_NULL)` +the python c-api function `PyObject_GetBuffer()`, unless o.obj is a PyPtr(C_NULL) """ function pydecref(o::PyBuffer) # note that PyBuffer_Release sets o.obj to NULL, and # is a no-op if o.obj is already NULL # TODO change to `Ref{PyBuffer}` when 0.6 is dropped. - ccall(@pysym(:PyBuffer_Release), Cvoid, (Any,), o) + _finalized[] || ccall(@pysym(:PyBuffer_Release), Cvoid, (Any,), o) o end