WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
283250
webkitcorepy.terminal.Terminal.override_atty rejects typing.IO subclasses
https://bugs.webkit.org/show_bug.cgi?id=283250
Summary
webkitcorepy.terminal.Terminal.override_atty rejects typing.IO subclasses
Sam Sneddon [:gsnedders]
Reported
2024-11-16 19:24:08 PST
Trying to run the webkitscmpy tests under pytest leads to: ``` _____________________________________________________________ TestLog.test_git ______________________________________________________________ self = <webkitscmpy.test.log_unittest.TestLog testMethod=test_git> def test_git(self):
> with OutputCapture() as captured, mocks.local.Git(self.path), mocks.local.Svn(), MockTime, Terminal.override_atty(sys.stdin, isatty=False):
webkitscmpy/test/log_unittest.py:43: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py:117: in __enter__ return next(self.gen) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ cls = <class 'webkitcorepy.terminal.Terminal'>, target = <_pytest.capture.DontReadFromInput object at 0x1038de910>, isatty = False @classmethod @contextlib.contextmanager def override_atty(cls, target, isatty=True): if not isinstance(target, (io.IOBase, file, StringIO)):
> raise ValueError('{} is not an IO object'.format(target))
E ValueError: <_pytest.capture.DontReadFromInput object at 0x1038de910> is not an IO object .tox/py39/lib/python3.9/site-packages/webkitcorepy/terminal.py:135: ValueError ``` _pytest.capture.DontReadFromInput: In [2]: DontReadFromInput.__mro__ Out[2]: (_pytest.capture.DontReadFromInput, typing.TextIO, typing.IO, typing.Generic, object) Thus it isn't an instance of any of the three classes we're checking for. On the whole, this feels like somewhere where we shouldn't be doing runtime type-checking by default at all. At most, we should probably just be checking for some file-like protocol (having read/write), as there's plenty of file-like objects out there (even within the stdlib!).
Attachments
Add attachment
proposed patch, testcase, etc.
Sam Sneddon [:gsnedders]
Comment 1
2024-11-16 20:05:20 PST
Pull request:
https://github.com/WebKit/WebKit/pull/36766
Radar WebKit Bug Importer
Comment 2
2024-11-23 19:25:32 PST
<
rdar://problem/140486513
>
EWS
Comment 3
2024-12-03 11:38:37 PST
Committed
287299@main
(c4740203d5ee): <
https://commits.webkit.org/287299@main
> Reviewed commits have been landed. Closing PR #36766 and removing active labels.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug