Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3d26cc9

Browse files
committed
Move the "import readline" to an earlier place so it is also done when
"-i" is given. (Yes, I know, giving in to Marc Lemburg who wanted this :-)
1 parent b6a4716 commit 3d26cc9

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

Modules/main.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,16 @@ Py_Main(argc, argv)
228228

229229
PySys_SetArgv(argc-optind, argv+optind);
230230

231+
if ((inspect || (command == NULL && filename == NULL)) &&
232+
isatty(fileno(stdin))) {
233+
PyObject *v;
234+
v = PyImport_ImportModule("readline");
235+
if (v == NULL)
236+
PyErr_Clear();
237+
else
238+
Py_DECREF(v);
239+
}
240+
231241
if (command) {
232242
sts = PyRun_SimpleString(command) != 0;
233243
free(command);
@@ -243,14 +253,6 @@ Py_Main(argc, argv)
243253
fclose(fp);
244254
}
245255
}
246-
if (isatty(fileno(stdin))) {
247-
PyObject *v;
248-
v = PyImport_ImportModule("readline");
249-
if (v == NULL)
250-
PyErr_Clear();
251-
else
252-
Py_DECREF(v);
253-
}
254256
}
255257
sts = PyRun_AnyFile(
256258
fp,

0 commit comments

Comments
 (0)