Commit 52e7a45
committed
Fix crash when stdout is not a TTY on Linux
Without this change, the following happened when piping/redirecting the
output of MCE.py:
```
Error: MC Extractor v1.102.0 crashed, please report the following:
Traceback (most recent call last):
File "/root/MCExtractor/MCE.py", line 1093, in <module>
elif sys_os.startswith('linux') or sys_os == 'darwin' or sys_os.find('bsd') != -1 : sys.stdout.write('\x1b]2;' + mce_title + '\x07')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/colorama/ansitowin32.py", line 47, in write
self.__convertor.write(text)
File "/usr/lib/python3/dist-packages/colorama/ansitowin32.py", line 177, in write
self.write_and_convert(text)
File "/usr/lib/python3/dist-packages/colorama/ansitowin32.py", line 199, in write_and_convert
text = self.convert_osc(text)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/colorama/ansitowin32.py", line 272, in convert_osc
winterm.set_title(params[1])
^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'set_title'
```
This looks like a colorama bug, see
tartley/colorama#209.
The workaround is to skip the title change if stdout is not a TTY.1 parent a220258 commit 52e7a45
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1090 | 1090 | | |
1091 | 1091 | | |
1092 | 1092 | | |
1093 | | - | |
| 1093 | + | |
1094 | 1094 | | |
1095 | 1095 | | |
1096 | 1096 | | |
| |||
0 commit comments