pub fn from_code<'p>(
        py: Python<'p>,
        code: &str,
        file_name: &str,
        module_name: &str,
    ) -> PyResult<&'p PyModule> {
        let data = CString::new(code)?;
        let filename = CString::new(file_name)?;
        let module = CString::new(module_name)?;

        unsafe {
            let cptr = ffi::Py_CompileString(data.as_ptr(), filename.as_ptr(), ffi::Py_file_input);
            if cptr.is_null() {
                return Err(PyErr::fetch(py));
            }

            let mptr = ffi::PyImport_ExecCodeModuleEx(module.as_ptr(), cptr, filename.as_ptr());
            if mptr.is_null() {
                return Err(PyErr::fetch(py));
            }

            <&PyModule as crate::FromPyObject>::extract(py.from_owned_ptr_or_err(mptr)?)
        }
    }
/// Loads the Python code specified into a new module.
///
/// `code` is the raw Python you want to load into the module.
/// `file_name` is the file name to associate with the module
/// (this is used when Python reports errors, for example).
/// `module_name` is the name to give the module.
Loads the Python code specified into a new module.
`code` is the raw Python you want to load into the module.
`file_name` is the file name to associate with the module
(this is used when Python reports errors, for example).
`module_name` is the name to give the module.
Loads the Python code specified into a new module . ` code ` is the raw Python you want to load into the module . ` file_name ` is the file name to associate with the module ( this is used when Python reports errors for example ) . ` module_name ` is the name to give the module .
pub fn from_code<'p>(
        py: Python<'p>,
        code: &str,
        file_name: &str,
        module_name: &str,
    ) -> PyResult<&'p PyModule> {
        let data = CString::new(code)?;
        let filename = CString::new(file_name)?;
        let module = CString::new(module_name)?;
        unsafe {
            let cptr = ffi::Py_CompileString(data.as_ptr(), filename.as_ptr(), ffi::Py_file_input);
            if cptr.is_null() {
                return Err(PyErr::fetch(py));
            }
            let mptr = ffi::PyImport_ExecCodeModuleEx(module.as_ptr(), cptr, filename.as_ptr());
            if mptr.is_null() {
                return Err(PyErr::fetch(py));
            }
            <&PyModule as crate::FromPyObject>::extract(py.from_owned_ptr_or_err(mptr)?)
        }
    }
pub fn from_code < ' p > ( py : Python < ' p > , code : & str , file_name : & str , module_name : & str , ) -> PyResult < & ' p PyModule > { let data = CString :: new ( code ) ? ; let filename = CString :: new ( file_name ) ? ; let module = CString :: new ( module_name ) ? ; unsafe { let cptr = ffi :: Py_CompileString ( data . as_ptr ( ) , filename . as_ptr ( ) , ffi :: Py_file_input ) ; if cptr . is_null ( ) { return Err ( PyErr :: fetch ( py ) ) ; } let mptr = ffi :: PyImport_ExecCodeModuleEx ( module . as_ptr ( ) , cptr , filename . as_ptr ( ) ) ; if mptr . is_null ( ) { return Err ( PyErr :: fetch ( py ) ) ; } < & PyModule as crate :: FromPyObject > :: extract ( py . from_owned_ptr_or_err ( mptr ) ? ) } }
Loads the Python code specified into a new module.
Loads the Python code specified into a new module .
py
Python<'p>
code
&str
file_name
&str
module_name
&str
py
Python<'p>
code
&str
file_name
&str
module_name
&str