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

Use monkeypatch #8628

Merged
merged 1 commit into from
Dec 28, 2024
Merged

Use monkeypatch #8628

merged 1 commit into from
Dec 28, 2024

Conversation

radarhere
Copy link
Member

This PR uses monkeypatch rather than the current behaviour of setting and restoring sys.stdout.

old_stdout = sys.stdout
class MyStdOut:
buffer = BytesIO()
mystdout: MyStdOut | BytesIO = MyStdOut() if buffer else BytesIO()
sys.stdout = mystdout
with Image.open(TEST_PNG_FILE) as im:
im.save(sys.stdout, "PNG")
# Reset stdout
sys.stdout = old_stdout

@hugovk hugovk merged commit e8dad19 into python-pillow:main Dec 28, 2024
48 checks passed
@radarhere radarhere deleted the monkeypatch branch December 28, 2024 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants