Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix a bug of logging on terminals whose size is unknown #611

Merged
merged 3 commits into from
Nov 14, 2019
Merged

Conversation

kmyk
Copy link
Member

@kmyk kmyk commented Nov 14, 2019

fix #609, reported by @yosupo06

fallback を指定すれば直るらしいので指定します。実際の環境で試してないですが、 shutil.py を読む限りではこれで直るはずです。
https://docs.python.org/ja/3/library/shutil.html#shutil.get_terminal_size

@kmyk
Copy link
Member Author

kmyk commented Nov 14, 2019

再現する環境がないことを考えると、@yosupo06os.terminal_size(columns=0, lines=0) が返ってくることを確認してくれたのめちゃ助かった

@yosupo06
Copy link
Contributor

yosupo06 commented Nov 14, 2019

https://circleci.com/gh/yosupo06/Algorithm/34 これは https://github.com/yosupo06/Algorithm/blob/447d0aa513320ff0c72d0af3739d709bcdcdcb61/test-oj/test.py を実行したものなんですが、ダメそうに見えます

https://github.com/python/cpython/blob/694c03fabb5cf3df0102cc317670a10fc39c6786/Lib/shutil.py#L1287 これ読むに os.get_terminal_size(sys.__stdout__.fileno()) が例外吐かずに(0, 0)返してるような気がするんですが、ちょっと闇が深そう?

@kmyk
Copy link
Member Author

kmyk commented Nov 14, 2019

流石に似た事例がある、たしかにそう。かしこい。
例外なしで (0, 0) が返ってくるということは他にも例外なしで (1, 1) が返ってくるケースもあるはずだし、適当な数値で max はよさそうに見えます。

@kmyk
Copy link
Member Author

kmyk commented Nov 14, 2019

@fukatani @kawacchu どちらかレビューとよさそうならマージをお願いします

Copy link
Contributor

@fukatani fukatani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fukatani fukatani merged commit 89444e7 into master Nov 14, 2019
@fukatani fukatani deleted the issue/609 branch November 14, 2019 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Too many output in Circle CI
3 participants