Skip to content

gh-43414: os.get_terminal_size() should use file descriptors in Windows#93203

Merged
zooba merged 8 commits into
python:mainfrom
raghunandanbhat:fix-issue-43414
Jul 28, 2022
Merged

gh-43414: os.get_terminal_size() should use file descriptors in Windows#93203
zooba merged 8 commits into
python:mainfrom
raghunandanbhat:fix-issue-43414

Conversation

@raghunandanbhat

@raghunandanbhat raghunandanbhat commented May 25, 2022

Copy link
Copy Markdown
Contributor

Modified os.get_terminal_size() to use _get_osfhandle(fd) instead of using hardcoded process standard handles in Windows.
Fixes 43414

@ghost

ghost commented May 25, 2022

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-bot

Copy link
Copy Markdown

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

Comment thread Modules/posixmodule.c Outdated
@eryksun eryksun added OS-windows extension-modules C modules in the Modules dir labels May 25, 2022
@bedevere-bot

Copy link
Copy Markdown

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

@raghunandanbhat raghunandanbhat requested a review from eryksun May 26, 2022 04:00
@eryksun

eryksun commented May 26, 2022

Copy link
Copy Markdown
Contributor

It would be nice to add a test in TermsizeTests in "Lib/test/test_os.py". For example:

    @unittest.skipUnless(sys.platform == 'win32', 'Windows specific test')
    def test_windows_fd(self):
        # gh-87580: support arbitrary file descriptors
        try:
            conout = open('conout$', 'w')
        except OSError:
            self.skipTest('failed to open conout$')
        with conout:
            size = os.get_terminal_size(conout.fileno())

        self.assertGreaterEqual(size.columns, 0)
        self.assertGreaterEqual(size.lines, 0)

@bedevere-bot

Copy link
Copy Markdown

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

Comment thread Misc/NEWS.d/next/Windows/2022-05-28-19-36-13.gh-issue-43414.NGMJ3g.rst Outdated
@zooba zooba merged commit edb7204 into python:main Jul 28, 2022
@raghunandanbhat raghunandanbhat deleted the fix-issue-43414 branch July 28, 2022 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extension-modules C modules in the Modules dir OS-windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

os.get_terminal_size() should use file descriptors in Windows

4 participants