Fix C FFI bug in PyErr

Use null-terminated strings to call PyErr_NewException()

Signed-off-by: Tibor Benke <ihrwein@gmail.com>
This commit is contained in:
Tibor Benke 2016-07-22 21:22:17 +02:00 committed by Daniel Grunwald
parent 2db59a0835
commit d054115d85
1 changed files with 4 additions and 1 deletions

View File

@ -164,7 +164,10 @@ impl PyErr {
};
unsafe {
let ptr: *mut ffi::PyObject = ffi::PyErr_NewException(name.as_ptr() as *mut c_char, base, dict);
let null_terminated_name = CString::new(name).unwrap();
let ptr: *mut ffi::PyObject = ffi::PyErr_NewException(null_terminated_name.as_ptr() as *mut c_char,
base,
dict);
PyObject::from_borrowed_ptr(py, ptr).unchecked_cast_into::<PyType>()
}
}