Py_DEBUG implies Py_REF_DEBUG, Py_TRACE_REFS, COUNT_ALLOCS

This commit is contained in:
Nikolay Kim 2017-05-04 13:11:00 -07:00
parent 98e66ee329
commit a3823cec8e
2 changed files with 13 additions and 5 deletions

View File

@ -102,13 +102,22 @@ config = sysconfig.get_config_vars();".to_owned();
}
let all_vars = SYSCONFIG_FLAGS.iter().chain(SYSCONFIG_VALUES.iter());
// let var_map: HashMap<String, String> = HashMap::new();
Ok(all_vars.zip(split_stdout.iter())
let mut all_vars = all_vars.zip(split_stdout.iter())
.fold(HashMap::new(), |mut memo: HashMap<String, String>, (&k, &v)| {
if !(v.to_owned() == "None" && is_value(k)) {
memo.insert(k.to_owned(), v.to_owned());
}
memo
}))
});
let debug = if let Some(val) = all_vars.get("Py_DEBUG") { val == "1" } else { false };
if debug {
all_vars.insert("Py_REF_DEBUG".to_owned(), "1".to_owned());
all_vars.insert("Py_TRACE_REFS".to_owned(), "1".to_owned());
all_vars.insert("COUNT_ALLOCS".to_owned(), "1".to_owned());
}
Ok(all_vars)
}
#[cfg(target_os="windows")]

View File

@ -80,8 +80,8 @@ pub const PYTHON_ABI_VERSION: i32 = 3;
#[cfg(py_sys_config="Py_TRACE_REFS")]
#[inline]
pub unsafe fn PyModule_Create2(module: *mut PyModuleDef,
apiver: c_int) -> *mut PyObject {
PyModule_Create2TraceRefs(arg1, apiver)
apiver: c_int) -> *mut PyObject {
PyModule_Create2TraceRefs(module, apiver)
}
#[cfg(py_sys_config="Py_TRACE_REFS")]
@ -104,4 +104,3 @@ pub unsafe fn PyModule_Create(module: *mut PyModuleDef) -> *mut PyObject {
pub unsafe fn PyModule_FromDefAndSpec(def: *mut PyModuleDef, spec: *mut PyObject) -> *mut PyObject {
PyModule_FromDefAndSpec2(def, spec, if cfg!(Py_LIMITED_API) { PYTHON_ABI_VERSION } else { PYTHON_API_VERSION })
}