Skip to content

Conversation

raghunandanbhat
Copy link
Contributor

@raghunandanbhat raghunandanbhat commented May 25, 2022

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

@ghost
Copy link

ghost commented May 25, 2022

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-bot
Copy link

Most changes to Python require a NEWS entry.

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

@eryksun eryksun added OS-windows extension-modules C modules in the Modules dir labels May 25, 2022
@bedevere-bot
Copy link

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
Copy link
Contributor

eryksun commented May 26, 2022

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

Most changes to Python require a NEWS entry.

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

@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