@@ -55,6 +55,37 @@ void pry_set_prompts(const char* ps1, const char* ps2) {
5555 Py_DECREF(po2);
5656}
5757
58+//From python3 sourcecode
59+static void
60+pymain_run_interactive_hook(void)
61+{
62+ PyObject *sys, *hook, *result;
63+ sys = PyImport_ImportModule("sys");
64+ if (sys == NULL) {
65+ goto error;
66+ }
67+
68+ hook = PyObject_GetAttrString(sys, "__interactivehook__");
69+ Py_DECREF(sys);
70+ if (hook == NULL) {
71+ PyErr_Clear();
72+ return;
73+ }
74+
75+ result = _PyObject_CallNoArg(hook);
76+ Py_DECREF(hook);
77+ if (result == NULL) {
78+ goto error;
79+ }
80+ Py_DECREF(result);
81+
82+ return;
83+
84+error:
85+ PySys_WriteStderr("Failed calling sys.__interactivehook__\n");
86+ PyErr_Print();
87+}
88+
5889*/
5990import "C"
6091
@@ -111,6 +142,8 @@ func (p Python) REPLLikeEval(code string) {
111142}
112143
113144func (p Python) REPL() {
145+ C.pymain_run_interactive_hook()
146+
114147 fn := C.CString("<stdin>")
115148 defer C.free(unsafe.Pointer(fn))
116149 C.PyRun_InteractiveLoopFlags(C.stdin, fn, nil)