mtest: consider AttributeError#15445
Conversation
| except OSError: | ||
| except (OSError, AttributeError): | ||
| self.cols = 80 | ||
| self.is_tty = False |
There was a problem hiding this comment.
Is it indeed accurate to say that OS/2 doesn't (cannot ever) have a tty?
There was a problem hiding this comment.
Error says that os does not have get_terminal_size attr. I know, os.get_terminal_size() has not been implemented on OS/2.
There was a problem hiding this comment.
Would this work instead?
self.is_tty = os.isatty(1)
self.cols = 80
if self.is_tty:
try:
self.cols, _ = os.get_terminal_size(1)
except (OSError, AttributeError):
passThere was a problem hiding this comment.
Yes, but parentheses are necessary.
Traceback (most recent call last):
File "f:/lang/work/meson/meson-os2.git/meson.py", line 27, in <module>
sys.exit(mesonmain.main())
File "f:\lang\work\meson\meson-os2.git/mesonbuild/mesonmain.py", line 313, in main
return run(sys.argv[1:], launcher)
File "f:\lang\work\meson\meson-os2.git/mesonbuild/mesonmain.py", line 304, in run
return CommandLineParser().run(args)
File "f:\lang\work\meson\meson-os2.git/mesonbuild/mesonmain.py", line 67, in __init__
from . import mconf, mdist, minit, minstall, mintro, msetup, mtest, rewriter, msubprojects, munstable_coredata, mcompile, mdevenv, mformat
File "f:\lang\work\meson\meson-os2.git/mesonbuild/mtest.py", line 562
except OSError, AttributeError:
^
SyntaxError: invalid syntax
There was a problem hiding this comment.
And the following error ocurrs:
[0/1] Running all tests
Traceback (most recent call last):
File "f:\lang\work\meson\meson-os2.git/mesonbuild/mesonmain.py", line 193, in run
return options.run_func(options)
File "f:\lang\work\meson\meson-os2.git/mesonbuild/mtest.py", line 2308, in run
with TestHarness(options) as th:
File "f:\lang\work\meson\meson-os2.git/mesonbuild/mtest.py", line 1674, in __init__
self.console_logger = ConsoleLogger(options.max_lines)
File "f:\lang\work\meson\meson-os2.git/mesonbuild/mtest.py", line 565, in __init__
self.output_start = dashes(self.SCISSORS, self.HLINE, self.cols - 2)
AttributeError: 'ConsoleLogger' object has no attribute 'cols'
ERROR: Unhandled python exception
This is a Meson bug and should be reported!
There was a problem hiding this comment.
Would this work instead?
Then there is no need to check for OSError either... OSError is how os.get_terminal_size(1) signals that fd 1 isn't a tty.
There was a problem hiding this comment.
Without OSError check, PowerShell tests failed. So I added it again.
os.get_terminal_size is not defined on OS/2.
os.get_terminal_size is not defined on OS/2.