Skip to content

bpo-20082: fix misbehavior of buffered writes to raw files in append mode#21729

Open
embray wants to merge 5 commits intopython:mainfrom
embray:bpo-20082-2
Open

bpo-20082: fix misbehavior of buffered writes to raw files in append mode#21729
embray wants to merge 5 commits intopython:mainfrom
embray:bpo-20082-2

Conversation

@embray
Copy link
Copy Markdown
Contributor

@embray embray commented Aug 4, 2020

This is a patch for a bug I apparently wrote many years ago but never converted to a PR.

https://bugs.python.org/issue20082

@embray
Copy link
Copy Markdown
Contributor Author

embray commented Aug 4, 2020

Hmm, this seems to suddenly be causing some failures I didn't expect :/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function should be checked for failure, so it should not return void.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not so sure. What is its failure state? It either sets self->appending = 1 or self->appending = 0. Neither case represents a failure or success. AFAICT all calls within it check for failure or success and are handled appropriately.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getattr() can raise an arbitrary exception, for example MemoryError or KeyboardInterrupt. They should not be cleared.

BTW, in 3.13 you can use PyObject_GetOptionalAttr() which automatically silences an AttributeError. It exists under other name as private API in older versions.

PyUnicode_FindChar() also can raise an exception, according to the specification, although it is less likely after getting rid of legacy strings.

@embray
Copy link
Copy Markdown
Contributor Author

embray commented Aug 11, 2020

Resolved all the trivial code style issues. Remaining question is whether _bufferedwriter_set_append should have a return value (if so I'm not clear on what it should be).

I think the issue that was causing test failures is fixed.

@embray
Copy link
Copy Markdown
Contributor Author

embray commented Aug 11, 2020

Hmm, now the CI systems are all consistently showing a new test failure, but I cannot reproduce it locally even with the exact same test command they're running.

Update: I can reproduce them now by configuring --with-pydebug.

@embray
Copy link
Copy Markdown
Contributor Author

embray commented Aug 12, 2020

I think this is ready now for the next round of review. Not sure why the Azure pipeline failed but it doesn't seem related.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Apr 8, 2026
embray added 4 commits April 13, 2026 12:52
if the raw file is appending there is no reason to attempt to rewind it before
flushing
…t have a mode attribute) and ensure that the mode is in fact a string
@python-cla-bot
Copy link
Copy Markdown

python-cla-bot bot commented Apr 13, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants