Repository: kivy/python-for-android

Issue:
Python exception when using colorlog due to incomplete IO implementation in sys.stderr
I am attempting to run a program which uses `TTYColoredFormatter` from [colorlog](https://pypi.org/project/colorlog/). This class formats log messages, adding ANSI escape codes _only_ if the stream it is writing to returns `True` for `stream.isatty()`.

Unfortunately, python-for-android's bootstrap code replaces sys.stderr and sys.stdout with a custom `LogFile` object: https://github.com/kivy/python-for-android/blob/53d77fc26c9e37eb6ce05f8899f4dae8334842b1/pythonforandroid/bootstraps/common/build/jni/application/src/start.c#L226-L242

This object doesn't implement `isatty()` (or much else, for that matter). As a result, the program raises an exception:

```
03-03 13:32:56.222  5806  5891 I python  : Traceback (most recent call last):
03-03 13:32:56.222  5806  5891 I python  :   File "/home/jenkins/workspace/kolibri-installer-android-pr/src/main.py", line 3, in <module>
03-03 13:32:56.222  5806  5891 I python  :   File "/home/jenkins/workspace/kolibri-installer-android-pr/src/kolibri_android/main_activity/__main__.py", line 7, in main
03-03 13:32:56.222  5806  5891 I python  :   File "/home/jenkins/workspace/kolibri-installer-android-pr/src/kolibri_android/main_activity/activity.py", line 19, in <module>
03-03 13:32:56.222  5806  5891 I python  :   File "/home/jenkins/workspace/kolibri-installer-android-pr/src/kolibri_android/kolibri_utils.py", line 13, in <module>
03-03 13:32:56.223  5806  5891 I python  :   File "/home/jenkins/workspace/kolibri-installer-android-pr/src/kolibri_android/android_whitenoise.py", line 11, in <module>
03-03 13:32:56.223  5806  5891 I python  :   File "/home/jenkins/workspace/kolibri-installer-android-pr/src/kolibri/__init__.py", line 10, in <module>
03-03 13:32:56.223  5806  5891 I python  :   File "/home/jenkins/workspace/kolibri-installer-android-pr/src/kolibri/utils/env.py", line 29, in <module>
03-03 13:32:56.223  5806  5891 I python  :   File "/home/jenkins/workspace/kolibri-installer-android-pr/src/kolibri/dist/colorlog/colorlog.py", line 203, in __init__
03-03 13:32:56.223  5806  5891 I python  : AttributeError: 'LogFile' object has no attribute 'isatty'
```

(For reference, we're using colorlog v3.2.0, so the code raising the exception looks like this: https://github.com/borntyping/python-colorlog/blob/v3.2.0/colorlog/colorlog.py#L191-L211).
Service don t start anymore, as smallIconName extra is now mandatory
https://github.com/kivy/python-for-android/blob/8cb497dd89e402478011df61f4690b963a0c96da/pythonforandroid/bootstraps/common/build/src/main/java/org/kivy/android/PythonService.java#L116

```java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference```

We could test if null before.


Discussion:
I wonder if this `LogFile` class can inherit from IOBase instead: https://docs.python.org/3/library/io.html#io.IOBase. There are some pretty sane defaults there so we might just get the correct behaviour for free.


Resolving patch:
diff --git a/pythonforandroid/__init__.py b/pythonforandroid/__init__.py
--- a/pythonforandroid/__init__.py
+++ b/pythonforandroid/__init__.py
@@ -1 +1 @@
-__version__ = '2023.02.10'
+__version__ = '2023.05.21'


Test patch: