diff --git a/.travis.yml b/.travis.yml index 16575dc4..e0a08ec6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,13 @@ language: python + python: - "2.7" - "3.5" - "3.6" + - "3.7-dev" + +allow_failures: + - python: "3.7-dev" env: global: diff --git a/pyo3cls/src/module.rs b/pyo3cls/src/module.rs index 15f7190e..0aa9993d 100644 --- a/pyo3cls/src/module.rs +++ b/pyo3cls/src/module.rs @@ -56,6 +56,7 @@ pub fn py3_init(fnname: &syn::Ident, name: &String, doc: syn::Lit) -> Tokens { // so we'll do it here in the module initialization: MODULE_DEF.m_name = concat!(stringify!(#m_name), "\0").as_ptr() as *const _; + #[cfg(py_sys_config = "WITH_THREAD")] pyo3::ffi::PyEval_InitThreads(); let _module = pyo3::ffi::PyModule_Create(&mut MODULE_DEF); diff --git a/src/pythonrun.rs b/src/pythonrun.rs index 9fa3920c..cf02c7c4 100644 --- a/src/pythonrun.rs +++ b/src/pythonrun.rs @@ -39,14 +39,20 @@ pub fn prepare_freethreaded_python() { if ffi::Py_IsInitialized() != 0 { // If Python is already initialized, we expect Python threading to also be initialized, // as we can't make the existing Python main thread acquire the GIL. + #[cfg(py_sys_config = "WITH_THREAD")] assert_ne!(ffi::PyEval_ThreadsInitialized(), 0); } else { + // If Python isn't initialized yet, we expect that Python threading + // isn't initialized either. + #[cfg(py_sys_config = "WITH_THREAD")] + assert_eq!(ffi::PyEval_ThreadsInitialized(), 0); // Initialize Python. // We use Py_InitializeEx() with initsigs=0 to disable Python signal handling. // Signal handling depends on the notion of a 'main thread', which doesn't exist in this case. // Note that the 'main thread' notion in Python isn't documented properly; // and running Python without one is not officially supported. ffi::Py_InitializeEx(0); + #[cfg(py_sys_config = "WITH_THREAD")] ffi::PyEval_InitThreads(); // PyEval_InitThreads() will acquire the GIL, // but we don't want to hold it at this point @@ -61,6 +67,7 @@ pub fn prepare_freethreaded_python() { }); } + #[doc(hidden)] pub fn prepare_pyo3_library() { START_PYO3.call_once(|| unsafe {