pub fn run_repl(&mut self) -> PyResult<PyObject> {
        let py = self.acquire_gil();

        unsafe {
            pyffi::Py_InspectFlag = 0;
        }

        // readline is optional. We don't care if it fails.
        if py.import("readline").is_ok() {}

        let sys = py.import("sys")?;

        if let Ok(hook) = sys.get(py, "__interactivehook__") {
            hook.call(py, NoArgs, None)?;
        }

        let stdin_filename = "<stdin>";
        let filename = CString::new(stdin_filename)
            .or_else(|_| Err(PyErr::new::<ValueError, _>(py, "could not create CString")))?;
        let mut cf = pyffi::PyCompilerFlags { cf_flags: 0 };

        // TODO use return value.
        unsafe {
            let stdin = stdin_to_file();
            pyffi::PyRun_AnyFileExFlags(stdin, filename.as_ptr() as *const c_char, 0, &mut cf)
        };

        Ok(py.None())
    }
/// Start and run a Python REPL.
///
/// This emulates what CPython's main.c does.
///
/// The interpreter is automatically initialized if needed.
Start and run a Python REPL.
This emulates what CPython's main.c does.

The interpreter is automatically initialized if needed.
Start and run a Python REPL . This emulates what CPython ' s main . c does . The interpreter is automatically initialized if needed .
pub fn run_repl(&mut self) -> PyResult<PyObject> {
        let py = self.acquire_gil();
        unsafe {
            pyffi::Py_InspectFlag = 0;
        }
        // readline is optional. We don't care if it fails.
        if py.import("readline").is_ok() {}
        let sys = py.import("sys")?;
        if let Ok(hook) = sys.get(py, "__interactivehook__") {
            hook.call(py, NoArgs, None)?;
        }
        let stdin_filename = "<stdin>";
        let filename = CString::new(stdin_filename)
            .or_else(|_| Err(PyErr::new::<ValueError, _>(py, "could not create CString")))?;
        let mut cf = pyffi::PyCompilerFlags { cf_flags: 0 };
        // TODO use return value.
        unsafe {
            let stdin = stdin_to_file();
            pyffi::PyRun_AnyFileExFlags(stdin, filename.as_ptr() as *const c_char, 0, &mut cf)
        };
        Ok(py.None())
    }
pub fn run_repl ( & mut self ) -> PyResult < PyObject > { let py = self . acquire_gil ( ) ; unsafe { pyffi :: Py_InspectFlag = 0 ; } // readline is optional. We don't care if it fails. if py . import ( " " ) . is_ok ( ) { } let sys = py . import ( " " ) ? ; if let Ok ( hook ) = sys . get ( py , " " ) { hook . call ( py , NoArgs , None ) ? ; } let stdin_filename = " " ; let filename = CString :: new ( stdin_filename ) . or_else ( | _ | Err ( PyErr :: new :: < ValueError , _ > ( py , " " ) ) ) ? ; let mut cf = pyffi :: PyCompilerFlags { cf_flags : 0 } ; // TODO use return value. unsafe { let stdin = stdin_to_file ( ) ; pyffi :: PyRun_AnyFileExFlags ( stdin , filename . as_ptr ( ) as * const c_char , 0 , & mut cf ) } ; Ok ( py . None ( ) ) }
Start and run a Python REPL.
Start and run a Python REPL .
&mut self