Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Update zlib from 3.12.6 and _ZlibDecompressor implementation #5476

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

Merged
merged 16 commits into from
Jan 16, 2025

Conversation

arihant2math
Copy link
Collaborator

@arihant2math arihant2math commented Jan 14, 2025

After this is merged a few GZip tests are unblocked.

@coolreader18
Copy link
Member

To fix the failing test, you can run cargo fmt in the repository.

@arihant2math
Copy link
Collaborator Author

I can't seem to see how

zlibd = zlib._ZlibDecompressor()
self.assertRaises(TypeError, zlibd.decompress)

can produce a TypeError when using #[pymethod] on the rust side, unless it already does and I'm reading something incorrectly.

@youknowone
Copy link
Member

youknowone commented Jan 14, 2025

Not only Constructor, it may also requires Initializer. Constructor corresponds to __new__ while Initializer corresponds to __init__

Sorry, I just checked CPython code but it doesn't look like that

@arihant2math
Copy link
Collaborator Author

I resolved a few issues, but currently I'm getting a bunch of
RuntimeError: Expected payload '_ZlibDecompressor' but '_ZlibDecompressor' found

@arihant2math
Copy link
Collaborator Author

Additionally _ZlibDecompressor has to be unpicklable for another test to pass, but I'm fine with just disabling that one.

@arihant2math arihant2math marked this pull request as ready for review January 15, 2025 19:03
@arihant2math
Copy link
Collaborator Author

Also it seems to my knowledge __getstate__ isn't a magic method I can use? It would be nice to use it because then I could pass the pickling test rather trivially.

@youknowone
Copy link
Member

youknowone commented Jan 16, 2025

Each class need to implement __getstate__ to support pickling. pickle library will use getstate in priority. Searching for fn getstate will result other types' implementation

Oh... unlike setstate, getstate doesn't have many implementations

Copy link
Member

@youknowone youknowone left a comment

Choose a reason for hiding this comment

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

would you leave a comment which version of CPython did you brought python source from? (including x in 3.12.x)

@youknowone youknowone changed the title _ZlibDecompressor implementation Update zlib from 3.12.6 and _ZlibDecompressor implementation Jan 16, 2025
Copy link
Member

@youknowone youknowone left a comment

Choose a reason for hiding this comment

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

Thank you so much!

@@ -532,6 +532,10 @@ def requires_legacy_unicode_capi():

has_fork_support = hasattr(os, "fork") and not is_emscripten and not is_wasi

# From python 3.12.6
Copy link
Member

Choose a reason for hiding this comment

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

I am sorry to confuse you. Version was required for commit message, but this is also fine too

@youknowone youknowone merged commit 2d83a67 into RustPython:main Jan 16, 2025
11 checks passed
@arihant2math arihant2math deleted the zlib-312 branch January 16, 2025 04:33
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.

3 participants