Visitar URL original
bpo-44439: BZ2File.write() / LZMAFile.write() handle buffer protocol correctly by animalize · Pull Request #26764 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20220203014508/https://github.com/python/cpython/pull/26764
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

bpo-44439: BZ2File.write() / LZMAFile.write() handle buffer protocol correctly #26764

Merged
merged 2 commits into from Jun 22, 2021

Conversation

@animalize
Copy link
Contributor

@animalize animalize commented Jun 17, 2021 •

The underlying C codes handle buffer protocol objects correctly, so only fix the wrong length in Python code is fine.

https://bugs.python.org/issue44439

No longer use len() to get the length of the input data. For some buffer protocol objects, the length obtained by using len() is wrong.
Lib/test/test_gzip.py Outdated Show resolved Hide resolved
Lib/bz2.py Outdated Show resolved Hide resolved
Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

LGTM.

@serhiy-storchaka serhiy-storchaka merged commit bc6c12c into python:main Jun 22, 2021
13 checks passed
@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Jun 22, 2021

Thanks @animalize for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.9.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Jun 22, 2021

Sorry, @animalize and @serhiy-storchaka, I could not cleanly backport this to 3.9 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker bc6c12c72a9536acc96e7b9355fd69d1083a43c1 3.9

@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Jun 22, 2021

GH-26845 is a backport of this pull request to the 3.10 branch.

miss-islington added a commit to miss-islington/cpython that referenced this issue Jun 22, 2021
…correctly (pythonGH-26764)

No longer use len() to get the length of the input data. For some buffer protocol objects,
the length obtained by using len() is wrong.
(cherry picked from commit bc6c12c)

Co-authored-by: Ma Lin <animalize@users.noreply.github.com>
@animalize animalize deleted the input_len branch Jun 22, 2021
@animalize
Copy link
Contributor Author

@animalize animalize commented Jun 22, 2021

3.9 branch has a code conflict, I created PR #26846 for 3.9 branch.

serhiy-storchaka pushed a commit that referenced this issue Jun 22, 2021
…correctly (GH-26764) (GH-26845)

No longer use len() to get the length of the input data. For some buffer protocol objects,
the length obtained by using len() is wrong.
(cherry picked from commit bc6c12c)

Co-authored-by: Ma Lin <animalize@users.noreply.github.com>
JuniorJPDJ added a commit to JuniorJPDJ/cpython that referenced this issue Aug 12, 2021
…correctly (pythonGH-26764)

No longer use len() to get the length of the input data. For some buffer protocol objects,
the length obtained by using len() is wrong.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants