Author: Armin Rigo <[email protected]>
Branch:
Changeset: r2143:57032e491d15
Date: 2015-05-31 10:22 +0200
http://bitbucket.org/cffi/cffi/changeset/57032e491d15/
Log: Leave with Py_FatalError() if we detect that the object is really
nonsense. In Python >= 3.3, this prints a traceback to stderr, too,
which is useful.
diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -5351,6 +5351,12 @@
return NULL;
}
x = (PyObject *)(raw + 42);
+ if (Py_REFCNT(x) <= 0) {
+ Py_FatalError("ffi.from_handle() detected that the address passed "
+ "points to garbage. If it is really the result of "
+ "ffi.new_handle(), then the Python object has already "
+ "been garbage collected");
+ }
Py_INCREF(x);
return x;
}
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit