Skip to content

Update zlib from 3.12.6 and _ZlibDecompressor implementation#5476

Merged
youknowone merged 16 commits into
RustPython:mainfrom
arihant2math:zlib-312
Jan 16, 2025
Merged

Update zlib from 3.12.6 and _ZlibDecompressor implementation#5476
youknowone merged 16 commits into
RustPython:mainfrom
arihant2math:zlib-312

Conversation

@arihant2math

@arihant2math arihant2math commented Jan 14, 2025

Copy link
Copy Markdown
Contributor

After this is merged a few GZip tests are unblocked.

@coolreader18

Copy link
Copy Markdown
Member

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

@arihant2math

Copy link
Copy Markdown
Contributor 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

youknowone commented Jan 14, 2025

Copy link
Copy Markdown
Member

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

Comment thread stdlib/src/zlib.rs Outdated
@arihant2math

Copy link
Copy Markdown
Contributor Author

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

@arihant2math

Copy link
Copy Markdown
Contributor 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
Copy Markdown
Contributor 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

youknowone commented Jan 16, 2025

Copy link
Copy Markdown
Member

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

@youknowone youknowone left a comment

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.

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

Comment thread Lib/test/support/__init__.py
@youknowone youknowone changed the title _ZlibDecompressor implementation Update zlib from 3.12.6 and _ZlibDecompressor implementation Jan 16, 2025

@youknowone youknowone left a comment

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.

Thank you so much!


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

# From python 3.12.6

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.

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

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