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

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

Merged
merged 8 commits into from Jul 28, 2022

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

@cpython-cla-bot
Copy link

cpython-cla-bot bot commented May 25, 2022

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-bot
Copy link

bedevere-bot commented May 25, 2022

Most changes to Python require a NEWS entry.

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

Modules/posixmodule.c Outdated Show resolved Hide resolved
@eryksun eryksun added OS-windows extension-modules C modules in the Modules dir labels May 25, 2022
@bedevere-bot
Copy link

bedevere-bot commented May 26, 2022

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
@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

bedevere-bot commented May 28, 2022

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
14 checks passed
@raghunandanbhat raghunandanbhat deleted the fix-issue-43414 branch Jul 28, 2022
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