Skip to content

Commit 2db988d

Browse files
dylanmccallrtibbles
authored andcommitted
Use io.IOBase for LogFile (kivy#2763)
This provides reasonable default implementations for common IO class methods such as isatty(). Closes kivy#2762.
1 parent 6ba12f9 commit 2db988d

File tree

1 file changed

+6
-4
lines changed
  • pythonforandroid/bootstraps/common/build/jni/application/src

1 file changed

+6
-4
lines changed

pythonforandroid/bootstraps/common/build/jni/application/src/start.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ static int run_python(int argc, char *argv[], bool call_exit) {
206206
/* inject our bootstrap code to redirect python stdin/stdout
207207
* replace sys.path with our path
208208
*/
209-
PyRun_SimpleString("import sys, posix\n");
209+
PyRun_SimpleString("import io, sys, posix\n");
210210

211211
char add_site_packages_dir[256];
212212

@@ -224,17 +224,19 @@ static int run_python(int argc, char *argv[], bool call_exit) {
224224
}
225225

226226
PyRun_SimpleString(
227-
"class LogFile(object):\n"
227+
"class LogFile(io.IOBase):\n"
228228
" def __init__(self):\n"
229229
" self.__buffer = ''\n"
230+
" def readable(self):\n"
231+
" return False\n"
232+
" def writable(self):\n"
233+
" return True\n"
230234
" def write(self, s):\n"
231235
" s = self.__buffer + s\n"
232236
" lines = s.split('\\n')\n"
233237
" for l in lines[:-1]:\n"
234238
" androidembed.log(l.replace('\\x00', ''))\n"
235239
" self.__buffer = lines[-1]\n"
236-
" def flush(self):\n"
237-
" return\n"
238240
"sys.stdout = sys.stderr = LogFile()\n"
239241
"print('Android path', sys.path)\n"
240242
"import os\n"

0 commit comments

Comments
 (0)