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

Let patched sys.stderr.write() and sys.stdout.write() return number of written bytes #134

Merged
merged 1 commit into from
Jul 3, 2022

Conversation

manueljacob
Copy link
Contributor

On Python 3, a file’s write() method is expected to return the number of
written bytes.

It’s a bit unclear what do when no data is actually written (log file
couldn’t be opened in case of stderr or data is deliberately ignored in
case of stdout). I think it’s reasonable in this case to pretend that
all passed data was written. If we returned 0, a caller which calls
write() repeatedly until all data has been written will end up in an
infinite loop.

@albertosottile
Copy link
Member

This LGTM, thanks for this contribution. Any idea why the CI workflow was not triggered? I was expecting an approval request, but I cannot even see that...

@manueljacob manueljacob force-pushed the stdio-write-return_value branch from 9da5416 to 5965646 Compare July 2, 2022 13:36
@manueljacob
Copy link
Contributor Author

The “workflow awaiting approval” went missing. Now, after force-push, it appeared again. Do you get the approval request now?

@manueljacob
Copy link
Contributor Author

Note: the tests will fail on master when you retrigger CI.

@albertosottile
Copy link
Member

I fixed the CI on master, could you rebase?

…f written bytes

On Python 3, a file’s write() method is expected to return the number of
written bytes.

It’s a bit unclear what do when no data is actually written (log file
couldn’t be opened in case of stderr or data is deliberately ignored in
case of stdout). I think it’s reasonable in this case to pretend that
all passed data was written. If we returned 0, a caller which calls
write() repeatedly until all data has been written will end up in an
infinite loop.
@manueljacob manueljacob force-pushed the stdio-write-return_value branch from 5965646 to 7c8dfb7 Compare July 3, 2022 01:10
@albertosottile albertosottile merged commit 73c3afa into py2exe:master Jul 3, 2022
@albertosottile
Copy link
Member

Thank you for this contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants