-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
Built-in modules inconsistent in different systems. #132834
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
Comments
This should be closed as the zlib module is not an expected part of the stdlib, and this issue is because Windows uses a packaged version of the zlib C library whereas Linux can use others. I presume they both work in decompression? |
you can test it yourself! presume what? |
By passing
Emphasis mine. Per the gzip spec, the 9th byte in the header is the OS marker:
So I believe that the code is working as intended. If you want just a zlib stream, you probably want to remove the |
Thanks, but i use javascript or nodejs in in different systems, it work the same result. this make me in trouble... |
I'm going to close this since zlib is working as intended. A potential solution to make a gzip output that is OS independent would be along the lines of: def zip(e):
if isinstance(e, str):
e = e.encode('utf-8')
b = bytearray(zlib.compress(e, zlib.Z_DEFAULT_COMPRESSION, zlib.MAX_WBITS | 16))
b[9] = 255 # unknown OS, for compatibility, could also set to 3, for UNIX
return bytes(b) Note that the GZip format includes other metadata that is not reproducible such as the mtime field, so the above solution may not be complete. |
Bug report
Bug description:
The zlib module yields inconsistent results across different systems.
ubuntu 24
win 10 arm
CPython versions tested on:
3.11
Operating systems tested on:
No response
The text was updated successfully, but these errors were encountered: